Click here to Skip to main content
Sign Up to vote bad
good
See more: C++
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 15-Nov-12 3:54am


3 solutions

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...
  Permalink  
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.
  Permalink  
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;
        }
    }
}
  Permalink  
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.

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 393
1 Prasad_Kulkarni 390
2 Michael Haephrati 390
3 OriginalGriff 320
4 CPallini 279
0 Sergey Alexandrovich Kryukov 6,824
1 Prasad_Kulkarni 3,671
2 _Amy 3,312
3 OriginalGriff 3,309
4 CPallini 2,925


Advertise | Privacy | Mobile
Web02 | 2.6.130617.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid