Jump to content

  • Log In with Google      Sign In   
  • Create Account


Problem.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
17 replies to this topic

#1 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 January 2002 - 01:25 PM

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

}  


Sponsor:

#2 hewhay   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 January 2002 - 01:38 PM

I din''t read all your code, but you need to
ShowWindow( hWnd, iCmdShow );
UpdateWindow( hWnd );

for every window, i guess.



#3 Oluseyi   Staff Emeritus   -  Reputation: 1678

Like
Likes
Like

Posted 18 January 2002 - 01:39 PM

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!


#4 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 January 2002 - 03:26 PM

yeah, im quite aware. ill try the showwindow for every window then.

#5 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 January 2002 - 03:32 PM

that doesnt fix my problem, the multiple showwindow functions

#6 Dactylos   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 January 2002 - 04:23 PM

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".

#7 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 January 2002 - 05:41 PM

that worked, thanks.

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

#8 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 January 2002 - 06:44 AM

? 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?

#9 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 January 2002 - 07:55 AM

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.

#10 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 19 January 2002 - 08:14 AM

SetWindowText(LPCTSTR lpszString)

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

#11 cMADsc   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 January 2002 - 06:11 PM

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."



#12 cMADsc   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 January 2002 - 06:11 PM

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."



#13 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 January 2002 - 09:27 AM

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?

#14 Null and Void   Moderators   -  Reputation: 1087

Like
Likes
Like

Posted 20 January 2002 - 09:34 AM

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



#15 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 January 2002 - 11:34 AM

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.

#16 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 January 2002 - 09:35 AM

anybody? if somebody just explained it once to me i''d get it.

#17 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2002 - 09:55 AM

sigh... thanks anyways?

#18 Lugie   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2002 - 03:46 PM

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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS