Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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 at 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 at 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 Shai Vashdi 1,518
1 Tadit Dash 350
2 Manas Bhardwaj 319
3 OriginalGriff 243
4 Sergey Alexandrovich Kryukov 240
0 Sergey Alexandrovich Kryukov 9,530
1 OriginalGriff 5,716
2 Peter Leow 4,320
3 Maciej Los 3,540
4 Abhinav S 3,373


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