?? message.c
字號:
pMsg->hwnd = hNeedPaint; pWin = (PMAINWIN) hNeedPaint; pMsg->lParam = (LPARAM)(&pWin->InvRgn.rgn); return 1; } pMsgQueue->dwState &= ~QS_PAINT; } if (pMsgQueue->dwState & QS_DESKTIMER) { pMsg->hwnd = HWND_DESKTOP; pMsg->message = MSG_TIMER; pMsg->wParam = 0; pMsg->lParam = 0; pMsgQueue->dwState &= ~QS_DESKTIMER; return 1; } if (pMsgQueue->dwState & QS_TIMER) { for (slot = 0; slot < DEF_NR_TIMERS; slot++) { if (pMsgQueue->dwState & (0x01 << slot)) break; } if (slot == DEF_NR_TIMERS) { pMsgQueue->dwState &= ~QS_TIMER; } else { pMsg->hwnd = pMsgQueue->TimerOwner[slot]; pMsg->message = MSG_TIMER; pMsg->wParam = pMsgQueue->TimerID[slot]; pMsg->lParam = 0; pMsgQueue->dwState &= ~(0x01 << slot); return 1; } } // no message, wait again. pMsgQueue->OnIdle (pMsgQueue); goto checkagain; return 1;}BOOL GUIAPI EmptyMessageQueue (HWND hWnd){ int i; PMSGQUEUE pMsgQueue; PQMSG pQMsg, temp; if( !(pMsgQueue = GetMsgQueue(hWnd)) ) return FALSE; if (pMsgQueue->pFirstNotifyMsg) { pQMsg = pMsgQueue->pFirstNotifyMsg; while (pQMsg) { temp = pQMsg->next; FreeQMSG (pQMsg); pQMsg = temp; } } pMsgQueue->pFirstNotifyMsg = NULL; pMsgQueue->pLastNotifyMsg = NULL; pMsgQueue->readpos = 0; pMsgQueue->writepos = 0; for (i = 0; i < DEF_NR_TIMERS; i++) { pMsgQueue->TimerOwner [i] = HWND_DESKTOP; pMsgQueue->TimerID [i] = 0; } TerminateTimer (); pMsgQueue->dwState = QS_EMPTY; pMsgQueue->TimerMask = 0xFFFF; return TRUE;}int GUIAPI ThrowAwayMessages (HWND hWnd){ PMSG pMsg; PMSGQUEUE pMsgQueue; PQMSG pQMsg; int nCount = 0; int readpos; if( !(pMsgQueue = GetMsgQueue(hWnd)) ) return ERR_INV_HWND; if (pMsgQueue->pFirstNotifyMsg) { pQMsg = pMsgQueue->pFirstNotifyMsg; while (pQMsg) { pMsg = &pQMsg->Msg; if (pMsg->hwnd == hWnd || GetMainWindowPtrOfControl (pMsg->hwnd) == (PMAINWIN)hWnd) { pMsg->hwnd = HWND_INVALID; nCount ++; } pQMsg = pQMsg->next; } } readpos = pMsgQueue->readpos; while (readpos != pMsgQueue->writepos) { pMsg = pMsgQueue->msg + readpos; if (pMsg->hwnd == hWnd || GetMainWindowPtrOfControl (pMsg->hwnd) == (PMAINWIN)hWnd) { pMsg->hwnd = HWND_INVALID; nCount ++; } readpos++; if (readpos >= pMsgQueue->len) readpos = 0; } return nCount;}BOOL GUIAPI PeekPostMessage (PMSG pMsg, HWND hWnd, int iMsgFilterMin, int iMsgFilterMax, UINT uRemoveMsg){ PMSGQUEUE pMsgQueue; PMSG pPostMsg; if( !(pMsgQueue = GetMsgQueue(hWnd)) ) return FALSE; memset (pMsg, 0, sizeof(MSG)); if (pMsgQueue->dwState & QS_POSTMSG) { if (pMsgQueue->readpos != pMsgQueue->writepos) { pPostMsg = pMsgQueue->msg + pMsgQueue->readpos; if (iMsgFilterMin == 0 && iMsgFilterMax == 0) *pMsg = *pPostMsg; else if (pPostMsg->message <= iMsgFilterMax && pPostMsg->message >= iMsgFilterMin) *pMsg = *pPostMsg; else { return FALSE; } if (uRemoveMsg == PM_REMOVE) { pMsgQueue->readpos++; if (pMsgQueue->readpos >= pMsgQueue->len) pMsgQueue->readpos = 0; } return TRUE; } } return FALSE;} int GUIAPI PostMessage (HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam){ PMSGQUEUE pMsgQueue; PMSG pMsg; if( !(pMsgQueue = GetMsgQueue(hWnd)) ) return ERR_INV_HWND; if (iMsg == MSG_PAINT) { pMsgQueue->dwState |= QS_PAINT; goto goodret; } if ((pMsgQueue->writepos + 1) % pMsgQueue->len == pMsgQueue->readpos) { return ERR_QUEUE_FULL; } // Write the data and advance write pointer */ pMsg = &(pMsgQueue->msg[pMsgQueue->writepos]); pMsg->hwnd = hWnd; pMsg->message = iMsg; pMsg->wParam = wParam; pMsg->lParam = lParam; pMsgQueue->writepos++; if (pMsgQueue->writepos >= pMsgQueue->len) pMsgQueue->writepos = 0; pMsgQueue->dwState |= QS_POSTMSG;goodret: return ERR_OK;}int GUIAPI PostQuitMessage (HWND hWnd){ PMSGQUEUE pMsgQueue; if( !(pMsgQueue = GetMsgQueue(hWnd)) ) return ERR_INV_HWND; pMsgQueue->dwState |= QS_QUIT; return ERR_OK;}int GUIAPI SendMessage (HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam){ WNDPROC WndProc; if (hWnd == HWND_INVALID) return -1; WndProc = GetWndProc (hWnd); return (*WndProc)(hWnd, iMsg, wParam, lParam);}int GUIAPI SendNotifyMessage (HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam){ PMSGQUEUE pMsgQueue; PQMSG pqmsg; if (hWnd == HWND_INVALID) return -1; if( !(pMsgQueue = GetMsgQueue(hWnd)) ) return ERR_INV_HWND; pqmsg = QMSGAlloc(); // queue the notification message. pqmsg->Msg.hwnd = hWnd; pqmsg->Msg.message = iMsg; pqmsg->Msg.wParam = wParam; pqmsg->Msg.lParam = lParam; pqmsg->next = NULL; if (pMsgQueue->pFirstNotifyMsg == NULL) { pMsgQueue->pFirstNotifyMsg = pMsgQueue->pLastNotifyMsg = pqmsg; } else { pMsgQueue->pLastNotifyMsg->next = pqmsg; pMsgQueue->pLastNotifyMsg = pqmsg; } pMsgQueue->dwState |= QS_NOTIFYMSG; return ERR_OK;}#ifdef _TRACE_MSGint GUIAPI DispatchMessage (PMSG pMsg){ WNDPROC WndProc; int iRet; fprintf (stderr, "Message, %s: hWnd: %x, wP: %x, lP: %lx.\n", Message2Str (pMsg->message), pMsg->hwnd, pMsg->wParam, pMsg->lParam); if (pMsg->hwnd == HWND_INVALID) return HWND_INVALID; WndProc = GetWndProc (pMsg->hwnd); iRet = (*WndProc)(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam); fprintf (stderr, "Message, %s done, return value: %x\n", Message2Str (pMsg->message), iRet); return iRet;}#elseint GUIAPI DispatchMessage(PMSG pMsg){ WNDPROC WndProc; if (pMsg->hwnd == HWND_INVALID) return HWND_INVALID; WndProc = GetWndProc(pMsg->hwnd); return (*WndProc)(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);}#endif /* !TRACE_MSG */#elseint GUIAPI GetMessage (PMSG pMsg, HWND hWnd){ PMSGQUEUE pMsgQueue; PQMSG phead; int slot; if( !(pMsgQueue = GetMsgQueue(hWnd)) ) return ERR_INV_HWND; memset (pMsg, 0, sizeof(MSG));checkagain: if (pMsgQueue->dwState & QS_QUIT) { pMsg->hwnd = hWnd; pMsg->message = MSG_QUIT; pMsg->wParam = 0; pMsg->lParam = 0; pMsg->pAdd = NULL; pMsgQueue->dwState &= ~QS_QUIT; return 0; } if (pMsgQueue->dwState & QS_NOTIFYMSG) { pthread_mutex_lock (&pMsgQueue->lock); if (pMsgQueue->pFirstNotifyMsg) { phead = pMsgQueue->pFirstNotifyMsg; pMsgQueue->pFirstNotifyMsg = phead->next; *pMsg = phead->Msg; pMsg->pAdd = NULL; FreeQMSG (phead); pthread_mutex_unlock (&pMsgQueue->lock); return 1; } else pMsgQueue->dwState &= ~QS_NOTIFYMSG; pthread_mutex_unlock (&pMsgQueue->lock); } if (pMsgQueue->dwState & QS_SYNCMSG) { pthread_mutex_lock (&pMsgQueue->lock); if (pMsgQueue->pFirstSyncMsg) { *pMsg = pMsgQueue->pFirstSyncMsg->Msg; pMsg->pAdd = pMsgQueue->pFirstSyncMsg; pMsgQueue->pFirstSyncMsg = pMsgQueue->pFirstSyncMsg->pNext; pthread_mutex_unlock (&pMsgQueue->lock); return 1; } else pMsgQueue->dwState &= ~QS_SYNCMSG; pthread_mutex_unlock (&pMsgQueue->lock); } if (pMsgQueue->dwState & QS_POSTMSG) { pthread_mutex_lock (&pMsgQueue->lock); if (pMsgQueue->readpos != pMsgQueue->writepos) { *pMsg = pMsgQueue->msg[pMsgQueue->readpos]; CheckCapturedMouseMessage (pMsg); pMsg->pAdd = NULL; pMsgQueue->readpos++; if (pMsgQueue->readpos >= pMsgQueue->len) pMsgQueue->readpos = 0; pthread_mutex_unlock (&pMsgQueue->lock); return 1; } else pMsgQueue->dwState &= ~QS_POSTMSG; pthread_mutex_unlock (&pMsgQueue->lock); } if (pMsgQueue->dwState & QS_PAINT) { PMAINWIN pHostingRoot; HWND hNeedPaint; PMAINWIN pWin; if (hWnd == HWND_DESKTOP) { pMsg->hwnd = hWnd; pMsg->message = MSG_PAINT; pMsg->wParam = 0; pMsg->lParam = 0; pMsg->pAdd = NULL; pthread_mutex_lock (&pMsgQueue->lock); pMsgQueue->dwState &= ~QS_PAINT; pthread_mutex_unlock (&pMsgQueue->lock); return 1; } pMsg->message = MSG_PAINT; pMsg->wParam = 0; pMsg->lParam = 0; pMsg->pAdd = NULL; pWin = GetMainWindowPtrOfControl (hWnd); pHostingRoot = msgGetHostingRoot (pWin); if ( (hNeedPaint = msgCheckHostedTree (pHostingRoot)) ) { pMsg->hwnd = hNeedPaint; pWin = (PMAINWIN) hNeedPaint; pMsg->lParam = (LPARAM)(&pWin->InvRgn.rgn); return 1; } pthread_mutex_lock (&pMsgQueue->lock); pMsgQueue->dwState &= ~QS_PAINT; pthread_mutex_unlock (&pMsgQueue->lock); } if (pMsgQueue->dwState & QS_TIMER) { if (hWnd == HWND_DESKTOP) { pMsg->hwnd = hWnd; pMsg->message = MSG_TIMER; pMsg->wParam = 0; pMsg->lParam = 0; pMsg->pAdd = NULL; pthread_mutex_lock (&pMsgQueue->lock); pMsgQueue->dwState &= ~0x01; pthread_mutex_unlock (&pMsgQueue->lock); return 1; } pthread_mutex_lock (&pMsgQueue->lock); for (slot = 0; slot < DEF_NR_TIMERS; slot++) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -