Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Win32 (http://www.go4expert.com/forums/win32/)
-   -   What is the Dialog Id, and how do I get it? (http://www.go4expert.com/forums/dialog-id-i-t15935/)

xytor 25Jan2009 00:58

What is the Dialog Id, and how do I get it?
 
Hi, I created a few controls (some edits, a button) inside my window using CreateWindow.
For the HMENU parameter, i just put in some arbitrary values I predefined. I assumed that this is the dialog id.
However, when I use functions like SetDlgItemText, the second parameter, int nIDDlgItem, does not accept that HMENU id I gave it upon creation. (the function fails with error code ERROR_CONTROL_ID_NOT_FOUND)

What is nIDDlgItem, and how do I get it?

shabbir 25Jan2009 07:22

Re: What is the Dialog Id, and how do I get it?
 
Every resource in MFC has an ID and you can get that with the combination of RC file and resource.h file values.

For Code you need to use the API GetDlgCtrlID function

xytor 25Jan2009 09:36

Re: What is the Dialog Id, and how do I get it?
 
I am not using any resources, I'm just creating the controls using CreateWindow.
Do I need to create my own resource.h file with the id's?

xytor 25Jan2009 09:37

Re: What is the Dialog Id, and how do I get it?
 
Oh, sorry, I didn't notice that reference to GetDlgCtrlID,
That should do it, thanks!

xytor 25Jan2009 09:44

Re: What is the Dialog Id, and how do I get it?
 
unfortunately, it didn't work.
GetDlgCtrlID failed and returned 0. GetLastError also returned 0 after this.
How is this possible? The controls are created and visible on the page.

shabbir 25Jan2009 11:20

Re: What is the Dialog Id, and how do I get it?
 
You need to show us some code.

Post it here.

xytor 25Jan2009 14:23

Re: What is the Dialog Id, and how do I get it?
 
Actually, it was my mistake! I forgot to give it an id when creating it (and left it 0 by mistake)
Sorry for wasting your time. I wish this forum let new users delete their posts...

shabbir 25Jan2009 14:42

Re: What is the Dialog Id, and how do I get it?
 
Yes they do when they cross some post count.

yasirhs 26Jan2009 06:06

Re: What is the Dialog Id, and how do I get it?
 
what??


All times are GMT +5.5. The time now is 21:37.