Changeset 8689 for trunk/src


Ignore:
Timestamp:
Jun 15, 2002, 7:17:17 PM (23 years ago)
Author:
sandervl
Message:

Do proper filtering for PeekMessage

Location:
trunk/src/user32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/oslibmsg.cpp

    r8130 r8689  
    1 /* $Id: oslibmsg.cpp,v 1.55 2002-03-28 11:35:38 sandervl Exp $ */
     1/* $Id: oslibmsg.cpp,v 1.56 2002-06-15 17:17:17 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    131131//If both the minimum & maximum message are unknown, the result can be wrong (max > min)!
    132132//******************************************************************************
    133 ULONG TranslateWinMsg(ULONG msg, BOOL fMinFilter)
     133ULONG TranslateWinMsg(ULONG msg, BOOL fMinFilter, BOOL fExactMatch = FALSE)
    134134{
    135135    if(msg == 0)
     
    141141    for(int i=0;i<MAX_MSGTRANSTAB;i++)
    142142    {
    143         if(fMinFilter && MsgTransTab[i].msgWin32 >= msg) {
    144             return MsgTransTab[i].msgOS2;
    145         }
    146         else
    147         if(!fMinFilter && MsgTransTab[i].msgWin32 >= msg) {
     143        if(fExactMatch) {
    148144            if(MsgTransTab[i].msgWin32 == msg)
    149                     return MsgTransTab[i].msgOS2;
    150             else    return MsgTransTab[i-1].msgOS2;
     145                return MsgTransTab[i].msgWin32;
     146        }
     147        else {
     148            if(fMinFilter && MsgTransTab[i].msgWin32 >= msg) {
     149                return MsgTransTab[i].msgOS2;
     150            }
     151            else
     152            if(!fMinFilter && MsgTransTab[i].msgWin32 >= msg) {
     153                if(MsgTransTab[i].msgWin32 == msg)
     154                        return MsgTransTab[i].msgOS2;
     155                else    return MsgTransTab[i-1].msgOS2;
     156            }
    151157        }
    152158    }
    153159
    154160    //not found, get everything
    155     dprintf(("WARNING: TranslateWinMsg: message %x not found", msg));
     161    dprintf2(("WARNING: TranslateWinMsg: message %x not found", msg));
    156162    return 0;
    157163}
     
    210216//******************************************************************************
    211217//******************************************************************************
    212 
    213 #ifdef ALTGR_HACK
    214 static void i_MostUglyAltGrHack(LPMSG pMsg)
    215 {
    216   switch (pMsg->message)
    217   {
    218     case WINWM_KEYUP:
    219     case WINWM_SYSKEYUP:
    220       USHORT wWinScan = (pMsg->lParam & 0x00ff0000) >> 16;
    221       if (wWinScan == WINSCAN_ALTRIGHT)
    222       {
    223         KeySetOverlayKeyState(VK_RMENU_W, KEYOVERLAYSTATE_DONTCARE);
    224         KeySetOverlayKeyState(VK_MENU_W, KEYOVERLAYSTATE_DONTCARE);
    225       }
    226       break;
    227   }
    228 }
    229 #else
    230 #define i_MostUglyAltGrHack(a)
    231 #endif
    232 
    233218BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
    234219                    BOOL isUnicode)
    235220{
    236  BOOL rc, eaten;
    237  TEB  *teb;
    238  QMSG  os2msg;
    239  HWND  hwndOS2 = 0;
    240  ULONG filtermin, filtermax;
    241 
    242   if(hwnd) {
    243         hwndOS2 = Win32ToOS2Handle(hwnd);
    244         if(hwndOS2 == NULL) {
    245                 memset(pMsg, 0, sizeof(MSG));
    246                 dprintf(("GetMsg: window %x NOT FOUND!", hwnd));
    247                 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    248                 return TRUE;
    249         }
    250   }
    251 
    252   teb = GetThreadTEB();
    253   if(teb == NULL) {
     221    BOOL rc, eaten;
     222    TEB  *teb;
     223    QMSG  os2msg;
     224    HWND  hwndOS2 = 0;
     225    ULONG filtermin, filtermax;
     226
     227    if(hwnd) {
     228        hwndOS2 = Win32ToOS2Handle(hwnd);
     229        if(hwndOS2 == NULL) {
     230                    memset(pMsg, 0, sizeof(MSG));
     231                    dprintf(("GetMsg: window %x NOT FOUND!", hwnd));
     232                    SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     233                    return TRUE;
     234            }
     235    }
     236
     237    teb = GetThreadTEB();
     238    if(teb == NULL) {
    254239        DebugInt3();
    255         return TRUE;
    256   }
    257 
    258   if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd))
    259   {
     240        return TRUE;
     241    }
     242   
     243    if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd))
     244    {
    260245        dprintf(("Return queued WM_CHAR message hwnd=%x msg=%d wParam=%x lParam=%x", teb->o.odin.msgWCHAR.hwnd, teb->o.odin.msgWCHAR.message, teb->o.odin.msgWCHAR.wParam, teb->o.odin.msgWCHAR.lParam));
    261246        if(uMsgFilterMin) {
     
    285270            // and WM_KEYUP according to docs.
    286271            if(ProcessKbdHook(pMsg, TRUE))
    287               goto continuegetmsg;
     272                goto continuegetmsg;
    288273            break;
    289274        }
    290275
    291         i_MostUglyAltGrHack(pMsg);
    292 
    293276        return (pMsg->message != WINWM_QUIT);
    294   }
     277    }
    295278
    296279continuegetmsg:
    297   if(hwnd) {
     280    if(hwnd) {
    298281        filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
    299         filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
    300         if(filtermin > filtermax) {
    301                 ULONG tmp = filtermin;
    302                 filtermin = filtermax;
    303                 filtermax = filtermin;
    304         }
     282            filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
     283            if(filtermin > filtermax) {
     284                ULONG tmp = filtermin;
     285                    filtermin = filtermax;
     286                    filtermax = filtermin;
     287            }
    305288        do {
    306289                WinWaitMsg(teb->o.odin.hab, filtermin, filtermax);
     
    310293
    311294        return (pMsg->message != WINWM_QUIT);
    312   }
    313   else
    314   {
     295    }
     296    else
     297    {
    315298        filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
    316         filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
    317         if(filtermin > filtermax) {
    318                 ULONG tmp = filtermin;
    319                 filtermin = filtermax;
    320                 filtermax = filtermin;
    321         }
     299            filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
     300            if(filtermin > filtermax) {
     301                ULONG tmp = filtermin;
     302                    filtermin = filtermax;
     303                    filtermax = filtermin;
     304            }
    322305        do {
    323306                eaten = FALSE;
     
    334317                    rc = 1;
    335318                }
    336         } while (eaten);
    337   }
    338   if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, MSG_REMOVE) == FALSE) {
    339       //dispatch untranslated message immediately
    340       WinDispatchMsg(teb->o.odin.hab, &os2msg);
    341       //and get the next one
    342       return OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, isUnicode);
    343   }
    344 
    345   memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
    346   memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
     319            }
     320        while (eaten);
     321    }
     322    if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, MSG_REMOVE) == FALSE) {
     323        //dispatch untranslated message immediately
     324        WinDispatchMsg(teb->o.odin.hab, &os2msg);
     325        //and get the next one
     326        return OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, isUnicode);
     327    }
     328
     329    memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
     330    memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
    347331 
    348   // send keyboard messages to the registered hooks
    349   switch (pMsg->message)
    350   {
     332    // send keyboard messages to the registered hooks
     333    switch (pMsg->message)
     334    {
    351335    case WINWM_KEYDOWN:
    352336    case WINWM_KEYUP:
    353337    case WINWM_SYSKEYDOWN:
    354338    case WINWM_SYSKEYUP:
    355       // only supposed to be called upon WM_KEYDOWN
    356       // and WM_KEYUP according to docs.
    357       if(ProcessKbdHook(pMsg, TRUE))
    358         goto continuegetmsg;
    359       break;
    360   }
    361  
    362   i_MostUglyAltGrHack(pMsg);
    363  
    364   return rc;
     339        // only supposed to be called upon WM_KEYDOWN
     340        // and WM_KEYUP according to docs.
     341        if(ProcessKbdHook(pMsg, TRUE))
     342            goto continuegetmsg;
     343        break;
     344    }
     345    return rc;
    365346}
    366347
     
    381362                     DWORD fRemove, BOOL isUnicode)
    382363{
    383  BOOL  rc, eaten;
    384  TEB  *teb;
    385  QMSG  os2msg;
    386  HWND  hwndOS2 = 0;
    387 
    388   if(hwnd && hwnd != -1) {
    389         hwndOS2 = Win32ToOS2Handle(hwnd);
    390         if(hwndOS2 == NULL) {
    391                 dprintf(("PeekMsg: window %x NOT FOUND!", hwnd));
    392                 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    393                 return FALSE;
    394         }
    395   }
    396 
    397   teb = GetThreadTEB();
    398   if(teb == NULL) {
     364    BOOL  rc, eaten;
     365    TEB  *teb;
     366    QMSG  os2msg;
     367    HWND  hwndOS2 = 0;
     368
     369    if(uMsgFilterMin > uMsgFilterMax) {
     370        //TODO: is this correct behaviour?
     371        dprintf(("!ERROR!: invalid message filter range!!!"));
     372        SetLastError(ERROR_INVALID_PARAMETER_W);
     373        return FALSE;
     374    }
     375    if(hwnd && hwnd != -1) {
     376            hwndOS2 = Win32ToOS2Handle(hwnd);
     377            if(hwndOS2 == NULL) {
     378                dprintf(("PeekMsg: window %x NOT FOUND!", hwnd));
     379                    SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     380                    return FALSE;
     381            }
     382    }
     383
     384    teb = GetThreadTEB();
     385    if(teb == NULL) {
    399386        DebugInt3();
    400387        return FALSE;
    401   }
    402 
    403   if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd))
    404   {
     388    }
     389
     390    if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd))
     391    {
    405392        dprintf(("Return queued WM_CHAR message hwnd=%x msg=%d wParam=%x lParam=%x", teb->o.odin.msgWCHAR.hwnd, teb->o.odin.msgWCHAR.message, teb->o.odin.msgWCHAR.wParam, teb->o.odin.msgWCHAR.lParam));
    406393        if(uMsgFilterMin) {
     
    433420            // and WM_KEYUP according to docs.
    434421            if(ProcessKbdHook(pMsg, fRemove))
    435               goto continuepeekmsg;
     422                goto continuepeekmsg;
    436423            break;
    437424        }
    438425   
    439426        return TRUE;
    440   }
     427    }
    441428
    442429continuepeekmsg:
    443   do {
    444         eaten = FALSE;
    445         rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
    446                         TranslateWinMsg(uMsgFilterMax, FALSE), (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
    447 
    448         if (rc && (fRemove & PM_REMOVE_W) && os2msg.msg == WM_TIMER) {
    449             eaten = TIMER_HandleTimer(&os2msg);
    450         }
    451   }
    452   while (eaten && rc);
    453 
    454   if(rc == FALSE) {
    455       return FALSE;
    456   }
     430    if(uMsgFilterMin && uMsgFilterMax)
     431    {   //we can't use the PM message filter (since the message nrs aren't similar), so we must
     432        //filter each message seperately
     433        //to do so, we will translate each win32 message in the filter range and call WinPeekMsg
     434        ULONG ulPMFilter;
     435
     436        for(int i=0;i<uMsgFilterMax-uMsgFilterMin;i++) {
     437            ulPMFilter = TranslateWinMsg(uMsgFilterMin+i, TRUE, TRUE);
     438            if(ulPMFilter) {
     439                do {
     440                    eaten = FALSE;
     441
     442                    rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, ulPMFilter, ulPMFilter,
     443                                    (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
     444
     445                    if (rc && (fRemove & PM_REMOVE_W) && os2msg.msg == WM_TIMER) {
     446                        eaten = TIMER_HandleTimer(&os2msg);
     447                    }
     448                }
     449                while (eaten && rc);
     450            }
     451            if(rc) {
     452                break;
     453            }
     454        }
     455    }
     456    else {
     457        do {
     458            eaten = FALSE;
     459
     460            rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, 0, 0, (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
     461
     462            if (rc && (fRemove & PM_REMOVE_W) && os2msg.msg == WM_TIMER) {
     463                eaten = TIMER_HandleTimer(&os2msg);
     464            }
     465        }
     466        while (eaten && rc);
     467    }
     468
     469    if(rc == FALSE) {
     470        return FALSE;
     471    }
    457472 
    458   // @@@PH
    459   // warning - OS2ToWinMsgTranslate might insert additional messages
    460   // into the queue
    461   if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE) == FALSE)
    462   {
    463      //unused PM message; dispatch immediately and grab next one
    464      dprintf2(("OSLibWinPeekMsg: Untranslated message; dispatched immediately"));
    465      if(!(fRemove & PM_REMOVE_W)) {
    466          rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
    467                          TranslateWinMsg(uMsgFilterMax, FALSE), PM_REMOVE);
    468      }
    469      WinDispatchMsg(teb->o.odin.hab, &os2msg);
    470      return OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax,
    471                             fRemove, isUnicode);
    472   }
    473   //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message
    474   if(fRemove & PM_REMOVE_W) {
    475         memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
    476         memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
    477   }
    478 
    479   // send keyboard messages to the registered hooks
    480   switch (pMsg->message)
    481   {
     473    // @@@PH
     474    // warning - OS2ToWinMsgTranslate might insert additional messages
     475    // into the queue
     476    if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE) == FALSE)
     477    {
     478         //unused PM message; dispatch immediately and grab next one
     479        dprintf2(("OSLibWinPeekMsg: Untranslated message; dispatched immediately"));
     480        if(!(fRemove & PM_REMOVE_W)) {
     481            rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
     482                            TranslateWinMsg(uMsgFilterMax, FALSE), PM_REMOVE);
     483        }
     484        WinDispatchMsg(teb->o.odin.hab, &os2msg);
     485        return OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, fRemove, isUnicode);
     486    }
     487    //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message
     488    if(fRemove & PM_REMOVE_W) {
     489        memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
     490        memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
     491    }
     492
     493    // send keyboard messages to the registered hooks
     494    switch (pMsg->message)
     495    {
    482496    case WINWM_KEYDOWN:
    483497    case WINWM_KEYUP:
    484498    case WINWM_SYSKEYDOWN:
    485499    case WINWM_SYSKEYUP:
    486       // only supposed to be called upon WM_KEYDOWN
    487       // and WM_KEYUP according to docs.
    488       if(ProcessKbdHook(pMsg, fRemove))
    489         goto continuepeekmsg;
    490       break;
    491   }
    492 
    493   return rc;
     500        // only supposed to be called upon WM_KEYDOWN
     501        // and WM_KEYUP according to docs.
     502        if(ProcessKbdHook(pMsg, fRemove))
     503            goto continuepeekmsg;
     504        break;
     505    }
     506
     507    return rc;
    494508}
    495509//******************************************************************************
     
    497511ULONG OSLibWinQueryMsgTime()
    498512{
    499   return WinQueryMsgTime(GetThreadHAB());
     513    return WinQueryMsgTime(GetThreadHAB());
    500514}
    501515//******************************************************************************
     
    503517BOOL OSLibWinWaitMessage()
    504518{
    505   return WinWaitMsg(GetThreadHAB(), 0, 0);
     519    return WinWaitMsg(GetThreadHAB(), 0, 0);
    506520}
    507521//******************************************************************************
     
    510524ULONG OSLibWinQueryQueueStatus()
    511525{
    512  ULONG statusOS2, statusWin32 = 0;
    513 
    514    statusOS2 = WinQueryQueueStatus(HWND_DESKTOP);
    515 
    516    if(statusOS2 & QS_KEY)
    517     statusWin32 |= QS_KEY_W;
    518    if(statusOS2 & QS_MOUSEBUTTON)
    519     statusWin32 |= QS_MOUSEBUTTON_W;
    520    if(statusOS2 & QS_MOUSEMOVE)
    521     statusWin32 |= QS_MOUSEMOVE_W;
    522    if(statusOS2 & QS_TIMER)
    523     statusWin32 |= QS_TIMER_W;
    524    if(statusOS2 & QS_PAINT)
    525     statusWin32 |= QS_PAINT_W;
    526    if(statusOS2 & QS_POSTMSG)
    527     statusWin32 |= QS_POSTMESSAGE_W;
    528    if(statusOS2 & QS_SENDMSG)
    529     statusWin32 |= QS_SENDMESSAGE_W;
    530 
    531    return statusWin32;
     526    ULONG statusOS2, statusWin32 = 0;
     527
     528    statusOS2 = WinQueryQueueStatus(HWND_DESKTOP);
     529
     530    if(statusOS2 & QS_KEY)
     531        statusWin32 |= QS_KEY_W;
     532    if(statusOS2 & QS_MOUSEBUTTON)
     533        statusWin32 |= QS_MOUSEBUTTON_W;
     534    if(statusOS2 & QS_MOUSEMOVE)
     535        statusWin32 |= QS_MOUSEMOVE_W;
     536    if(statusOS2 & QS_TIMER)
     537        statusWin32 |= QS_TIMER_W;
     538    if(statusOS2 & QS_PAINT)
     539        statusWin32 |= QS_PAINT_W;
     540    if(statusOS2 & QS_POSTMSG)
     541        statusWin32 |= QS_POSTMESSAGE_W;
     542    if(statusOS2 & QS_SENDMSG)
     543        statusWin32 |= QS_SENDMESSAGE_W;
     544
     545    return statusWin32;
    532546}
    533547//******************************************************************************
     
    535549BOOL OSLibWinInSendMessage()
    536550{
    537    return WinInSendMsg(GetThreadHAB());
     551    return WinInSendMsg(GetThreadHAB());
    538552}
    539553//******************************************************************************
     
    541555DWORD OSLibWinGetMessagePos()
    542556{
    543  APIRET rc;
    544  POINTL ptl;
    545 
    546    rc = WinQueryMsgPos(GetThreadHAB(), &ptl);
    547    if(!rc) {
    548       return 0;
    549    }
    550    //convert to windows coordinates
    551    return MAKEULONG(ptl.x,mapScreenY(ptl.y));
     557    APIRET rc;
     558    POINTL ptl;
     559
     560    rc = WinQueryMsgPos(GetThreadHAB(), &ptl);
     561    if(!rc) {
     562        return 0;
     563    }
     564    //convert to windows coordinates
     565    return MAKEULONG(ptl.x,mapScreenY(ptl.y));
    552566}
    553567//******************************************************************************
     
    555569LONG OSLibWinGetMessageTime()
    556570{
    557    return (LONG)WinQueryMsgTime(GetThreadHAB());
     571    return (LONG)WinQueryMsgTime(GetThreadHAB());
    558572}
    559573//******************************************************************************
     
    561575BOOL OSLibWinReplyMessage(ULONG result)
    562576{
    563    return (BOOL)WinReplyMsg( NULLHANDLE, NULLHANDLE, HMQ_CURRENT, (MRESULT)result);
     577    return (BOOL)WinReplyMsg( NULLHANDLE, NULLHANDLE, HMQ_CURRENT, (MRESULT)result);
    564578}
    565579//******************************************************************************
     
    567581ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode)
    568582{
    569  POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
     583    POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
    570584 
    571585    if(NULL == packet)
     
    595609BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode)
    596610{
    597  POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
     611    POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
    598612 
    599613    if (NULL == packet)
     
    621635BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
    622636{
    623  TEB *teb = GetTEBFromThreadId(threadid);
    624  POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
    625  BOOL ret;
     637    TEB *teb = GetTEBFromThreadId(threadid);
     638    POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
     639    BOOL ret;
    626640 
    627641    if(NULL == packet)
     
    659673DWORD GetThreadMessageExtraInfo()
    660674{
    661  TEB *teb;
    662 
    663   teb = GetThreadTEB();
    664   if(teb)
    665   {
    666       return teb->o.odin.dwMsgExtraInfo;
    667   }
    668   dprintf(("GetThreadMessageExtraInfo: teb == NULL!!"));
    669   return 0;
     675    TEB *teb;
     676
     677    teb = GetThreadTEB();
     678    if(teb)
     679    {
     680        return teb->o.odin.dwMsgExtraInfo;
     681    }
     682    dprintf(("GetThreadMessageExtraInfo: teb == NULL!!"));
     683    return 0;
    670684}
    671685//******************************************************************************
     
    673687DWORD SetThreadMessageExtraInfo(DWORD lParam)
    674688{
    675  TEB *teb;
    676 
    677   teb = GetThreadTEB();
    678   if(teb)
    679   {
    680         teb->o.odin.dwMsgExtraInfo = lParam;
    681   }
    682   else dprintf(("SetThreadMessageExtraInfo: teb == NULL!!"));
    683   return 0;
    684 }
    685 //******************************************************************************
    686 //******************************************************************************
     689    TEB *teb;
     690
     691    teb = GetThreadTEB();
     692    if(teb)
     693    {
     694         teb->o.odin.dwMsgExtraInfo = lParam;
     695    }
     696    else dprintf(("SetThreadMessageExtraInfo: teb == NULL!!"));
     697    return 0;
     698}
     699//******************************************************************************
     700//******************************************************************************
  • trunk/src/user32/windowmsg.cpp

    r7801 r8689  
    1 /* $Id: windowmsg.cpp,v 1.33 2002-02-05 17:59:02 sandervl Exp $ */
     1/* $Id: windowmsg.cpp,v 1.34 2002-06-15 17:17:17 sandervl Exp $ */
    22/*
    33 * Win32 window message APIs for OS/2
     
    4141LONG WIN32API DispatchMessageA(const MSG * msg)
    4242{
    43   dprintf2(("DispatchMessageA %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
    44   return OSLibWinDispatchMsg((MSG *)msg);
     43    dprintf2(("DispatchMessageA %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
     44    return OSLibWinDispatchMsg((MSG *)msg);
    4545}
    4646//******************************************************************************
     
    4848LONG WIN32API DispatchMessageW( const MSG * msg)
    4949{
    50   dprintf2(("DispatchMessageW %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
    51   return OSLibWinDispatchMsg((MSG *)msg, TRUE);
     50    dprintf2(("DispatchMessageW %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
     51    return OSLibWinDispatchMsg((MSG *)msg, TRUE);
    5252}
    5353//******************************************************************************
     
    5555BOOL WIN32API TranslateMessage(const MSG *msg)
    5656{
    57   // check the message code
    58   if ( (msg->message <  WM_KEYDOWN) ||
    59        (msg->message >  WM_SYSKEYUP)||
    60        (msg->message == WM_CHAR)    ||
    61        (msg->message == WM_DEADCHAR) )
    62   {
    63     SetLastError(ERROR_INVALID_PARAMETER);
    64     return FALSE;
    65   }
     57    // check the message code
     58    if ( (msg->message <  WM_KEYDOWN) ||
     59         (msg->message >  WM_SYSKEYUP)||
     60         (msg->message == WM_CHAR)    ||
     61         (msg->message == WM_DEADCHAR) )
     62    {
     63        SetLastError(ERROR_INVALID_PARAMETER);
     64        return FALSE;
     65    }
    6666 
    67   // only WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, WM_SYSKEYUP
    68   // can go into TranslateMessage
     67    // only WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, WM_SYSKEYUP
     68    // can go into TranslateMessage
    6969 
    70   return OSLibWinTranslateMessage((MSG *)msg);
     70    return OSLibWinTranslateMessage((MSG *)msg);
    7171}
    7272//******************************************************************************
     
    7474BOOL WIN32API GetMessageA( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax)
    7575{
    76   BOOL ret;
     76    BOOL ret;
    7777
    7878    dprintf2(("GetMessageA %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax));
     
    8686BOOL WIN32API GetMessageW( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax)
    8787{
    88   BOOL ret;
     88    BOOL ret;
    8989
    9090    dprintf2(("GetMessageW %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax));
     
    9898                           UINT uMsgFilterMax, UINT fuRemoveMsg)
    9999{
    100  BOOL fFoundMsg;
     100    BOOL fFoundMsg;
    101101 
    102102    dprintf2(("PeekMessageA %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg));
     
    117117                           UINT uMsgFilterMax, UINT fuRemoveMsg)
    118118{
    119  BOOL fFoundMsg;
     119    BOOL fFoundMsg;
    120120
    121121    dprintf2(("PeekMessageW %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg));
     
    143143LPARAM WIN32API SetMessageExtraInfo(LPARAM lParam)
    144144{
    145   dprintf(("USER32: SetMessageExtraInfo %x", lParam));
    146   return SetThreadMessageExtraInfo(lParam);
     145    dprintf(("USER32: SetMessageExtraInfo %x", lParam));
     146    return SetThreadMessageExtraInfo(lParam);
    147147}
    148148//******************************************************************************
     
    150150DWORD WIN32API GetMessagePos(void)
    151151{
    152  DWORD pos;
     152    DWORD pos;
    153153
    154154    pos = OSLibWinGetMessagePos();
     
    195195UINT WIN32API RegisterWindowMessageA(LPCSTR lpString)
    196196{
    197  UINT rc;
     197    UINT rc;
    198198
    199199    rc = GlobalAddAtomA(lpString);
     
    213213BOOL WIN32API SetMessageQueue(int cMessagesMax)
    214214{
    215   dprintf(("USER32:  SetMessageQueue\n"));
    216   return(TRUE);
     215    dprintf(("USER32:  SetMessageQueue\n"));
     216    return(TRUE);
    217217}
    218218//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.