#### Archived

This topic is now archived and is closed to further replies.

# Problem.

This topic is 5838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

sorry for having to start a new topic but im not getting any replies in my other one. i have the book "Multiplayer Game Programming" which taught me a few things, but some things i cant get to work and im still not real sharp on, due to some lack of explanation. of of these is the displaying of child windows. i THINK i have the code all right for it, but they just dont show in the window. here''s what i have.
  #include #include #define IDC_hBU_STATIC 40001 #define IDC_hBU_EDIT 40002 HWND hBU_STATIC = NULL; HWND hBU_EDIT = NULL; LPCTSTR lpszApplicationName = "Sweet"; LPCTSTR lpszTitle = "Totally Sweet Flipped Out Ninjas"; LRESULT CALLBACK fnMessageProcessor (HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { HWND hWnd; MSG msg; WNDCLASSEX wndclass; LOGBRUSH background; wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = fnMessageProcessor; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = "Sweet"; wndclass.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); background.lbStyle = BS_PATTERN; background.lbHatch = (long) LoadImage( hInstance, "loginbg.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); wndclass.hbrBackground = CreateBrushIndirect(&background); if( ( RegisterClassEx( &wndclass ) == 0 ) ) { exit(1); } hWnd = CreateWindow("SWEET", "Totally Sweet Flipped Out Ninjas", WS_EX_TRANSPARENT | WS_EX_CLIENTEDGE, CW_USEDEFAULT, CW_USEDEFAULT, 400, 200, NULL, NULL, hInstance, NULL ); hBU_STATIC = CreateWindow( "account", "Account:", WS_CHILD | WS_VISIBLE, 80, 72, 120, 28, hWnd, NULL, hInstance, NULL ); hBU_EDIT = CreateWindow( "accountfield", "!", WS_CHILD | WS_VISIBLE | SS_CENTER, 80, 72, 120, 28, hWnd, NULL, hInstance, NULL ); ShowWindow( hWnd, iCmdShow ); UpdateWindow( hWnd ); while( TRUE ) { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (!GetMessage(&msg, NULL, 0, 0)) break; TranslateMessage( &msg ); DispatchMessage( &msg ); } } return ( msg.wParam ); } LRESULT CALLBACK fnMessageProcessor ( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) { switch( iMsg ) { case WM_CREATE: return( 0 ); case WM_PAINT: return( 0 ); case WM_DESTROY: PostQuitMessage( 0 ); return( 0 ); } return DefWindowProc( hWnd, iMsg, wParam, lParam ); } 

##### Share on other sites
ShowWindow( hWnd, iCmdShow );
UpdateWindow( hWnd );

for every window, i guess.

##### Share on other sites
You realize it''s only been a few hours (a day at the most) since you last posted to the other thread? The proper thing to do is to "bump" your thread up by posting follow-up questions at the end - "Anyone?", "I really need some insight on this", etc.

Since this is a beginners forum, we''re very careful to be extra nice and keep the flamers away, but that''s what you should do in the future. Personally, I saw the post but was (and am) tired. Maybe when I wake up from my nap...?

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

##### Share on other sites
yeah, im quite aware. ill try the showwindow for every window then.

##### Share on other sites
that doesnt fix my problem, the multiple showwindow functions

##### Share on other sites
Each time you create a window you specify which window-class it should belong to (the first parameter in the call to CreateWindow). This window class must have been defined before creating the window. As far as I can see you do not define the "account" and "accountfield" classes.

Judging from the names of the HWND-variables you may simply want to use the pre-defined classes "STATIC" and "EDIT".

##### Share on other sites
that worked, thanks.

now i have one last problem: how do i modify the static text to look different? or isnt that possible?

##### Share on other sites
? i need to make the background of my static text transparent, maybe change the font if thats possible, and make the text white. does static text support this or do i have to use something else?

##### Share on other sites
i have searched various places and i cant come up with a way to edit static text. ive read my book through, i cant find it. any help is appreciated... or at least point me to a tutorial or something on it.

##### Share on other sites
SetWindowText(LPCTSTR lpszString)

Search for SetWindowText at msdn.microsoft.com, and you''ll get a whole long list of child window functions

##### Share on other sites
You should not have your paint message like:

WM_PAINT:
return 0;

The window will not be repainted unless you call BeginPaint and
EndPaint or(validateRect). Windows will just send multiple paint messages!!! You should atleast declare WM_PAINT as:

WM_PAINT:
BeginPaint(hwnd,&ps);
EndPaint(hwnd, &ps);
return 0;

-----------------------------
"There are ones that say they can and there are those who actually do."

"...u can not learn programming in a class, you have to learn it on your own."

##### Share on other sites
You should not have your paint message like:

WM_PAINT:
return 0;

The window will not be repainted unless you call BeginPaint and
EndPaint or(validateRect). Windows will just send multiple paint messages!!! You should atleast declare WM_PAINT as:

WM_PAINT:
BeginPaint(hwnd,&ps);
EndPaint(hwnd, &ps);
return 0;

-----------------------------
"There are ones that say they can and there are those who actually do."

"...u can not learn programming in a class, you have to learn it on your own."

##### Share on other sites
hmph. static text troubles me. are there any other ways of putting text on a window? and so it isnt bold looking like static text is?

##### Share on other sites
Send the static text a new font to use if you don''t like the default one. See CreateFont and WM_SETFONT.

##### Share on other sites
i really cant get this to work. i put in the codes with all the right params set, and i keep getting these syntax errors. i dont know if im putting them in the wrong place, or what. could somebody please take me step through step how to accually set it so the background of the child window is transparent and how to change the font to something more appealing? ive "RTFM", its just that its not explained very well to a beginner how to use some of the functions really.

##### Share on other sites
anybody? if somebody just explained it once to me i''d get it.

##### Share on other sites
sigh... thanks anyways?

##### Share on other sites
la la la... ill just sit here and talk to myself then

so, how was you''re day?

well me, it blew dogs for quarters.

oh, whys that?

well everybody hates me on the gamedev.net forums and they wont help me out with my static text problems/questions!

oh that sucks.

sure does!