|
-
July 17th, 2004, 06:49 PM
#1
Why cant I get the resource ID?
Why can not I get the resource ID of a dialog using GetDlgCtrlID?
int CTestDlg::GetID()
{
return GetDlgCtrlID();
}
-
July 17th, 2004, 08:35 PM
#2
Interesting.
Try passing in NULL as the parameter. What does GetDlgCtrlID() return?
Kuphryn
-
July 17th, 2004, 08:54 PM
#3
Is your dialog a child window or a top-level window?
From the documentation of GetDlgCtrlID():
Although GetDlgCtrlID may return a value if hwndCtl is a handle to a top-level window, top-level windows cannot have identifiers and such a return value is never valid.
-
July 17th, 2004, 09:39 PM
#4
I have tired creating the dialog as a top-level window as well as a child window, but it always returns 0.
Well, how can I get the resoucre ID even it is a top-level window?
-
July 18th, 2004, 09:21 AM
#5
 Originally Posted by kuphryn
Try passing in NULL as the parameter. What does GetDlgCtrlID() return?
Since he obviously uses the 'CWnd' version, how would he supposed to pass 0? The function does not take any parameter as opposed to the API version...
-
July 18th, 2004, 10:28 AM
#6
 Originally Posted by PomeloWu
I have tired creating the dialog as a top-level window as well as a child window, but it always returns 0.
Well, how can I get the resoucre ID even it is a top-level window?
Note that GetDlgCtrlID() gives you the control ID of a control - that's something else than the resource ID. AFAIK, there's no way to determine the original resource ID of a dialog once it is created. Anyway, what do you need this for? If you absolutely need to know the ID of the resource at runtime, you could do the following: Create your own CDialog-derived class and derive all your app's dialogs from that class (instead of deriving directly from CDialog). Then add a ctor similar to that of CDialog, which, besides from calling the base ctor, saves the resource ID that is passed upon creation to a member variable. You can then add a member function GetResourceID() which returns that value.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|