Beginner needing some help please...

Started by
1 comment, last by MINS 23 years, 9 months ago
HI I am just learning C++ and i think its great! But i just finshed some code out of a book- 21 days learn C++ etc etc And it explains part of a code every diffacult and I wonder if anyone here can tell me in a better sense so I can understand. Also the PDF book is pissing me off to go back and forth LOL well the code is- GetDlgItem He says that its passed the ID of the controls i wanna change?? I dont understand someone please help me I used this code to disable and enable showing stuff.. Also anyone with ICQ good at C++ or learning like me contact me so we can chat and help me or learn togeather thanks cya ICQ- 48233744 thanks bye
Advertisement

Hi,

What he means is that you pass the ID of the control (listbox/edit box) to GetDlgItem() and you get a pointer to window (base class to edit boxes/list boxes). You then cast the return value to appropriate class and you now have a pointer to requested editbox/listbox/whatever.
If you use MFC I think it creates a separate file with IDs, you won''t miss it.
Otherwise you have created the IDs by yourself, or?

I mean, something like this:
#define IDC_EDITBOX 4327894327894327894378943789

CEdit* ptr;
ptr=(CEdit*) GetDlgItem(IDC_EDITBOX);

now you have a ptr to box. Now you may use it.

Got it?



/Mankind gave birth to God.
/Mankind gave birth to God.
GetDlgItem() is also a function call in Win32 programming. You can use it to get the HWND of a dialog control. Let say you have a dialog window with a text box. To get the information in the textbox you call:

    char s[50];GetWindowText(GetDlgItem( /* handle to dialog box */, /* id to text box control */ ), &s, 50);     




Gandalf the Black


Edited by - Gandalf on August 2, 2000 6:05:00 AM
Gandalf the Black

This topic is closed to new replies.

Advertisement