本文整理汇总了C++中DispatchMessageA函数的典型用法代码示例。如果您正苦于以下问题:C++ DispatchMessageA函数的具体用法?C++ DispatchMessageA怎么用?C++ DispatchMessageA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DispatchMessageA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test_GetKeyState
void Test_GetKeyState()
{
HWND hwnd;
MSG msg;
hwnd = CreateTestWindow();
hKbdHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, GetModuleHandleA( NULL ), 0);
hKbdLLHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandleA( NULL ), 0);
ok(hKbdHook!=NULL," \n");
ok(hKbdLLHook!=NULL," \n");
keybd_event(VK_LMENU, 0, 0,0);
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
keybd_event(VK_LMENU, 0, KEYEVENTF_KEYUP,0);
//fixme this hangs the test
//while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessageA( &msg );
DestroyWindow(hwnd);
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
UnhookWindowsHookEx (hKbdHook);
UnhookWindowsHookEx (hKbdLLHook);
}
示例2: Win32_GetEvent
static int Win32_GetEvent(SST_DisplayTarget target, SST_WMEvent* eventReturn)
{
MSG msg;
SST_DisplayTarget_Win32* displayTarget = (SST_DisplayTarget_Win32*)target;
SST_Window_Win32* win;
int found = 0;
/* First, get Win32 messages and dispatch to winproc. We
do this immediately, otherwise the OS thinks we've hung. */
while(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
/* Check for user events */
if(RemoveFromEQ(&displayTarget->userEventQueue, eventReturn))
return 1;
/* Now check each window's event queue */
win = displayTarget->firstWindow;
while(win)
{
if(RemoveFromEQ(&win->eventQueue, eventReturn))
{
found = 1;
break;
}
win = win->next;
}
return found;
}
示例3: CreateWndThreadA
unsigned WINAPI
CreateWndThreadA(
LPVOID pThreadParam)
{
HWND hWnd = CreateWindowA( "Azureus Window Hook", NULL, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
if( hWnd == NULL){
printf( "Failed to create window\n" );
return( 0 );
}else{
MSG Msg;
while(GetMessageA(&Msg, hWnd, 0, 0)) {
TranslateMessage(&Msg);
DispatchMessageA(&Msg);
}
return Msg.wParam;
}
}
示例4: CreateTestWindow
static HWND CreateTestWindow()
{
MSG msg;
WNDCLASSA wclass;
HANDLE hInstance = GetModuleHandleA( NULL );
HWND hWndTest;
wclass.lpszClassName = "MouseInputTestClass";
wclass.style = CS_HREDRAW | CS_VREDRAW;
wclass.lpfnWndProc = WndProc;
wclass.hInstance = hInstance;
wclass.hIcon = LoadIconA( 0, IDI_APPLICATION );
wclass.hCursor = LoadCursorA( NULL, IDC_ARROW );
wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
wclass.lpszMenuName = 0;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
RegisterClassA( &wclass );
/* create the test window that will receive the keystrokes */
hWndTest = CreateWindowA( wclass.lpszClassName, "MouseInputTestTest",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
NULL, NULL, hInstance, NULL);
assert( hWndTest );
ShowWindow( hWndTest, SW_SHOWMAXIMIZED);
SetWindowPos( hWndTest, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
SetForegroundWindow( hWndTest );
UpdateWindow( hWndTest);
SetFocus(hWndTest);
/* flush pending messages */
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
return hWndTest;
}
示例5: test_messages
static void test_messages(void)
{
WNDCLASSA cls;
HWND win;
MSG msg;
HANDLE thread;
DWORD tid;
InitializeCriticalSection(&clipboard_cs);
memset(&cls, 0, sizeof(cls));
cls.lpfnWndProc = clipboard_wnd_proc;
cls.hInstance = GetModuleHandleA(NULL);
cls.lpszClassName = "clipboard_test";
RegisterClassA(&cls);
win = CreateWindowA("clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0);
ok(win != NULL, "CreateWindow failed: %d\n", GetLastError());
thread = CreateThread(NULL, 0, clipboard_thread, (void*)win, 0, &tid);
ok(thread != NULL, "CreateThread failed: %d\n", GetLastError());
while(GetMessageA(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
ok(WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
CloseHandle(thread);
UnregisterClassA("clipboard_test", GetModuleHandleA(NULL));
DeleteCriticalSection(&clipboard_cs);
}
示例6: GetMessageA
int OGLTest::Run()
{
bool fFirst = true;
MSG msg;
do
{
BOOL fGotMessage;
if (miRenderStep)
{
fGotMessage = GetMessageA(&msg, 0, 0, 0);
}
else
{
fGotMessage = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
}
if (fGotMessage)
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
float dt = 0.0f; /* Time in seconds since last render step. @todo Measure. */
BOOL fDoRender = FALSE;
if (miRenderStep)
{
if (msg.message == WM_CHAR)
{
if (msg.wParam == ' ')
{
fDoRender = TRUE;
dt = fFirst ? 0.0f : 0.1f; /* 0.1 second increment per step. */
}
}
}
else
{
fDoRender = TRUE;
}
if (fDoRender)
{
if (mpRender)
{
setCurrentGLCtx(mhGLRC);
mpRender->TimeAdvance(dt);
mpRender->DoRender();
setCurrentGLCtx(NULL);
fFirst = false;
}
}
} while (msg.message != WM_QUIT);
return msg.wParam;
}
示例7: message_loop
void message_loop()
{
MSG msg;
while (GetMessage(&msg, 0, 0, 0))
{
DispatchMessageA(&msg);
TranslateMessage(&msg);
}
}
示例8: mmTaskBlock
/******************************************************************
* mmTaskBlock ([email protected])
*/
VOID WINAPI mmTaskBlock(DWORD tid)
{
MSG msg;
do
{
GetMessageA(&msg, 0, 0, 0);
if (msg.hwnd) DispatchMessageA(&msg);
} while (msg.message != WM_USER);
}
示例9: do_events
/* process any pending messages */
static void do_events(void)
{
MSG msg;
while (PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
}
示例10: WinMain
int CALLBACK
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HINSTANCE Module = hInstance;
WNDCLASSEX WindowClass = {};
WindowClass.cbSize = sizeof(WindowClass);
WindowClass.style = CS_HREDRAW | CS_VREDRAW;
WindowClass.lpfnWndProc = MainWindowProc;
WindowClass.hInstance = Module;
WindowClass.hIcon = LoadIcon(0, IDI_APPLICATION);
WindowClass.hCursor = LoadCursorA(0, IDC_ARROW);
WindowClass.lpszClassName = WINDOW_CLASS_NAME;
RegisterClassExA(&WindowClass);
DWORD WindowExStyle = WS_EX_APPWINDOW;
DWORD WindowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
HWND MainWindow = CreateWindowEx(
WindowExStyle,
WINDOW_CLASS_NAME,
"FSWindow",
WindowStyle,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0,
Module,
0);
RECT AdjustRect = {};
AdjustRect.right = MAIN_WINDOW_WIDTH;
AdjustRect.bottom = MAIN_WINDOW_HEIGHT;
AdjustWindowRectEx(&AdjustRect, WindowStyle, FALSE, WindowExStyle);
SetWindowPos(MainWindow, 0,
0, 0,
AdjustRect.right - AdjustRect.left, AdjustRect.bottom - AdjustRect.top,
SWP_NOMOVE | SWP_NOCOPYBITS | SWP_SHOWWINDOW);
BOOL Running = TRUE;
while(Running) {
MSG Message;
while(PeekMessageA(&Message, 0, 0, 0, PM_REMOVE)) {
if(Message.message == WM_QUIT) {
Running = FALSE;
break;
}
else {
TranslateMessage(&Message);
DispatchMessageA(&Message);
}
}
Sleep(10);
}
return 0;
}
示例11: Thread2
static
DWORD
WINAPI
Thread2(
_Inout_opt_ PVOID Parameter)
{
MSG msg;
LRESULT ret;
WPARAM wParam;
hWndThread2 = CreateWindowExW(0, L"SendTest", NULL, 0, 10, 10, 20, 20, NULL, NULL, 0, NULL);
ok(hWndThread2 != NULL, "CreateWindow failed\n");
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
RECORD_MESSAGE(2, msg.message, POST, 0, 0);
DispatchMessageA(&msg);
}
wParam = (WPARAM)Parameter;
ret = SendMessage(hWndThread1, WM_SENDTOOTHERTHREAD, wParam, dwThread2);
ok(ret == 0, "ret = %lu\n", ret);
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
RECORD_MESSAGE(2, msg.message, POST, 0, 0);
DispatchMessageA(&msg);
}
DestroyWindow(hWndThread2);
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
RECORD_MESSAGE(2, msg.message, POST, 0, 0);
DispatchMessageA(&msg);
}
return 7;
}
示例12: cleanup
static void cleanup(void)
{
MSG msg;
PostMessageA(hProgressParentWnd, WM_CLOSE, 0, 0);
while (GetMessageA(&msg,0,0,0)) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
UnregisterClassA(progressTestClass, GetModuleHandleA(NULL));
}
示例13: FlushMessages
static void FlushMessages()
{
MSG msg;
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
{
int iwnd = get_iwnd(msg.hwnd);
if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
RECOND_MESSAGE(iwnd, msg.message, POST,0,0);
DispatchMessageA( &msg );
}
}
示例14: Thread1
static
DWORD
WINAPI
Thread1(
_Inout_opt_ PVOID Parameter)
{
MSG msg;
hWndThread1 = CreateWindowExW(0, L"SendTest", NULL, 0, 10, 10, 20, 20, NULL, NULL, 0, NULL);
ok(hWndThread1 != NULL, "CreateWindow failed\n");
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
RECORD_MESSAGE(1, msg.message, POST, 0, 0);
DispatchMessageA(&msg);
}
ResumeThread(hThread2);
while (MsgWaitForMultipleObjectsEx(1, &hThread2, FALSE, QS_ALLEVENTS, MWMO_ALERTABLE) != WAIT_OBJECT_0)
{
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
RECORD_MESSAGE(1, msg.message, POST, 0, 0);
DispatchMessageA(&msg);
}
}
DestroyWindow(hWndThread1);
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
RECORD_MESSAGE(1, msg.message, POST, 0, 0);
DispatchMessageA(&msg);
}
return 6;
}
示例15: flush_events
/* try to make sure pending X events have been processed before continuing */
static void flush_events(int waitTime)
{
MSG msg;
int diff = waitTime;
DWORD time = GetTickCount() + waitTime;
while (diff > 0)
{
if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min(100,diff), QS_ALLEVENTS) == WAIT_TIMEOUT) break;
while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
diff = time - GetTickCount();
}
}