MicrosoftInternetExplorer402DocumentNotSpecified7.8Normal0
bool QApplication::winEventFilter ( MSG * ) [虚]
消息程序在每次接受到消息时调用这个函数。如果你想处理Qt不处理的窗口消息msg,请重新实现这个函数。
- bool MainWindow::winEvent(MSG* pMsg)
-
{
-
if ( pMsg->message == WM_COPYDATA )
-
{
-
COPYDATASTRUCT* pCopyDataStruct;
-
POSTERS_REC_STRUCT* pRec;
-
unsigned char* odapMsgPtr[MAX_POSTERS_SIZE];
-
QString str;
-
pCopyDataStruct = (COPYDATASTRUCT*) pMsg->lParam;
-
-
switch (pCopyDataStruct->dwData)
-
{
-
case VALID_REC1 :
-
case VALID_REC2 :
-
{
-
(void)memcpy(odapMsgPtr, pCopyDataStruct->lpData, pCopyDataStruct->cbData);
-
-
if (odapMsgPtr != NULL)
-
{
-
pRec = (POSTERS_REC_STRUCT *)odapMsgPtr;
-
class_data1 = pRec->var1;
-
class_data2 = pRec->var2;
-
}
-
}
-
}
-
-
return true;
-
}
-
else
-
return false;
-
}
-
-
Some Code on the web gives another example
-
-
#ifdef HAVE_WIN32_API
-
virtual bool winEventFilter(MSG * msg) {
-
SPW_InputEvent sbEvent;
-
if (SPW_TranslateEventWin32(msg, &sbEvent)) {
-
QWidget * focus = this->focusWidget();
-
if (!focus) focus = this->activeWindow();
-
if (focus) {
-
QCustomEvent qevent((QEvent::Type)SoQtInternal::SPACEBALL_EVENT,
-
(void *)&sbEvent);
-
QApplication::sendEvent(focus, &qevent);
-
}
-
}
-
#if (QT_VERSION >= 0x040000)
-
long result = 0;
-
return QApplication::winEventFilter(msg, &result);
-
#else
-
return QApplication::winEventFilter(msg);
-
#endif
The class provides an icon for an application in the system tray.
Modern operating systems usually provide a special area on the desktop, called the system tray or notification area, where long-running applications can display icons and short messages.
- /* translates a Win32 event to a SPW_InputEvent. */
-
int SPW_TranslateEventWin32(MSG * msg, SPW_InputEvent * sbEvent)
-
{
-
SiSpwEvent spwEvent;
-
SiGetEventData eventdata;
-
-
if (Spw_DeviceHandle != SI_NO_HANDLE) {
-
-
SiGetEventWinInit (&eventdata, msg->message, msg->wParam, msg->lParam);
-
if (SiGetEvent (Spw_DeviceHandle, 0, &eventdata, &spwEvent) == SI_IS_EVENT) {
-
-
int i;
-
switch(spwEvent.type) {
-
case SI_MOTION_EVENT:
-
sbEvent->type = SPW_InputMotionEvent;
-
for(i=0; i<6; i++) {
-
sbEvent->sData[i] = (short)spwEvent.u.spwData.mData[i];
-
}
-
break;
-
case SI_BUTTON_EVENT:
-
sbEvent->type = SPW_InputButtonPressEvent;
-
sbEvent->buttonState.pressed = (SiButtonPressed(&spwEvent) != SI_NO_BUTTON);
-
sbEvent->buttonState.released = (SiButtonReleased(&spwEvent) != SI_NO_BUTTON);
-
break;
-
}
-
return TRUE;
-
}
-
}
-
return FALSE;
-
}
阅读(1950) | 评论(0) | 转发(1) |