In MFC, how can I find the actual signature of a function which is combined with a specific notification [modified]
-
Hey guys, Help! I have been using visual C++ for a while, but there is a issue always make me confused. The description of the issue: We use this Macro very often: ON_NOTIFY(wNotifyCode, id, memberFxn), but how do you know what is the actual signature of memberFxn. For instance, when we use ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText) At the same time, we will define a function called OnToolTipText, the signature of this function is: OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult) For the parameter pNMHDR, we know the actual data type maybe not NMHDR, sometime we convert it by using a specific data type rather than using it directly. The actual struct of NMHDR is: typedef struct tagNMHDR { HWND hwndFrom; UINT idFrom; UINT code; } NMHDR; For the notification TTN_NEEDTEXTW, we convert parameter pNMHDR by using TOOLTIPTEXTA, so my question is: how, when and where do you know you should use TOOLTIPTEXTA to convert it? why don't you use something else? is there any documents talk about what type we should use to convert a specific parameter? PS: If you don't mind, I have one more question, is there anyone knows how to use CListCtrl::SetInfoTip()? I want to set a tooltip for each cell of the table, I tired to use SetInfoTip(), but it doesn't work well. Can you teach me how to use it? Thank you so much!
David Zuo
-
Hey guys, Help! I have been using visual C++ for a while, but there is a issue always make me confused. The description of the issue: We use this Macro very often: ON_NOTIFY(wNotifyCode, id, memberFxn), but how do you know what is the actual signature of memberFxn. For instance, when we use ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText) At the same time, we will define a function called OnToolTipText, the signature of this function is: OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult) For the parameter pNMHDR, we know the actual data type maybe not NMHDR, sometime we convert it by using a specific data type rather than using it directly. The actual struct of NMHDR is: typedef struct tagNMHDR { HWND hwndFrom; UINT idFrom; UINT code; } NMHDR; For the notification TTN_NEEDTEXTW, we convert parameter pNMHDR by using TOOLTIPTEXTA, so my question is: how, when and where do you know you should use TOOLTIPTEXTA to convert it? why don't you use something else? is there any documents talk about what type we should use to convert a specific parameter? PS: If you don't mind, I have one more question, is there anyone knows how to use CListCtrl::SetInfoTip()? I want to set a tooltip for each cell of the table, I tired to use SetInfoTip(), but it doesn't work well. Can you teach me how to use it? Thank you so much!
David Zuo
All
ON_NOTIFY
handlers have the same signature. For other macros, see the documentation for that macro. The convention for any message sent withWM_NOTIFY
is for thelParam
parameter of the window message to point to a structure that either is, or begins with, anNMHDR
structure - the notification code is actually part of this structure. To find out if there's an extended structure sent with a given notification code, check the documentation for that code. In your specific situation you should be matching aTOOLTIPTEXT**W**
structure with theTTN_NEEDTEXTW
notification. In general you should consider using the versions with no character-encoding-width indicator,TTN_NEEDTEXT
and, as documented in the latest MSDN Library, aNMTTDISPINFO
structure.Stability. What an interesting concept. -- Chris Maunder