I am trying to use WTL::CHyperLink in order to display a clickable link on my application.
According to this article, I need to attach it to a Static Text control.
So, in my GUI, I have now created a static text control with an ID of IDC_LINK
In my DDX MAP:
BEGIN_DDX_MAP(MyDialog)
DDX_CONTROL_HANDLE(IDC_LINK, m_link)
END_DDX_MAP()
and as a member variable:
CHyperLink m_link;
However, I am always left with this:
Error C2679: Binary Operator '=': No operator accepting a right-hand operant of type 'ATL::CWindow' (or no suitable conversion possible)
Does anyone know what I am doing wrong?
WTL CHyperLink
is a custom control implementation class and unlike other classes like CEdit
, which are thin HWND
wrappers, you cannot initialize the control by using assignment operator with window handle (which is what DDX_CONTROL_HANDLE
map tries to do) and by just manipulating window handle only in general. You are supposed to either create a control window from scratch (CHyperLink::Create
), or take a pre-created static control and subclass it using CHyperLink::SubclassWindow
.
With static control already existing in the dialog template, which is supposed to back your hyperlink, you can try DDX_CONTROL
macro instead of DDX_CONTROL_HANDLE
because it attempts to initialize by subclassing using SubclassWindow
call.
Non-DDX initialization code snippet is here: SubclassWindow
+ SetHyperLink
calls in WM_INITDIALOG
handler.
You asked a similar question before: Error when trying to hook up a control with DDX_CONTROL And at that time you confused the same two DDX macros the other way...