|
-
Aug 21st, 2001, 07:42 PM
#1
Thread Starter
Hyperactive Member
not closing
When I exit my program it disappears but it stays in the ctrl-alt-delete menu so if I try and re-build it I can't. Does anyone know whats wrong?
Matt 
-
Aug 21st, 2001, 07:44 PM
#2
Frenzied Member
what are you using to close it?
-
Aug 21st, 2001, 07:48 PM
#3
Thread Starter
Hyperactive Member
Code:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
Matt 
-
Aug 21st, 2001, 08:04 PM
#4
Frenzied Member
how are you closing it? The title bar? A button?
-
Aug 21st, 2001, 08:10 PM
#5
Thread Starter
Hyperactive Member
the "X" at the top of the window
Matt 
-
Aug 21st, 2001, 09:10 PM
#6
Member
exit(0) will work.
-
Aug 22nd, 2001, 09:25 AM
#7
Monday Morning Lunatic
You shouldn't use exit like that. It's very bad (like using End in VB) because certain things don't get cleared up.
What's in your message loop? Your window procedure looks fine to me.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 23rd, 2001, 09:17 AM
#8
yeah, it's probably the mesage loop
i suppose it's something like that:
PHP Code:
while(GetMessage(&msg, hwnd, 0, 0) // hwnd is the main window
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
but WM_QUIT (which makes GetMessage return 0, thus leaving the loop) is not directed to any window, so GetMessage(hwnd) won't catch it. Use GetMessage(&msg, NULL, 0, 0) instead.
I once had that problem and the symptoms were exactly the same, so I suppose that's the problem you have.
All the buzzt
CornedBee
-
Aug 23rd, 2001, 09:44 AM
#9
Monday Morning Lunatic
Code:
while(GetMessage(&msg, hwnd, 0, 0) // hwnd is the main window
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Bad CornedBee It should be:
Code:
while(GetMessage(&msg, NULL /* or hwnd if ya want */, 0, 0) > 0) {
Translate...
Dispatch...
}
You need to cater for a -1 return value as well, which is converted to a bool true.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 23rd, 2001, 02:53 PM
#10
Thread Starter
Hyperactive Member
for some reason my loop looks the same as yours but I replaced it and it works. thanks alot!
Matt 
-
Aug 24th, 2001, 02:21 AM
#11
that's cool parksie, I always wondered how to catch the possible -1 return without a damn complicated loop. I never thought about this easy way. Thanks
Oh, and Preston, I don't think you need to handle the WM_CLOSE message. I think DefWindowProc calls DestroyWindow by default. At least my programs seem to work flawless(correct english?) with it, but I'm not sure.
All the buzzt
CornedBee
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|