Problem.

Started by
16 comments, last by Lugie 22 years, 3 months ago
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 <windows.h>
#include <stdio.h>

#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 );

}  
War is how Americans learn geography.
Advertisement
I din''t read all your code, but you need to
ShowWindow( hWnd, iCmdShow );
UpdateWindow( hWnd );

for every window, i guess.

humanity will always be slaved by its ignorance
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!
yeah, im quite aware. ill try the showwindow for every window then.
War is how Americans learn geography.
that doesnt fix my problem, the multiple showwindow functions
War is how Americans learn geography.
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".
that worked, thanks.

now i have one last problem: how do i modify the static text to look different? or isnt that possible?
War is how Americans learn geography.
? 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?
War is how Americans learn geography.
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.
War is how Americans learn geography.
SetWindowText(LPCTSTR lpszString)

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

This topic is closed to new replies.

Advertisement