Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I use GetDlgCtrlID to show tooltips on my buttons.

This worked well before.

Now I copied a bunch of buttons to an other dialog, which gave me some issues with the resource.h file.
I fixed these manually

Now it seems the buttons that were copied don't return their ID with GetDlgCtrlID
not in the new dialog, neither in the original dialog.

However, in the solution explorer visual studio fives me a tooltip with the correct ID
f.e.
IDC_LOCK
#define IDC_LOCK 11297    (tooltip this corresponds with resource.h)


Any ideas on this one?
my guess is to clean the resources, but that will be a pain, since it is a big file.
or can it be done automatically?

thanks
Posted

If the function is not returning the id then you need to check with GetLastError() to find out why. Also the piece of code you posted above does not prove anything. Having a #define statement in a file does not mean it matches anything else in your project. Maybe you need to show some more of your code.
 
Share this answer
 
Here is the code that handles the tooltips

It works fine for all original buttons.
for the ones i copied from an other dialog, it does not work
it will not return an ID


BOOL CSend_DataDlg::OnToolTipNotify( UINT id,
                                  NMHDR * pNMHDR,
                                  LRESULT * pResult )
{
	
	AFX_MODULE_THREAD_STATE* pModuleThreadState =AfxGetModuleThreadState();
	//if(pModuleThreadState)
	{
		CToolTipCtrl* pToolTip = pModuleThreadState->m_pToolTip;
		if(pToolTip)
		pToolTip->SetMaxTipWidth(130);
	}
    // Get the tooltip structure.
    TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;

    // Actually the idFrom holds Control's handle.
    UINT CtrlHandle = pNMHDR->idFrom;
	

    // Check once again that the idFrom holds handle itself.
    if ((pTTT->uFlags & TTF_IDISHWND))
    {
        // Get the control's ID.
        UINT nID = ::GetDlgCtrlID( HWND( CtrlHandle ));
        // Now you have the ID. depends on control,
        // set your tooltip message.
		CString str;
		str.Format("%i", nID);
		AfxMessageBox(str);
//this is just to check if the ID is read
		switch( nID )
        {
			//activate button
	    case IDC_MAP_1:
                pTTT->lpszText = _T("Write curves of map 1");
            break;
	    case IDC_MAP_2:
		pTTT->lpszText = _T("Write curves of map 2");
            break;
        }
    }
}
 
Share this answer
 
Comments
Richard MacCutchan 16-Nov-12 6:26am    
Use your debugger to look at all the returned values, and check what error is being raised when GetDlgCtrlID() returns 0.
Richard MacCutchan 16-Nov-12 6:27am    
Also please don't post additional information as a solution (it's not). Use the "Improve Question" link.
Hello,

I solved it, appearently by copying the buttons they were placed "beneath" a group box that groups the buttons.

So the mouse pointer actually pointed to the group box instead of the buttons...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900