那么我们就可以编写一个包含多个UI线程的应用程序——每个创建windows的线程都需要自己的消息循环——但这是一种相当先进的技术,对于大多数基本的应用程序来说并不是那么有用。 资料:How does the message loop use threads?
PS.由于本人英文水平所限,只能翻译到这个程度了,有纰漏还望多多指出,附上本篇翻译的英文原版教程地址:http://www.winprog.org/tutorial/message_loop.html
possible message loop needs you might have when sending and receiving messages across your interoperation boundaries. To help formalize an application message loop architecture, Windows Presentation Foundation (WPF) provides theComponentDispatcherclass that defines a simple protocol for a message loop to ...
Because the system directs messages to individual windows in an application, a thread must create at least one window before starting its message loop. Most applications contain a single thread that creates windows. A typical application registers the window class for its main window, creates and ...
break; // WM_QUIT, exit message loop } if(!PreTranslateMessage(&m_msg)) { ::TranslateMessage(&m_msg); ::DispatchMessage(&m_msg); } if(IsIdleMessage(&m_msg)) { bDoIdle = TRUE; nIdleCount = 0; } } 剩下的就是win32的窗口机制,用户在使用时看到的是一个个的窗口,窗口是win32程序输入...
For example, the WM_LBUTTONDOWN message includes the x-coordinate and y-coordinate of the mouse cursor. To pass a message to a window, the operating system calls the window procedure registered for that window. (And now you know what the window procedure is for.) The Message Loop An ...
The system does not automatically create a message queue for each thread. Instead, the system creates a message queue only for threads that perform operations which require a message queue. If the thread creates one or more windows, a message loop must be provided; this message loop retrieves...
pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (hwnd, nCmdShow); /* Run the message loop...
, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (hwnd, SW_SHOW); UpdateWindow(hwnd); /* Run the message loop. ...
// WARNING: Don't actually write your loop this way.while(1) { GetMessage(&msg,NULL,0,0); TranslateMessage(&msg); DispatchMessage(&msg); } 当然,正如字面意思,此循环永远不会结束。 这就是GetMessage函数的返回值传入的位置。 通常,GetMessage会返回非零值。 如果要退出应用程序并中断消息循环,请调...