C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-10-2010, 03:06 AM   #1
Registered User
 
Join Date: Feb 2010
Posts: 34
Child window handle not known

I defined a child window in my Window procedure as follows:

Code:
for(i = 3; i < 13; i++) hwndEdit[i] = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("edit"), TEXT(""), WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL, 2*cxChar, (6+(2+7/4)*i)*cyChar, 10*cxChar, 7*cyChar/4, hwnd, (HMENU) i+3, ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
For i=5 I obviously have a child window ID of 8. In the procedure I can communicate with this child window through this ID. However, if I try to communicate with this child window in a Dialog procedure it doesn't work. If I try to get the child window handle with:

Code:
hChild = GetDlgItem(hwnd, 8);
if(hChild) MessageBox(NULL, TEXT("A handle is returned"), TEXT("Warning!"), MB_OK | MB_ICONINFORMATION);
the MessageBox will not show up. hwnd is provided as a parameter to the Dialog Procedure. What am I doing wrong?
mvanrijnbach is offline   Reply With Quote
Old 03-10-2010, 03:42 AM   #2
Registered User
 
Join Date: Feb 2010
Posts: 34
Actually I think I should use hChild = GetDlgItem(GetParent(hwnd), 8), because hwnd is the handle to the Dialog Window. The child window with ID 8 also has the parent of the Dialog Window as its parent.
mvanrijnbach is offline   Reply With Quote
Old 03-10-2010, 03:43 AM   #3
Registered User
 
Join Date: Feb 2010
Posts: 34
hmmm, still this doesn't work though....
mvanrijnbach is offline   Reply With Quote
Old 03-10-2010, 06:31 AM   #4
Registered User
 
Join Date: Feb 2010
Posts: 34
ok, this is pretty stupid. I fixed it myself The 'i+3' after (HMENU) in CreateWindow has to be in between brackets, otherwise only the handle to ID equal to 3 is known.
mvanrijnbach is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting other processes class names Hawkin Windows Programming 3 03-20-2008 04:02 PM
Posting a message to a child window axr0284 Windows Programming 6 01-27-2005 09:35 AM
problem with open gl engine. gell10 Game Programming 1 08-21-2003 04:10 AM
OpenGL and Windows sean345 Game Programming 5 06-24-2002 10:14 PM
opengl code not working Unregistered Windows Programming 4 02-14-2002 10:01 PM


All times are GMT -6. The time now is 12:09 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22