Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
1 ratings:
 5 out of 5     Rate this Document

Why Do I Get an Incorrect Resource ID String from the CNiNumEdit Measurement Studio Control?

Primary Software: Measurement Studio>>Visual C++ Support
Primary Software Version: 8.1
Primary Software Fixed Version: 8.1
Secondary Software: N/A

Problem: Using Microsoft Foundation Class (MFC) libraries, control resource IDs may be obtained using the CWnd::GetDlgCtrlID() method.

CWnd *pWnd = GetFocus();
pWnd->GetDlgCtrlID();

However, using this method to obtain the resource ID from the Measurement Studio CNiNumEdit control returns an invalid resource ID. How do I get the correct resource ID?

Solution: The CNiNumEdit control is actually composed of multiple controls. When the focus is on the CNiNumEdit control, it is really focused on the EditBox control of the CNiNumEdit control. To obtain the resource ID for the entire CNiNumEdit control, query the parent control.

CWnd *pWnd = GetFocus();
pWnd->GetParent()->GetDlgCtrlID();

In this approach, the user cannot have a single handler for all controls. There must be two handlers. The handlers can call a common funtion after getting the control ID.

//for CniNumEdit controlo
Handler2()
{
CWnd *pWnd = GetFocus();
int id = pWnd->GetParent()->GetDlgCtrlID();
CommonFunction(id);
}

//for other controls
Handler1()
{
CWnd *pWnd = GetFocus();
int id = pWnd->GetDlgCtrlID();
CommonFunction(id);
}

Refer to the Related Links section for more information.



Related Links: KnowledgeBase 126GIBh0: How Do I Create Controls Dynamically in Microsoft Visual C++ When Using MFC without the Demo Mode Message Window?

Attachments:





Report Date: 10/27/2006
Last Updated: 04/10/2007
Document ID: 3XU8IQNX

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit