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();
}
[139 byte] By [PomeloWu] at [2007-11-18 22:16:50]
# 1 Re: Why cant I get the resource ID?
Interesting.

Try passing in NULL as the parameter. What does GetDlgCtrlID() return?

Kuphryn
kuphryn at 2007-11-11 1:04:18 >
# 2 Re: Why cant I get the resource ID?
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.
RussG1 at 2007-11-11 1:05:18 >
# 3 Re: Why cant I get the resource ID?
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?
PomeloWu at 2007-11-11 1:06:18 >
# 4 Re: Why cant I get the resource ID?
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... :rolleyes:
Andreas Masur at 2007-11-11 1:07:24 >
# 5 Re: Why cant I get the resource ID?
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.
gstercken at 2007-11-11 1:08:23 >