C++ Win32 freezing when mouse is moved

Started by
14 comments, last by empirical2 13 years ago
Hello all

I've been having trouble for a while with this ever since I made a customized Window class to make be able to call functions that would easily do things like go full screen, set up child windows, changing cursors, stuff like that. Ever since then, occasionally, when my computer feels like it, all mouse movements will stop entire programming from running. All painting stops, as do frame counters. Also, much more recently, that same program will stop running just like before when a key is held down. What could be going on, if anyone has encountered this before? Does it even have anything to do with writing a custom window class?

I'm sorry about any spelling or grammar mistakes or any undue brevity, as I'm most likely typing on my phone

"Hell, there's more evidence that we are just living in a frequency wave that flows in harmonic balance creating the universe and all its existence." ~ GDchat

Advertisement
Does it even have anything to do with writing a custom window class?[/quote]
If it does not occur when you don't use the custom window class, then there's likely something wrong with that class.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Show your WinProc.
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
...and your Message pump (the Peek/GetMessage,TranslateMsg/DispatchMsg part).

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

LOL why would it get stuck from just creating a class?

You clearly jacked something up with your codes outside of the class...

Hello all

I've been having trouble for a while with this ever since I made a customized Window class to make be able to call functions that would easily do things like go full screen, set up child windows, changing cursors, stuff like that. Ever since then, occasionally, when my computer feels like it, all mouse movements will stop entire programming from running. All painting stops, as do frame counters. Also, much more recently, that same program will stop running just like before when a key is held down. What could be going on, if anyone has encountered this before? Does it even have anything to do with writing a custom window class?


I would check your winproc, Are you handling default messages? your program might be drowning in messages.

Show your WinProc.


I copied this directly out of a book, so it should work perfectly.


// Route Windows messages to game engine member functions
switch (msg)
{
case WM_CREATE:
// Set the game window and start the game
m_pWindow->SetWindow(hWindow);
GameStart(hWindow);
return 0;

case WM_SETFOCUS:
// Activate the game and update the Sleep status
GameActivate(hWindow);
SetSleep(FALSE);
return 0;

case WM_KILLFOCUS:
// Deactivate the game and update the Sleep status
GameDeactivate(hWindow);
SetSleep(TRUE);
return 0;

case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC = BeginPaint(hWindow, &ps);

// Paint the game
GamePaint(hDC);

EndPaint(hWindow, &ps);
return 0;

case WM_LBUTTONDOWN:
// Handle left mouse button press
MouseButtonDown(LOWORD(lParam), HIWORD(lParam), TRUE);
return 0;

case WM_LBUTTONUP:
// Handle left mouse button release
MouseButtonUp(LOWORD(lParam), HIWORD(lParam), TRUE);
return 0;

case WM_RBUTTONDOWN:
// Handle right mouse button press
MouseButtonDown(LOWORD(lParam), HIWORD(lParam), FALSE);
return 0;

case WM_RBUTTONUP:
// Handle right mouse button release
MouseButtonUp(LOWORD(lParam), HIWORD(lParam), FALSE);
return 0;

case WM_MOUSEMOVE:
// Handle mouse movement
MouseMove(LOWORD(lParam), HIWORD(lParam));
return 0;

case WM_DESTROY:
// End the game and exit the application
GameEnd();
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWindow, msg, wParam, lParam);


It does work normally when I'm not using the class, but what gets me is that sometimes it does this, and sometimes it doesn't. Like, for example, right now when I run it, it works perfectly, but 5 minutes ago when I ran it, it was messing up. Another thing to note is that I can't get stuff like Setting different cursors to work, and I don't know why...

I'm sorry about any spelling or grammar mistakes or any undue brevity, as I'm most likely typing on my phone

"Hell, there's more evidence that we are just living in a frequency wave that flows in harmonic balance creating the universe and all its existence." ~ GDchat

Hmm, looks good so far.
Can you how me the Function "MouseMove" please?
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
You need some braces on your case statements like:

case IDOK: // OK button hit!
{
//Update our last record
UpdateObjectRecord(hwndDlg, MyGame.Info.DialogObjectNumber);
EndDialog(hwndDlg, IDOK); // end this dialog box.
}return(true);


If not for function then at least for aesthetics.
What does your message pump look like? I bet you're not processing all messages each frame, and you're just processing one message per tick. Especially if it only does it after a while.

This topic is closed to new replies.

Advertisement