Jump to content
  • Advertisement
Sign in to follow this  
Waaayoff

How to use PeekMessage with wxWidgets?

This topic is 2123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can't find a solution anywhere... Currently i have the following:

if(!wxEntryStart(hInstance, hPrevInstance, lpCmdLine, nCmdShow ))
	{
		return -1;
	}

	wxTheApp->CallOnInit();

	MSG msg;

	while (true)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if(msg.message == WM_QUIT) break;
			
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	wxEntryCleanup();

But if i press the close button, nothing happens...

Share this post


Link to post
Share on other sites
Advertisement

Are you sure its compatible with the framework if you directly use the WinAPI and you dont need to use some wx function?

From the look of it the window procedure seems to not call DestroyWindow on WM_CLOSE or not call PostQuitMessage on WM_DESTROY.

Share this post


Link to post
Share on other sites

Are you sure its compatible with the framework if you directly use the WinAPI and you dont need to use some wx function?

From the look of it the window procedure seems to not call DestroyWindow on WM_CLOSE or not call PostQuitMessage on WM_DESTROY.

 

Yes that's why i'm asking. There may be a function but i can't find it...

Share this post


Link to post
Share on other sites

Isn't this break breaking out of the if statement? If so, it'll end up inside the while (true), so the loop will never end.

 

Long time since I last used this keyword, several years to be precise.

 

@edit: forget about it, break should actually jump right out of the while loop. Just tested it.

 

Searching on the internet, found this, and it looks like that if you pass the message on, windows should do it. But in your code you're breaking out of the loop before dispatching the message. Maybe moving the IF to after the translate and dispatch functions can do it. Still, I don't have wxWidget installed so I can't test it myself, sorry.

Edited by dejaime

Share this post


Link to post
Share on other sites

When working with GUI frameworks like wxWidgets, you aren't supposed to be tapping into the OS event pump. I assume you are doing this because you want to get some sort of render loop going. This wxWidgets wiki page should help in that case.

Edited by Aldacron

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!