message-loop

Cocoa message loop? (vs. windows message loop)

允我心安 提交于 2019-12-03 06:29:51
While trying to port my game engine to mac, I stumble upon one basic (but big) problem. On windows, my main code looks like this (very simplified): PeekMessage(...) // check for windows messages switch (msg.message) { case WM_QUIT: ...; case WM_LBUTTONDOWN: ...; ... } TranslateMessage(&msg); DispatchMessage (&msg); for (std::vector<CMyBackgroundThread*>::iterator it = mythreads.begin(); it != mythreads.end(); ++it) { (*it)->processEvents(); } ... do other useful stuff like look if the window has resized and other stuff... drawFrame(); // draw a frame using opengl SwapBuffers(hDC); // swap

How to exit a thread's message loop?

故事扮演 提交于 2019-12-02 20:54:06
A background-thread can be configured to receive window messages. You would post messages to the thread using PostThreadMessage . What's the correct way to exit that message loop? Background Before you can post messages to a background thread, the thread needs to ensure that a message queue is created by calling PeekMessage : procedure ThreadProcedure; var msg: TMsg; begin //Call PeekMessage to force the system to create the message queue. PeekMessage(msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); end; Now the outside world is able to post messages to our thread: PostThreadMessage(nThreadID, WM

Is it possible to use Windows Raw Input API without a window (ie from a console application)?

淺唱寂寞╮ 提交于 2019-12-01 22:23:33
问题 Is it possible to use Windows Raw Input API without a window (ie from a console application)? I've tried using RegisterRawInputDevices but my message loops doesn't seem to get any events from GetMessage and hence just 'hangs' there. 回答1: Do you mean RegisterRawInputDevices? Since the RAWINPUTDEVICE structure requires you to specify an HWND to receive the WM_INPUT messages, no it's not possible to do this without a window. Console applications can create windows, and the window probably can

WebBrowser control in a class library

喜欢而已 提交于 2019-11-28 01:58:31
问题 So as the title suggests, I'm trying to use WebBrowser control in a class library. I've gone through several SO questions like this excellent post, but the unique thing in my situation is that the WebBrowser object must remain alive for the life of application and keep its state/cookies across different calls that the library clients will make from time to time. I have confirmed that WebBrowser control does not do navigation unless the thread it was created on contains a message pump. But as