🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Help.. first Windows app....

Started by
9 comments, last by BugSquash 24 years, 4 months ago
Help me! I''m using VC++ 6, and I am making my first windows app. But, CreateWindow is crapping out. I used a little error code finder copied from the MSDN, and it said "The parameter is incorrect." well woppidty doo. According to WGPDUMB, my CreateWindow is legal. (It worked before, too!) Anyways, here it is: hWindow = CreateWindow("FRSTCLASS", "T A E L O I D !", WS_OVERLAPPEDWINDOW / WS_VISIBLE, 100, 100, 300, 300, NULL, NULL, hinstance, NULL); H E L P ! --BugSquash Taeloid!
NARF!
Advertisement
Never mind. I fixed that. Now it works, but I still have a problem. The project is called "Fullwin", and when you close, a copy of it called "Fullwin" hangs around and it doesn''t go away. My app doesn''t seem to be recieving WM_QUIT from PostQuitMessage() in WM_DESTROY. Please... help....
NARF!
I''m not sure this will help, but here''s some possible solutions:
Make sure the code in your WM_DESTROY message has PostQuitMessage(0);

In your WinMain you should have a main loop (after you create windows and initialize stuff) that receives messages with the PeekMessage function. Maybe you do already. Here''s the basic code I use:
while(1){	if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	{ 		// test if this is a quit		if (msg.message == WM_QUIT)			break;			// translate any accelerator keys		TranslateMessage(&msg);		// send the message to the window proc		DispatchMessage(&msg);	} // end if   	else		WaitMessage();} // end while 


Maybe you were missing something like this? Of course in a real application there might be more stuff in your loop, but this will handle the messages.

Good luck,
Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
I''m doing al that stuff, and I am still pretty sure I am not recieving the WM_QUIT. Wierd.

--BugSquash
Taeloid!
NARF!
How do you have your Window class structure setup? Maybe your Windows Procedure function isn''t set up correctly.
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
quote:

LRESULT CALLBACK WindowProc(HWND hWindow,
UINT msg,
WPARAM wparam,
LPARAM lparam){
HDC hdc;
PAINTSTRUCT ps;

//Find message , react to it.
switch(msg){
case WM_CREATE:
{


return(0);
} break;

case WM_PAINT:
{
//Do this when I actually need to
return(0);
} break;

case WM_DESTROY:
{
MessageBox(NULL, "You ahve reached WM_DESTROY", "AY!", MB_OK);
PostQuitMessage(0);
return(0);
} break;

default: break;

} //End Switch


return(DefWindowProc(hWindow, msg, wparam, lparam));
} //End WindowProc



Please ignore the low-quality of the function.

--BugSquash
Taeloid!

NARF!
When you recieve a WM_PAINT message you need to at least validate the window. This may be your problem.

hdc = BeginPaint(hWnd, &paintStruct);
//do some stuff here
EndPaint(hwnd, &paintStruct);
Oh. I just have a solid black brush so I figured I didn''t have to. Hear I go...

--BugSquash
Taeloid!
NARF!
ARGH! NO WM_QUIT message yet, and the invisible app STILL popps up! Argh! aaah! Argh! Etc!

--BugSquash
Taeloid!
NARF!
Check this line here:
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
make sure it is exactly like that, and not :
if (PeekMessage(&msg,hwnd,0,0,PM_REMOVE))

This topic is closed to new replies.

Advertisement