Changeset 2200 for trunk/src


Ignore:
Timestamp:
Dec 24, 1999, 7:42:46 PM (26 years ago)
Author:
sandervl
Message:

Message handling rewrite

Location:
trunk/src/user32
Files:
1 added
11 edited

Legend:

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

    r2076 r2200  
    1 /* $Id: dc.cpp,v 1.28 1999-12-14 19:13:18 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.29 1999-12-24 18:39:10 sandervl Exp $ */
    22
    33/*
     
    13811381//******************************************************************************
    13821382//******************************************************************************
     1383BOOL WIN32API ValidateRect( HWND hwnd, const RECT * lprc)
     1384{
     1385    dprintf(("USER32: ValidateRect %x (%d,%d)(%d,%d)", hwnd, lprc->left, lprc->top, lprc->right, lprc->bottom));
     1386    return RedrawWindow( hwnd, lprc, 0, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
     1387}
     1388//******************************************************************************
     1389//******************************************************************************
     1390BOOL WIN32API ValidateRgn( HWND hwnd, HRGN  hrgn)
     1391{
     1392    dprintf(("USER32: ValidateRgn %x %x", hwnd, hrgn));
     1393    return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE_W | RDW_NOCHILDREN_W | (hwnd==0 ? RDW_UPDATENOW_W : 0));
     1394}
     1395/*****************************************************************************
     1396 * Name      : int WIN32API GetWindowRgn
     1397 * Purpose   : The GetWindowRgn function obtains a copy of the window region of a window.
     1398 * Parameters: HWND hWnd handle to window whose window region is to be obtained
     1399 *             HRGN hRgn handle to region that receives a copy of the window region
     1400 * Variables :
     1401 * Result    : NULLREGION, SIMPLEREGION, COMPLEXREGION, ERROR
     1402 * Remark    :
     1403 * Status    : UNTESTED STUB
     1404 *
     1405 * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
     1406 *****************************************************************************/
     1407
     1408int WIN32API GetWindowRgn (HWND hWnd,
     1409                              HRGN hRgn)
     1410{
     1411  dprintf(("USER32:GetWindowRgn (%08xh,%08x) not implemented.\n",
     1412         hWnd,
     1413         hRgn));
     1414  //Attention: Win32 hwnd handle!
     1415
     1416  return (NULLREGION_W);
     1417}
     1418/*****************************************************************************
     1419 * Name      : int WIN32API SetWindowRgn
     1420 * Purpose   : The SetWindowRgn function sets the window region of a window. The
     1421 *             window region determines the area within the window where the
     1422 *             operating system permits drawing. The operating system does not
     1423 *             display any portion of a window that lies outside of the window region
     1424 * Parameters: HWND  hWnd    handle to window whose window region is to be set
     1425 *             HRGN  hRgn    handle to region
     1426 *             BOOL  bRedraw window redraw flag
     1427 * Variables :
     1428 * Result    : If the function succeeds, the return value is non-zero.
     1429 *             If the function fails, the return value is zero.
     1430 * Remark    :
     1431 * Status    : UNTESTED STUB
     1432 *
     1433 * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
     1434 *****************************************************************************/
     1435
     1436int WIN32API SetWindowRgn(HWND hWnd,
     1437                             HRGN hRgn,
     1438                             BOOL bRedraw)
     1439{
     1440  dprintf(("USER32:SetWindowRgn (%08xh,%08xh,%u) not implemented.\n",
     1441         hWnd,
     1442         hRgn,
     1443         bRedraw));
     1444  //Attention: Win32 hwnd handle!
     1445
     1446  return (0);
     1447}
     1448//******************************************************************************
     1449//******************************************************************************
  • trunk/src/user32/oslibmsg.cpp

    r1971 r2200  
    1 /* $Id: oslibmsg.cpp,v 1.14 1999-12-05 00:31:47 sandervl Exp $ */
     1/* $Id: oslibmsg.cpp,v 1.15 1999-12-24 18:39:10 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    99 * Project Odin Software License can be found in LICENSE.TXT
    1010 *
    11  * TODO: Simply copy for now. Need to make a real translation
     11 * TODO: Some messages that are sent to the frame window are directly passed on to the client
     12 *       -> Get/PeekMessage never gets them as we return a dummy message for non-client windows
     13 *       (i.e. menu WM_COMMAND messages)
     14 *
    1215 * TODO: Filter translation isn't correct for posted messages
    1316 *
     
    2730#include <wprocess.h>
    2831#include "pmwindow.h"
     32#include "oslibwin.h"
    2933
    3034typedef BOOL (EXPENTRY FNTRANS)(MSG *, QMSG *);
     
    8084   0x020a, 0x020a,   // WM_???,             WM_???
    8185   WM_CHAR,          WINWM_CHAR,
    82    
     86
    8387   //TODO: Needs better translation!
    8488   WM_CHAR,          WINWM_KEYDOWN,
     
    9296QMSG *MsgThreadPtr = 0;
    9397
     98LRESULT WIN32API SendMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
     99
    94100//******************************************************************************
    95101//******************************************************************************
     
    108114void WinToOS2MsgTranslate(MSG *winMsg, QMSG *os2Msg, BOOL isUnicode)
    109115{
    110   int i;
    111 
    112   memcpy(os2Msg, winMsg, sizeof(MSG));
    113   os2Msg->hwnd = Win32Window::Win32ToOS2Handle(winMsg->hwnd);
    114   os2Msg->reserved = 0;
    115   for(i=0;i<MAX_MSGTRANSTAB;i++)
    116   {
    117     if(MsgTransTab[i].msgWin32 == winMsg->message)
    118     {
    119       os2Msg->msg = MsgTransTab[i].msgOS2;
    120       break;
    121     }
    122   }
    123 }
    124 //******************************************************************************
    125 //******************************************************************************
    126 void OS2ToWinMsgTranslate(QMSG *os2Msg, MSG *winMsg, BOOL isUnicode)
    127 {
    128   POSTMSG_PACKET *packet;
    129   int i;
    130 
    131   memcpy(winMsg, os2Msg, sizeof(MSG));
    132   winMsg->hwnd = Win32Window::OS2ToWin32Handle(os2Msg->hwnd);
    133 
    134   if(os2Msg->msg == WIN32APP_POSTMSG) {
    135         packet = (POSTMSG_PACKET *)os2Msg->mp2;
    136         if(packet && (ULONG)os2Msg->mp1 == WIN32PM_MAGIC) {
    137                 winMsg->message = packet->Msg;
    138                 winMsg->wParam  = packet->wParam;
    139                 winMsg->lParam  = packet->lParam;
    140         }
    141         return;
    142   }
    143   for(i=0;i<MAX_MSGTRANSTAB;i++)
    144   {
    145     if(MsgTransTab[i].msgOS2 == os2Msg->msg)
    146     {
    147       winMsg->message = MsgTransTab[i].msgWin32;
    148       break;
    149     }
    150   }
     116//  memcpy(os2Msg, winMsg, sizeof(MSG));
     117//  os2Msg->hwnd = Win32Window::Win32ToOS2Handle(winMsg->hwnd);
     118//  os2Msg->reserved = 0;
    151119}
    152120//******************************************************************************
     
    159127{
    160128 POSTMSG_PACKET *packet;
    161  THDB *thdb;
    162 
    163   thdb = GetThreadTHDB();
    164   if(thdb) {
    165         thdb->fMsgTranslated = TRUE;
    166   }
    167129
    168130  if(msg >= WINWM_USER)
     
    192154LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
    193155{
    194  BOOL eaten = 0;
    195 
    196 //TODO: What to do if app changed msg? (translate)
    197 //  WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
    198 
    199   //SvL: Some apps use PeeKMessage(remove) & DispatchMessage instead of
    200   //     GetMessage/DispatchMessage
    201   if (MsgThreadPtr->msg == WM_TIMER)
    202       eaten = TIMER_HandleTimer (MsgThreadPtr);
    203  
    204   if(eaten)     return 0;
    205 
    206   return (LONG)WinDispatchMsg(GetThreadHAB(), MsgThreadPtr);
     156 THDB *thdb;
     157 QMSG  os2msg;
     158 LONG  rc;
     159
     160  thdb = GetThreadTHDB();
     161  if(thdb == NULL) {
     162        DebugInt3();
     163        return FALSE;
     164  }
     165
     166  //TODO: What to do if app changed msg? (translate)
     167  //  WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
     168
     169  if(msg->time == MsgThreadPtr->time || msg->hwnd == 0) {
     170        memcpy(&os2msg, MsgThreadPtr, sizeof(QMSG));
     171        MsgThreadPtr->time = -1;
     172        if(msg->hwnd) {
     173            thdb->nrOfMsgs = 1;
     174            thdb->msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
     175            memcpy(&thdb->msg, msg, sizeof(MSG));
     176        }
     177        return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
     178  }
     179  else {//is this allowed?
     180//        dprintf(("WARNING: OSLibWinDispatchMsg: called with own message!"));
     181        return SendMessageA(msg->hwnd, msg->message, msg->wParam, msg->lParam);
     182  }
    207183}
    208184//******************************************************************************
     
    212188{
    213189 BOOL rc, eaten;
     190 THDB *thdb;
     191
     192  thdb = GetThreadTHDB();
     193  if(thdb == NULL) {
     194        DebugInt3();
     195        return FALSE;
     196  }
     197
     198  if(thdb->fTranslated && (!hwnd || hwnd == thdb->msgWCHAR.hwnd)) {
     199        thdb->fTranslated = FALSE;
     200        memcpy(pMsg, &thdb->msgWCHAR, sizeof(MSG));
     201        MsgThreadPtr->msg  = 0;
     202        MsgThreadPtr->hwnd = 0;
     203        return TRUE;
     204  }
     205  if(hwnd) {
     206        do {
     207            WinWaitMsg(thdb->hab, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax));
     208            rc = OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, PM_REMOVE_W, isUnicode);
     209        }
     210        while(rc == FALSE);
     211  }
     212  else
     213  {
     214    do {
     215        eaten = FALSE;
     216        rc = WinGetMsg(thdb->hab, MsgThreadPtr, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax), 0);
     217        if (MsgThreadPtr->msg == WM_TIMER)
     218            eaten = TIMER_HandleTimer (MsgThreadPtr);
     219    } while (eaten);
     220  }
     221  OS2ToWinMsgTranslate((PVOID)thdb, MsgThreadPtr, pMsg, isUnicode);
     222  return rc;
     223}
     224//******************************************************************************
     225//******************************************************************************
     226BOOL OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
     227                     DWORD fRemove, BOOL isUnicode)
     228{
     229 BOOL  rc, eaten;
     230 THDB *thdb;
     231 QMSG  os2msg;
     232
     233  thdb = GetThreadTHDB();
     234  if(thdb == NULL) {
     235        DebugInt3();
     236        return FALSE;
     237  }
     238
     239  if(thdb->fTranslated && (!hwnd || hwnd == thdb->msgWCHAR.hwnd)) {
     240        if(fRemove == PM_REMOVE_W) {
     241            thdb->fTranslated = FALSE;
     242            MsgThreadPtr->msg  = 0;
     243            MsgThreadPtr->hwnd = 0;
     244        }
     245        memcpy(pMsg, &thdb->msgWCHAR, sizeof(MSG));
     246        return TRUE;
     247  }
    214248
    215249  do {
    216     eaten = FALSE;
    217     rc = WinGetMsg(GetThreadHAB(), MsgThreadPtr, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax), 0);
    218     if (MsgThreadPtr->msg == WM_TIMER)
    219       eaten = TIMER_HandleTimer (MsgThreadPtr);
    220   } while (eaten);
    221 
    222   OS2ToWinMsgTranslate(MsgThreadPtr, pMsg, isUnicode);
     250        eaten = FALSE;
     251        rc = WinPeekMsg(thdb->hab, &os2msg, Win32BaseWindow::OS2ToWin32Handle(hwnd), TranslateWinMsg(uMsgFilterMin),
     252                        TranslateWinMsg(uMsgFilterMax), (fRemove == PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
     253
     254        if (rc && fRemove == PM_REMOVE_W && os2msg.msg == WM_TIMER)
     255            eaten = TIMER_HandleTimer(&os2msg);
     256  }
     257  while (eaten && rc);
     258
     259  OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode);
     260  //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message
     261  if(fRemove == PM_REMOVE_W) {
     262        memcpy(MsgThreadPtr, &os2msg, sizeof(QMSG));
     263  }
    223264  return rc;
    224265}
    225266//******************************************************************************
    226267//******************************************************************************
    227 BOOL  OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
    228                       BOOL fRemove, BOOL isUnicode)
    229 {
    230  BOOL rc;
    231 
    232   rc = WinPeekMsg(GetThreadHAB(), MsgThreadPtr, hwnd, TranslateWinMsg(uMsgFilterMin),
    233                   TranslateWinMsg(uMsgFilterMax), (fRemove == MSG_REMOVE) ? PM_REMOVE : PM_NOREMOVE);
    234   OS2ToWinMsgTranslate(MsgThreadPtr, pMsg, isUnicode);
    235   return rc;
    236 }
    237 //******************************************************************************
    238 //******************************************************************************
    239268ULONG OSLibWinQueryMsgTime()
    240269{
     
    252281ULONG OSLibWinQueryQueueStatus()
    253282{
    254  ULONG statusOS2, statusWin32;
     283 ULONG statusOS2, statusWin32 = 0;
    255284
    256285   statusOS2 = WinQueryQueueStatus(HWND_DESKTOP);
    257286
    258287   if(statusOS2 & QS_KEY)
    259         statusWin32 |= QS_KEY_W;
    260    if(statusOS2 & QS_MOUSEBUTTON)   
    261         statusWin32 |= QS_MOUSEBUTTON_W;
     288    statusWin32 |= QS_KEY_W;
     289   if(statusOS2 & QS_MOUSEBUTTON)
     290    statusWin32 |= QS_MOUSEBUTTON_W;
    262291   if(statusOS2 & QS_MOUSEMOVE)
    263         statusWin32 |= QS_MOUSEMOVE_W;
    264    if(statusOS2 & QS_TIMER)   
    265         statusWin32 |= QS_TIMER_W;
    266    if(statusOS2 & QS_PAINT)   
    267         statusWin32 |= QS_PAINT_W;
    268    if(statusOS2 & QS_POSTMSG)   
    269         statusWin32 |= QS_POSTMESSAGE_W;
    270    if(statusOS2 & QS_SENDMSG)   
    271         statusWin32 |= QS_SENDMESSAGE_W;
     292    statusWin32 |= QS_MOUSEMOVE_W;
     293   if(statusOS2 & QS_TIMER)
     294    statusWin32 |= QS_TIMER_W;
     295   if(statusOS2 & QS_PAINT)
     296    statusWin32 |= QS_PAINT_W;
     297   if(statusOS2 & QS_POSTMSG)
     298    statusWin32 |= QS_POSTMESSAGE_W;
     299   if(statusOS2 & QS_SENDMSG)
     300    statusWin32 |= QS_SENDMESSAGE_W;
    272301
    273302   return statusWin32;
  • trunk/src/user32/oslibmsg.h

    r1971 r2200  
    1 /* $Id: oslibmsg.h,v 1.6 1999-12-05 00:31:47 sandervl Exp $ */
     1/* $Id: oslibmsg.h,v 1.7 1999-12-24 18:39:10 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    1818ULONG TranslateWinMsg(ULONG msg);
    1919
     20#define ODINMSG_NOEXTRAMSGS     0
     21#define ODINMSG_EXTRAMSGS       1
     22
    2023#ifdef OS2DEF_INCLUDED
    21 void  OS2ToWinMsgTranslate(QMSG *os2Msg, MSG *winMsg, BOOL isUnicode);
     24BOOL  OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs = ODINMSG_EXTRAMSGS);
    2225void  WinToOS2MsgTranslate(MSG *winMsg, QMSG *os2Msg, BOOL isUnicode);
     26
     27extern QMSG *MsgThreadPtr;
     28
    2329#endif
    2430
     
    2632                     UINT uMsgFilterMax, BOOL isUnicode = FALSE);
    2733BOOL  OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin,
    28                       UINT uMsgFilterMax, BOOL fRemove, BOOL isUnicode = FALSE);
     34                      UINT uMsgFilterMax, DWORD fRemove, BOOL isUnicode = FALSE);
    2935void  OSLibWinPostQuitMessage(ULONG nExitCode);
    3036LONG  OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode = FALSE);
     37BOOL  OSLibWinTranslateMessage(MSG *msg);
    3138
    3239ULONG OSLibWinQueryMsgTime();
     
    3744LONG  OSLibWinGetMessageTime();
    3845BOOL  OSLibWinReplyMessage(ULONG result);
    39 
    4046ULONG OSLibWinQueryQueueStatus();
    4147
     
    94100#define WINWM_COPYDATA              0x004A
    95101#define WINWM_CANCELJOURNAL         0x004B
     102#define WINWM_CONTEXTMENU           0x007b
     103#define WINWM_STYLECHANGING         0x007c
     104#define WINWM_STYLECHANGED          0x007d
     105#define WINWM_DISPLAYCHANGE         0x007e
     106#define WINWM_GETICON               0x007f
     107#define WINWM_SETICON               0x0080
    96108#define WINWM_NCCREATE              0x0081
    97109#define WINWM_NCDESTROY             0x0082
     
    129141#define WINWM_INITMENU              0x0116
    130142#define WINWM_INITMENUPOPUP         0x0117
     143#define WINWM_SYSTIMER              0x0118
    131144#define WINWM_MENUSELECT            0x011F
    132145#define WINWM_MENUCHAR              0x0120
     
    187200#define WINWM_HOTKEY                0x0312
    188201#define WINWM_DDE_FIRST             0x03E0
    189 #define WINWM_DDE_INITIATE          (WM_DDE_FIRST)
    190 #define WINWM_DDE_TERMINATE         (WM_DDE_FIRST + 1)
    191 #define WINWM_DDE_ADVISE            (WM_DDE_FIRST + 2)
    192 #define WINWM_DDE_UNADVISE          (WM_DDE_FIRST + 3)
    193 #define WINWM_DDE_ACK               (WM_DDE_FIRST + 4)
    194 #define WINWM_DDE_DATA              (WM_DDE_FIRST + 5)
    195 #define WINWM_DDE_REQUEST           (WM_DDE_FIRST + 6)
    196 #define WINWM_DDE_POKE              (WM_DDE_FIRST + 7)
    197 #define WINWM_DDE_EXECUTE           (WM_DDE_FIRST + 8)
    198 #define WINWM_DDE_LAST              (WM_DDE_FIRST + 8)
     202#define WINWM_DDE_INITIATE          (WINWM_DDE_FIRST)
     203#define WINWM_DDE_TERMINATE         (WINWM_DDE_FIRST + 1)
     204#define WINWM_DDE_ADVISE            (WINWM_DDE_FIRST + 2)
     205#define WINWM_DDE_UNADVISE          (WINWM_DDE_FIRST + 3)
     206#define WINWM_DDE_ACK               (WINWM_DDE_FIRST + 4)
     207#define WINWM_DDE_DATA              (WINWM_DDE_FIRST + 5)
     208#define WINWM_DDE_REQUEST           (WINWM_DDE_FIRST + 6)
     209#define WINWM_DDE_POKE              (WINWM_DDE_FIRST + 7)
     210#define WINWM_DDE_EXECUTE           (WINWM_DDE_FIRST + 8)
     211#define WINWM_DDE_LAST              (WINWM_DDE_FIRST + 8)
    199212#define WINWM_USER                  0x0400
    200213
  • trunk/src/user32/pmframe.cpp

    r2140 r2200  
    1 /* $Id: pmframe.cpp,v 1.28 1999-12-19 17:46:24 cbratschi Exp $ */
     1/* $Id: pmframe.cpp,v 1.29 1999-12-24 18:39:10 sandervl Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    2626
    2727#define PMFRAMELOG
    28 
    29 #define GCL_STYLE_W           (-26)
    30 #define CS_VREDRAW_W          0x0001
    31 #define CS_HREDRAW_W          0x0002
    3228
    3329//******************************************************************************
  • trunk/src/user32/pmwindow.cpp

    r2189 r2200  
    1 /* $Id: pmwindow.cpp,v 1.68 1999-12-22 18:09:31 cbratschi Exp $ */
     1/* $Id: pmwindow.cpp,v 1.69 1999-12-24 18:39:10 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    1717#include <os2wrap.h>
    1818#include <stdlib.h>
     19#include <string.h>
    1920#include "win32type.h"
    2021#include <winconst.h>
     
    4344ULONG ScreenBitsPerPel = 0;
    4445
    45 //Used for key translation while processing WM_CHAR message
    46 USHORT virtualKeyTable [66] = {
    47                0x00,    //   OS/2 VK         Win32 VK,    Entry 0 is not used
    48                0x01,    // VK_BUTTON1       VK_LBUTTON
    49                0x02,    // VK_BUTTON2       VK_RBUTTON
    50                0x04,    // VK_BUTTON3       VK_MBUTTON
    51                0x03,    // VK_BREAK         VK_CANCEL
    52                0x08,    // VK_BACKSPACE     VK_BACK
    53                0x09,    // VK_TAB           VK_TAB
    54                0x00,    // VK_BACKTAB       No equivalent!
    55                0x0A,    // VK_NEWLINE       0x0A (no VK_* def)
    56                0x10,    // VK_SHIFT         VK_SHIFT
    57                0x11,    // VK_CTRL          VK_CONTROL
    58                0x12,    // VK_ALT           VK_MENU, best match I guess
    59                0x12,    // VK_ALTGRAF       VK_MENU, best match I guess
    60                0x13,    // VK_PAUSE         VK_PAUSE
    61                0x14,    // VK_CAPSLOCK      VK_CAPITAL
    62                0x1B,    // VK_ESC           VK_ESCAPE
    63                0x20,    // VK_SPACE         VK_SPACE
    64                0x21,    // VK_PAGEUP        VK_PRIOR
    65                0x22,    // VK_PAGEDOWN      VK_NEXT
    66                0x23,    // VK_END           VK_END
    67                0x24,    // VK_HOME          VK_HOME
    68                0x25,    // VK_LEFT          VK_LEFT
    69                0x26,    // VK_UP            VK_UP
    70                0x27,    // VK_RIGHT         VK_RIGHT
    71                0x28,    // VK_DOWN          VK_DOWN
    72                0x2C,    // VK_PRINTSCRN     VK_SNAPSHOT
    73                0x2D,    // VK_INSERT        VK_INSERT
    74                0x2E,    // VK_DELETE        VK_DELETE
    75                0x91,    // VK_SCRLLOCK      VK_SCROLL
    76                0x90,    // VK_NUMLOCK       VK_NUMLOCK
    77                0x0D,    // VK_ENTER         VK_RETURN
    78                0x00,    // VK_SYSRQ         No equivalent!
    79                0x70,    // VK_F1            VK_F1
    80                0x71,    // VK_F2            VK_F2
    81                0x72,    // VK_F3            VK_F3
    82                0x73,    // VK_F4            VK_F4
    83                0x74,    // VK_F5            VK_F5
    84                0x75,    // VK_F6            VK_F6
    85                0x76,    // VK_F7            VK_F7
    86                0x77,    // VK_F8            VK_F8
    87                0x78,    // VK_F9            VK_F9
    88                0x79,    // VK_F10           VK_F10
    89                0x7A,    // VK_F11           VK_F11
    90                0x7B,    // VK_F12           VK_F12
    91                0x7C,    // VK_F13           VK_F13
    92                0x7D,    // VK_F14           VK_F14
    93                0x7E,    // VK_F15           VK_F15
    94                0x7F,    // VK_F16           VK_F16
    95                0x80,    // VK_F17           VK_F17
    96                0x81,    // VK_F18           VK_F18
    97                0x82,    // VK_F19           VK_F19
    98                0x83,    // VK_F20           VK_F20
    99                0x84,    // VK_F21           VK_F21
    100                0x85,    // VK_F22           VK_F22
    101                0x86,    // VK_F23           VK_F23
    102                0x87,    // VK_F24           VK_F24
    103                0x00,    // VK_ENDDRAG       No equivalent!
    104                0x0C,    // VK_CLEAR         VK_CLEAR
    105                0xF9,    // VK_EREOF         VK_EREOF
    106                0xFD,    // VK_PA1           VK_PA1
    107                0xF6,    // VK_ATTN          VK_ATTN
    108                0xF7,    // VK_CRSEL         VK_CRSEL
    109                0xF8,    // VK_EXSEL         VK_EXSEL
    110                0x00,    // VK_COPY          No equivalent!
    111                0x00,    // VK_BLK1          No equivalent!
    112                0x00};   // VK_BLK2          No equivalent!
    11346
    11447MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     
    202135 OSLIBPOINT       point, ClientPoint;
    203136 Win32BaseWindow *win32wnd;
     137 THDB            *thdb;
    204138 APIRET           rc;
     139 MSG              winMsg, *pWinMsg;
    205140
    206141  //Restore our FS selector
    207142  SetWin32TIB();
    208143
     144  thdb = GetThreadTHDB();
    209145  win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    210146
    211   if(msg != WM_CREATE && win32wnd == NULL) {
    212         dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
    213         goto RunDefWndProc;
    214   }
     147  if(!thdb || (msg != WM_CREATE && win32wnd == NULL)) {
     148        dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
     149        goto RunDefWndProc;
     150  }
     151
     152  if((thdb->msgstate & 1) == 0)
     153  {//message that was sent directly to our window proc handler; translate it here
     154        QMSG qmsg;
     155
     156        qmsg.msg  = msg;
     157        qmsg.hwnd = hwnd;
     158        qmsg.mp1  = mp1;
     159        qmsg.mp2  = mp2;
     160        qmsg.time = WinQueryMsgTime(thdb->hab);
     161        WinQueryMsgPos(thdb->hab, &qmsg.ptl);
     162        qmsg.reserved = 0;
     163
     164        if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, ODINMSG_NOEXTRAMSGS) == FALSE)
     165        {//message was not translated
     166            memset(&winMsg, 0, sizeof(MSG));
     167        }
     168        pWinMsg = &winMsg;
     169  }
     170  else {
     171        pWinMsg = &thdb->msg;
     172        thdb->msgstate++;
     173  }
     174
    215175  if(msg == WIN32APP_POSTMSG && (ULONG)mp1 == WIN32PM_MAGIC) {
    216176        //win32 app user message
     
    222182    case WM_CREATE:
    223183    {
    224      THDB *thdb = GetThreadTHDB();
    225 
    226         if(thdb == NULL || thdb->newWindow == 0)
     184
     185        if(thdb->newWindow == 0)
    227186            goto createfail;
    228187
     
    230189        dprintf(("OS2: WM_CREATE %x", hwnd));
    231190        win32wnd = (Win32BaseWindow *)thdb->newWindow;
     191        thdb->newWindow = 0;
    232192
    233193        if(win32wnd->MsgCreate(WinQueryWindow(hwnd, QW_PARENT), hwnd) == FALSE)
     
    250210    case WM_CLOSE:
    251211        dprintf(("OS2: WM_CLOSE %x", hwnd));
    252 //        win32wnd->RemoveFakeOpen32();
    253212        if(win32wnd->MsgClose()) {
    254213                goto RunDefWndProc;
     
    280239    case WM_ADJUSTWINDOWPOS:
    281240    {
    282       PSWP     pswp = (PSWP)mp1;
    283 
    284         dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     241//      PSWP     pswp = (PSWP)mp1;
     242
     243//        dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    285244        goto RunDefWndProc;
    286245    }
     
    341300#endif
    342301
    343 #if 1
    344302    case WM_WINDOWPOSCHANGED:
    345303    {
    346       PSWP      pswp  = (PSWP)mp1;
    347       SWP       swpOld = *(pswp + 1);
    348       WINDOWPOS wp;
    349       HWND      hParent = NULLHANDLE;
    350       LONG      yDelta = pswp->cy - swpOld.cy;
    351       LONG      xDelta = pswp->cx - swpOld.cx;
    352 
    353         dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    354 
    355         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto RunDefWndProc;
    356 
    357         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    358             if (win32wnd->isChild()) {
    359                 if(win32wnd->getParent()) {
    360                         hParent = win32wnd->getParent()->getOS2WindowHandle();
    361                 }
    362                 else    goto RunDefWndProc; //parent has just been destroyed
    363             }
    364         }
    365         OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, hParent, win32wnd->getOS2FrameWindowHandle());
    366 
    367         if (!win32wnd->CanReceiveSizeMsgs())    goto RunDefWndProc;
    368 
    369         dprintf(("Set client rectangle to (%d,%d)(%d,%d)", swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy));
    370         win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
    371 
    372         wp.hwnd = win32wnd->getWindowHandle();
    373         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    374         {
    375            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    376            wp.hwndInsertAfter = wndAfter->getWindowHandle();
    377         }
    378 
    379         PRECT lpRect = win32wnd->getWindowRect();
    380         //SvL: Only send it when the client has changed & the frame hasn't
    381         //     If the frame size/position has changed, pmframe.cpp will send
    382         //     this message
    383         if(lpRect->right == wp.x+wp.cx && lpRect->bottom == wp.y+wp.cy) {
    384                 win32wnd->MsgPosChanged((LPARAM)&wp);
    385         }
    386         else    win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
    387 
    388         goto RunDefWndProc;
    389     }
    390 #endif
     304        win32wnd->MsgPosChanged((LPARAM)&thdb->wp);
     305        goto RunDefWndProc;
     306    }
    391307
    392308    case WM_ACTIVATE:
     
    412328    }
    413329
    414     case WM_SIZE:
    415     {
    416         dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
    417         break;
    418     }
    419     case WM_MINMAXFRAME:
    420     {
    421         dprintf(("OS2: WM_MINMAXFRAME"));
    422         break;
    423     }
    424     case WM_OWNERPOSCHANGE:
    425     {
    426         dprintf(("OS2: WM_OWNERPOSCHANGE"));
    427         goto RunDefWndProc;
    428     }
    429 
    430     case WM_CALCVALIDRECTS:
    431     {
    432         dprintf(("OS2: WM_CALCVALIDRECTS"));
    433         goto RunDefWndProc;
    434     }
    435 
    436     case WM_FOCUSCHANGE:
    437         dprintf(("OS2: WM_FOCUSCHANGE %x", win32wnd->getWindowHandle()));
    438         goto RunDefWndProc;
    439 
    440330    case WM_SETFOCUS:
    441331    {
     
    464354    //**************************************************************************
    465355    case WM_BUTTON1DOWN:
    466         dprintf(("OS2: WM_BUTTON1DOWN %x", hwnd));
    467         point.x = (*(POINTS *)&mp1).x;
    468         point.y = (*(POINTS *)&mp1).y;
    469         ClientPoint.x = point.x;
    470         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    471         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    472         if(win32wnd->MsgButton(BUTTON_LEFTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    473                 goto RunDefWndProc;
    474         }
    475         break;
    476 
    477356    case WM_BUTTON1UP:
    478         dprintf(("OS2: WM_BUTTON1UP %x", hwnd));
    479         point.x = (*(POINTS *)&mp1).x;
    480         point.y = (*(POINTS *)&mp1).y;
    481         ClientPoint.x = point.x;
    482         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    483         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    484         if(win32wnd->MsgButton(BUTTON_LEFTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    485                 goto RunDefWndProc;
    486         }
    487         break;
    488357    case WM_BUTTON1DBLCLK:
    489         point.x = (*(POINTS *)&mp1).x;
    490         point.y = (*(POINTS *)&mp1).y;
    491         ClientPoint.x = point.x;
    492         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    493         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    494         if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    495                 goto RunDefWndProc;
    496         }
    497         break;
    498358    case WM_BUTTON2DOWN:
    499         point.x = (*(POINTS *)&mp1).x;
    500         point.y = (*(POINTS *)&mp1).y;
    501         ClientPoint.x = point.x;
    502         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    503         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    504         if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    505                 goto RunDefWndProc;
    506         }
    507         break;
    508359    case WM_BUTTON2UP:
    509         point.x = (*(POINTS *)&mp1).x;
    510         point.y = (*(POINTS *)&mp1).y;
    511         ClientPoint.x = point.x;
    512         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    513         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    514         if(win32wnd->MsgButton(BUTTON_RIGHTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    515                 goto RunDefWndProc;
    516         }
    517         break;
    518360    case WM_BUTTON2DBLCLK:
    519         point.x = (*(POINTS *)&mp1).x;
    520         point.y = (*(POINTS *)&mp1).y;
    521         ClientPoint.x = point.x;
    522         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    523         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    524         if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    525                 goto RunDefWndProc;
    526         }
    527         break;
    528361    case WM_BUTTON3DOWN:
    529         point.x = (*(POINTS *)&mp1).x;
    530         point.y = (*(POINTS *)&mp1).y;
    531         ClientPoint.x = point.x;
    532         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    533         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    534         if(win32wnd->MsgButton(BUTTON_MIDDLEDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    535                 goto RunDefWndProc;
    536         }
    537         break;
    538362    case WM_BUTTON3UP:
    539         point.x = (*(POINTS *)&mp1).x;
    540         point.y = (*(POINTS *)&mp1).y;
    541         ClientPoint.x = point.x;
    542         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    543         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    544         if(win32wnd->MsgButton(BUTTON_MIDDLEUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    545                 goto RunDefWndProc;
    546         }
    547         break;
    548363    case WM_BUTTON3DBLCLK:
    549         point.x = (*(POINTS *)&mp1).x;
    550         point.y = (*(POINTS *)&mp1).y;
    551         ClientPoint.x = point.x;
    552         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    553         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    554         if(win32wnd->MsgButton(BUTTON_MIDDLEDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     364        if(win32wnd->MsgButton(pWinMsg)) {
    555365                goto RunDefWndProc;
    556366        }
     
    570380    case WM_MOUSEMOVE:
    571381    {
    572         ULONG keystate = 0;
    573         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
    574             keystate |= WMMOVE_LBUTTON;
    575         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
    576             keystate |= WMMOVE_MBUTTON;
    577         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
    578             keystate |= WMMOVE_RBUTTON;
    579         if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
    580             keystate |= WMMOVE_SHIFT;
    581         if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
    582             keystate |= WMMOVE_CTRL;
    583 
    584382        //OS/2 Window coordinates -> Win32 Window coordinates
    585         win32wnd->MsgMouseMove(keystate, SHORT1FROMMP(mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(mp1)));
     383        win32wnd->MsgMouseMove(pWinMsg);
    586384        break;
    587385    }
    588386
    589387    case WM_CONTROL:
    590 
    591388    case WM_COMMAND:
    592         if(SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    593             win32wnd->MsgCommand(CMD_MENU, SHORT1FROMMP(mp1), 0);
    594         }
    595         if(SHORT1FROMMP(mp2) == CMDSRC_ACCELERATOR) {
    596             win32wnd->MsgCommand(CMD_ACCELERATOR, SHORT1FROMMP(mp1), 0);
    597         }
     389        dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
     390        win32wnd->DispatchMsg(pWinMsg);
    598391        //todo controls + accelerators
    599392        break;
     
    601394    case WM_SYSCOMMAND:
    602395    {
    603       ULONG x = 0, y = 0;
    604       ULONG win32sc;
    605 
    606         if(SHORT2FROMMP(mp2) == TRUE) {//syscommand caused by mouse action
    607             POINTL pointl;
    608             WinQueryPointerPos(HWND_DESKTOP, &pointl);
    609             x = pointl.x;
    610             y = ScreenHeight - y;
    611         }
    612         switch(SHORT1FROMMP(mp1)) {
    613         case SC_MOVE:
    614             win32sc = SC_MOVE_W;
    615             break;
    616         case SC_CLOSE:
    617             win32sc = SC_CLOSE_W;
    618             break;
    619         case SC_MAXIMIZE:
    620             win32sc = SC_MAXIMIZE_W;
    621             break;
    622         case SC_MINIMIZE:
    623             win32sc = SC_MINIMIZE_W;
    624             break;
    625         case SC_NEXTFRAME:
    626         case SC_NEXTWINDOW:
    627             win32sc = SC_NEXTWINDOW_W;
    628             break;
    629         case SC_RESTORE:
    630             win32sc = SC_RESTORE_W;
    631             break;
    632         case SC_TASKMANAGER:
    633             win32sc = SC_TASKLIST_W;
    634             break;
    635         default:
     396        if(win32wnd->DispatchMsg(pWinMsg)) {
    636397            goto RunDefWndProc;
    637398        }
    638         dprintf(("WM_SYSCOMMAND %x %x (%d,%d)", hwnd, win32sc, x, y));
    639         if(win32wnd->MsgSysCommand(win32sc, x, y)) {
    640             goto RunDefWndProc;
    641         }
    642399        break;
    643400    }
    644401    case WM_CHAR:
    645402    {
    646         THDB *thdb;
    647         ULONG repeatCount=0, virtualKey=0, keyFlags=0, scanCode=0;
    648         ULONG flags = SHORT1FROMMP(mp1);
    649         BOOL keyWasPressed, fTranslated = FALSE, fRunDefWndProc = FALSE;
    650 
    651         char c;
    652 
    653         repeatCount = CHAR3FROMMP(mp1);
    654         scanCode = CHAR4FROMMP(mp1);
    655         keyWasPressed = ((SHORT1FROMMP (mp1) & KC_PREVDOWN) == KC_PREVDOWN);
    656 
    657         dprintf(("PM: WM_CHAR: %x %x %d %x", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), repeatCount, scanCode));
    658         dprintf(("PM: WM_CHAR: %x", flags));
    659 
    660         // vitali add begin
    661         if ( ( SHORT1FROMMP(mp2) & 0x0FF ) == 0x0E0 )
    662         {
    663             // an extended key ( arrows, ins, del and so on )
    664             // get "virtual" scancode from character code cause
    665             // for "regular" keys they are equal
    666             scanCode = ( SHORT1FROMMP(mp2) >> 8) & 0x0FF;
    667         }
    668         // vitali add end
    669 
    670         // both WM_KEYUP & WM_KEYDOWN want a virtual key, find the right Win32 virtual key
    671         // given the OS/2 virtual key and OS/2 character
    672 
    673         //if (((SHORT1FROMMP (mp1) & KC_CHAR) == KC_CHAR) ||
    674         //    ((SHORT1FROMMP (mp1) & KC_LONEKEY) == KC_LONEKEY))
    675         c = 0;
    676         if ((SHORT1FROMMP (mp1) & 0xFF) != 0)
    677         {
    678             c = SHORT1FROMMP (mp2);
    679             if ((c >= 'A') && (c <= 'Z')) {
    680                 virtualKey = c;
    681                 goto VirtualKeyFound;
    682             }
    683             if ((c >='a') && (c <= 'z')) {
    684                 virtualKey = c - 32;   // make it uppercase
    685                 goto VirtualKeyFound;
    686             }
    687             if ((c >= '0') && (c <= '9')) {
    688                 virtualKey = c;
    689                 goto VirtualKeyFound;
    690             }
    691         }
    692 
    693         // convert OS/2 virtual keys to Win32 virtual key
    694         if (SHORT2FROMMP (mp2) <= VK_BLK2)
    695             virtualKey = virtualKeyTable [SHORT2FROMMP (mp2)];
    696 
    697 VirtualKeyFound:
    698         dprintf (("VIRTUALKEYFOUND:(%x)", virtualKey));
    699 
    700         if(!(SHORT1FROMMP(mp1) & KC_ALT))
    701         {
    702             //
    703             // the Alt key is not pressed
    704             //
    705             if ((flags & KC_KEYUP) == KC_KEYUP) {
    706                 // send WM_KEYUP message
    707 
    708                 if(win32wnd->MsgKeyUp (repeatCount, scanCode, virtualKey)) {
    709                     fRunDefWndProc = TRUE;
    710                 }
    711             }
    712             else {
    713                 // send WM_KEYDOWN message
    714                 if (win32wnd->MsgKeyDown (repeatCount, scanCode,
    715                                           virtualKey, keyWasPressed))
    716                     fRunDefWndProc = TRUE;
    717             }
    718         }
    719         else {
    720             //
    721             // the Alt key is pressed
    722             //
    723             if ((flags & KC_KEYUP) == KC_KEYUP) {
    724                 // send WM_SYSKEYUP message
    725 
    726                 dprintf(("PMWINDOW_WM_SYSKEYUP: vkey:(%x)", virtualKey));
    727                 if(win32wnd->MsgSysKeyUp (repeatCount, scanCode, virtualKey)) {
    728                     fRunDefWndProc = TRUE;
    729                 }
    730             }
    731             else {
    732                 // send WM_SYSKEYDOWN message
    733                 dprintf(("PMWINDOW_WM_SYSKEYDOWN: vkey:(%x)", virtualKey));
    734                 if (win32wnd->MsgSysKeyDown (repeatCount, scanCode, virtualKey, keyWasPressed))
    735                     fRunDefWndProc = TRUE;
    736             }
    737         }
    738 
    739         thdb = GetThreadTHDB();
    740         if(thdb) {
    741             fTranslated = thdb->fMsgTranslated;
    742             thdb->fMsgTranslated = FALSE;  //reset flag
    743         }
    744         //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
    745         //      the newly generated WM_CHAR message.
    746         if(fTranslated && !((flags & KC_KEYUP) == KC_KEYUP))
    747         {//TranslatedMessage was called before DispatchMessage, so send WM_CHAR messages
    748             ULONG keyflags = 0, vkey = 0;
    749             ULONG fl = SHORT1FROMMP(mp1);
    750             ULONG chCode = SHORT1FROMMP(mp2);
    751 
    752             if(!(fl & KC_CHAR)) {
    753 //SvL: Test
    754                 break;
    755 //                goto RunDefWndProc;
    756             }
    757             if(fl & KC_VIRTUALKEY) {
    758                 if(virtualKey)
    759                         vkey = virtualKey;
    760                 else    vkey = SHORT2FROMMP(mp2);
    761                 chCode = vkey;
    762             }
    763             if(fl & KC_KEYUP) {
    764                 keyflags |= KEY_UP;
    765             }
    766             if(fl & KC_ALT) {
    767                 keyflags |= KEY_ALTDOWN;
    768             }
    769             if(fl & KC_PREVDOWN) {
    770                 keyflags |= KEY_PREVDOWN;
    771             }
    772             if(fl & KC_DEADKEY) {
    773                 keyflags |= KEY_DEADKEY;
    774             }
    775             if(win32wnd->MsgChar(chCode, CHAR3FROMMP(mp1), CHAR4FROMMP(mp1), virtualKey, keyflags)) {
    776 //SvL: Test
    777 //                goto RunDefWndProc;
    778 
    779             }
    780         }
    781 //SvL: Test
    782 //        if(fRunDefWndProc) goto RunDefWndProc;
     403        win32wnd->DispatchMsg(pWinMsg);
    783404        break;
    784405    }
    785406
    786407    case WM_INITMENU:
    787         win32wnd->MsgInitMenu((HWND)mp2);
    788         break;
     408        win32wnd->MsgInitMenu(pWinMsg);
     409        break;
     410
     411    case WM_TIMER:
     412        win32wnd->DispatchMsg(pWinMsg);
     413        goto RunDefWndProc;
    789414
    790415    case WM_MENUSELECT:
    791416    case WM_MENUEND:
    792417    case WM_NEXTMENU:
    793         goto RunDefWndProc;
    794 
    795     case WM_TIMER:
    796         if (mp2)
    797         {
    798           BOOL sys;
    799           ULONG id;
    800 
    801           dprintf(("OS2: WM_TIMER %x %d", hwnd, mp1));
    802           if (TIMER_GetTimerInfo(hwnd,(ULONG)mp1,&sys,&id))
    803           {
    804             if (sys)
    805               win32wnd->MsgSysTimer(id);
    806             else
    807               win32wnd->MsgTimer(id);
    808           }
    809         }
    810418        goto RunDefWndProc;
    811419
     
    845453    }
    846454
    847     case WM_ERASEBACKGROUND:
    848     {
    849         dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
    850 #if 1
    851         break;
    852 #else
    853 
    854         if (WinQueryUpdateRect (hwnd, NULL) && !win32wnd->isSupressErase()) {
    855             BOOL erased = sendEraseBkgnd (win32wnd);
    856             win32wnd->setEraseBkgnd (!erased, !erased);
    857         }
    858 
    859         break;
    860 #endif
    861     }
    862 
    863455    case WM_PAINT:
    864     {
    865         dprintf(("OS2: WM_PAINT %x", hwnd));
    866 
    867 #if 0
    868         if (WinQueryUpdateRect (hwnd, NULL)) {
    869             if (!win32wnd->isSupressErase() && win32wnd->isEraseBkgnd()) {
    870                 BOOL erased = sendEraseBkgnd (win32wnd);
    871                 win32wnd->setEraseBkgnd (!erased, !erased);
    872             }
    873         }
    874 
    875         win32wnd->setSupressErase (FALSE);
    876 #endif
    877 
    878         win32wnd->MsgPaint(0, 0);
    879 
    880         //validate the update region, WM_PAINT has no return value
    881         goto RunDefWndProc;
    882     }
     456        win32wnd->DispatchMsg(pWinMsg);
     457        goto RunDefWndProc;
    883458
    884459    case WM_HITTEST:
    885       // Only send this message if the window is enabled
    886       if (WinIsWindowEnabled(hwnd))
    887       {
    888         OSLIBPOINT pt;
    889         dprintf(("USER32: WM_HITTEST (%d,%d)",(*(POINTS *)&mp1).x,(*(POINTS *)&mp1).y));
    890         pt.x = (*(POINTS *)&mp1).x;
    891         pt.y = (*(POINTS *)&mp1).y;
    892         MapOS2ToWin32Point( OSLIB_HWND_DESKTOP, hwnd, &pt);
    893         if(win32wnd->MsgHitTest(pt.x, pt.y))
     460        // Only send this message if the window is enabled
     461        if (WinIsWindowEnabled(hwnd))
    894462        {
    895           goto RunDefWndProc;
    896         }
    897       } else goto RunDefWndProc;
    898       break;
     463                if(win32wnd->MsgHitTest(pWinMsg)) {
     464                    goto RunDefWndProc;
     465                }
     466        }
     467        else    goto RunDefWndProc;
    899468
    900469    case WM_CONTEXTMENU:
    901       {
    902         POINTL pt;
    903 
    904         dprintf(("OS2: WM_CONTEXTMENU %x", hwnd));
    905         pt.x = (*(POINTS *)&mp1).x;
    906         pt.y = (*(POINTS *)&mp1).y;
    907         WinMapWindowPoints(hwnd,HWND_DESKTOP,&pt,1);
    908         pt.y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN)-pt.y-1;
    909         win32wnd->MsgContextMenu(pt.x,pt.y);
     470    {
     471        win32wnd->DispatchMsg(pWinMsg);
    910472
    911473        RestoreOS2TIB();
    912474        return (MRESULT)TRUE;
    913       }
     475    }
     476
     477    case WM_ERASEBACKGROUND:
     478    {
     479        dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
     480        break;
     481    }
     482
     483    case WM_SIZE:
     484    {
     485        dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
     486        break;
     487    }
     488    case WM_MINMAXFRAME:
     489    {
     490        dprintf(("OS2: WM_MINMAXFRAME"));
     491        break;
     492    }
     493    case WM_OWNERPOSCHANGE:
     494    {
     495        dprintf(("OS2: WM_OWNERPOSCHANGE"));
     496        goto RunDefWndProc;
     497    }
     498
     499    case WM_CALCVALIDRECTS:
     500    {
     501        dprintf(("OS2: WM_CALCVALIDRECTS"));
     502        goto RunDefWndProc;
     503    }
     504
     505    case WM_FOCUSCHANGE:
     506        dprintf(("OS2: WM_FOCUSCHANGE %x", win32wnd->getWindowHandle()));
     507        goto RunDefWndProc;
    914508
    915509    case WM_SYSCOLORCHANGE:
     
    934528    case WM_SEMANTICEVENT:
    935529    default:
    936 //        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
     530        //dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    937531        RestoreOS2TIB();
    938532        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  • trunk/src/user32/user32.cpp

    r2160 r2200  
    1 /* $Id: user32.cpp,v 1.62 1999-12-20 16:45:17 cbratschi Exp $ */
     1/* $Id: user32.cpp,v 1.63 1999-12-24 18:39:11 sandervl Exp $ */
    22
    33/*
     
    129129BOOL WIN32API InflateRect( PRECT lprc, int dx, int  dy)
    130130{
    131     dprintf(("USER32:  InflateRect\n"));
     131    dprintf2(("USER32:  InflateRect\n"));
    132132    if (!lprc)
    133133    {
     
    16221622//******************************************************************************
    16231623/*****************************************************************************
    1624  * Name      : int WIN32API GetWindowRgn
    1625  * Purpose   : The GetWindowRgn function obtains a copy of the window region of a window.
    1626  * Parameters: HWND hWnd handle to window whose window region is to be obtained
    1627  *             HRGN hRgn handle to region that receives a copy of the window region
    1628  * Variables :
    1629  * Result    : NULLREGION, SIMPLEREGION, COMPLEXREGION, ERROR
    1630  * Remark    :
    1631  * Status    : UNTESTED STUB
    1632  *
    1633  * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
    1634  *****************************************************************************/
    1635 
    1636 int WIN32API GetWindowRgn (HWND hWnd,
    1637                               HRGN hRgn)
    1638 {
    1639   dprintf(("USER32:GetWindowRgn (%08xh,%08x) not implemented.\n",
    1640          hWnd,
    1641          hRgn));
    1642   //Attention: Win32 hwnd handle!
    1643 
    1644   return (NULLREGION);
    1645 }
    1646 //******************************************************************************
    1647 //******************************************************************************
    1648 #if 0
    1649 BOOL WIN32API InvalidateRgn( HWND hWnd, HRGN hRgn, BOOL bErase)
    1650 {
    1651 #ifdef DEBUG
    1652     WriteLog("USER32:  InvalidateRgn\n");
    1653 #endif
    1654     hWnd = Win32Window::Win32ToOS2Handle(hWnd);
    1655 
    1656     return O32_InvalidateRgn(hWnd,hRgn,bErase);
    1657 }
    1658 #endif
    1659 /*****************************************************************************
    16601624 * Name      : BOOL WIN32API PaintDesktop
    16611625 * Purpose   : The PaintDesktop function fills the clipping region in the
     
    16781642  return (FALSE);
    16791643}
    1680 /*****************************************************************************
    1681  * Name      : int WIN32API SetWindowRgn
    1682  * Purpose   : The SetWindowRgn function sets the window region of a window. The
    1683  *             window region determines the area within the window where the
    1684  *             operating system permits drawing. The operating system does not
    1685  *             display any portion of a window that lies outside of the window region
    1686  * Parameters: HWND  hWnd    handle to window whose window region is to be set
    1687  *             HRGN  hRgn    handle to region
    1688  *             BOOL  bRedraw window redraw flag
    1689  * Variables :
    1690  * Result    : If the function succeeds, the return value is non-zero.
    1691  *             If the function fails, the return value is zero.
    1692  * Remark    :
    1693  * Status    : UNTESTED STUB
    1694  *
    1695  * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
    1696  *****************************************************************************/
    1697 
    1698 int WIN32API SetWindowRgn(HWND hWnd,
    1699                              HRGN hRgn,
    1700                              BOOL bRedraw)
    1701 {
    1702   dprintf(("USER32:SetWindowRgn (%08xh,%08xh,%u) not implemented.\n",
    1703          hWnd,
    1704          hRgn,
    1705          bRedraw));
    1706   //Attention: Win32 hwnd handle!
    1707 
    1708   return (0);
    1709 }
    1710 //******************************************************************************
    1711 //******************************************************************************
    1712 BOOL WIN32API ValidateRect( HWND hwnd, const RECT * lprc)
    1713 {
    1714 #ifdef DEBUG
    1715     WriteLog("USER32:  ValidateRect\n");
    1716 #endif
    1717     hwnd = Win32Window::Win32ToOS2Handle(hwnd);
    1718 
    1719     return O32_ValidateRect(hwnd,lprc);
    1720 }
    1721 //******************************************************************************
    1722 //******************************************************************************
    1723 BOOL WIN32API ValidateRgn( HWND hwnd, HRGN  hrgn)
    1724 {
    1725 #ifdef DEBUG
    1726     WriteLog("USER32:  ValidateRgn\n");
    1727 #endif
    1728     hwnd = Win32Window::Win32ToOS2Handle(hwnd);
    1729 
    1730     return O32_ValidateRgn(hwnd,hrgn);
    1731 }
    17321644
    17331645/* Filled Shape Functions */
     
    17691681    return O32_GetKeyboardType(nTypeFlag);
    17701682}
     1683
     1684/* Message and Message Queue Functions */
     1685
     1686
     1687/* Device Context Functions */
     1688
     1689
     1690/* Window Station and Desktop Functions */
    17711691/*****************************************************************************
    17721692 * Name      : HDESK WIN32API GetThreadDesktop
     
    17891709  return (NULL);
    17901710}
    1791 
    1792 /* Message and Message Queue Functions */
    1793 
    1794 
    1795 /* Device Context Functions */
    1796 
    1797 
    1798 /* Window Station and Desktop Functions */
    17991711
    18001712/*****************************************************************************
  • trunk/src/user32/win32dlg.cpp

    r2084 r2200  
    1 /* $Id: win32dlg.cpp,v 1.37 1999-12-16 00:11:46 sandervl Exp $ */
     1/* $Id: win32dlg.cpp,v 1.38 1999-12-24 18:39:11 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    293293        while (TRUE)
    294294        {
    295           if (!OSLibWinPeekMsg(&msg,0,0,0,MSG_NOREMOVE))
     295          if (!OSLibWinPeekMsg(&msg,0,0,0,PM_NOREMOVE))
    296296          {
    297297                if(!(getStyle() & DS_NOIDLEMSG))
     
    299299                OSLibWinGetMsg(&msg,0,0,0);
    300300          }
    301           else  OSLibWinPeekMsg(&msg,0,0,0,MSG_REMOVE);
     301          else  OSLibWinPeekMsg(&msg,0,0,0,PM_REMOVE);
    302302
    303303          if(msg.message == WM_QUIT)
     
    319319//                                       MSG_REMOVE, !(getStyle() & DS_NOIDLEMSG), NULL ))
    320320//            if(OSLibWinPeekMsg(&msg, topOwner->getOS2FrameWindowHandle(), 0, 0, MSG_REMOVE))
    321             if(OSLibWinPeekMsg(&msg, 0, 0, 0, MSG_REMOVE))
     321            if(OSLibWinPeekMsg(&msg, 0, 0, 0, PM_REMOVE))
    322322            {
    323323                if(msg.message == WM_QUIT) {
  • trunk/src/user32/win32wbase.cpp

    r2145 r2200  
    1 /* $Id: win32wbase.cpp,v 1.116 1999-12-19 19:55:41 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.117 1999-12-24 18:39:12 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    778778{
    779779  if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) {
    780     dprintf(("Win32BaseWindow::MsgClose, app handles msg"));
     780        dprintf(("Win32BaseWindow::MsgClose, app handles msg"));
    781781        return 0; //app handles this message
    782782  }
     
    872872//******************************************************************************
    873873//******************************************************************************
    874 ULONG Win32BaseWindow::MsgMove(ULONG x, ULONG y)
    875 {
    876     dprintf(("MsgMove to (%d,%d)", x, y));
    877     if(fNoSizeMsg || (getParent() && getParent()->InMovingChildren()))
    878         return 1;
    879 
    880     return SendInternalMessageA(WM_MOVE, 0, MAKELONG((USHORT)x, (USHORT)y));
    881 }
    882 //******************************************************************************
    883 //******************************************************************************
    884874#if 0
    885875ULONG Win32BaseWindow::MsgMinMax()
     
    888878}
    889879#endif
    890 //******************************************************************************
    891 //******************************************************************************
    892 ULONG Win32BaseWindow::MsgTimer(ULONG TimerID)
    893 {
    894   // TODO: call TIMERPROC if not NULL
    895   return SendInternalMessageA(WM_TIMER, TimerID, 0);
    896 }
    897 //******************************************************************************
    898 //******************************************************************************
    899 ULONG Win32BaseWindow::MsgSysTimer(ULONG TimerID)
    900 {
    901   // TODO: call TIMERPROC if not NULL
    902   return SendInternalMessageA(WM_SYSTIMER, TimerID, 0);
    903 }
    904880//******************************************************************************
    905881//******************************************************************************
     
    912888//******************************************************************************
    913889//******************************************************************************
    914 ULONG Win32BaseWindow::MsgCommand(ULONG cmd, ULONG Id, HWND hwnd)
    915 {
    916   switch(cmd) {
    917     case CMD_MENU:
    918         return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
    919     case CMD_CONTROL:
    920         return 0; //todo
    921     case CMD_ACCELERATOR:
    922         // this fit not really windows behavior.
    923         // maybe TranslateAccelerator() is better
    924         dprintf(("accelerator command"));
    925         return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
    926   }
    927   return 0;
    928 }
    929 //******************************************************************************
    930 //******************************************************************************
    931 ULONG Win32BaseWindow::MsgHitTest(ULONG x, ULONG y)
    932 {
    933   lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)x, (USHORT)y));
    934   dprintf(("MsgHitTest returned %x", lastHitTestVal));
     890ULONG Win32BaseWindow::MsgHitTest(MSG *msg)
     891{
     892  lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)msg->pt.x, (USHORT)msg->pt.y));
     893  dprintf2(("MsgHitTest returned %x", lastHitTestVal));
    935894  return 1; //TODO: May need to change this
    936 }
    937 //******************************************************************************
    938 //TODO: Send WM_NCCALCSIZE message here and correct size if necessary
    939 //******************************************************************************
    940 ULONG Win32BaseWindow::MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize)
    941 {
    942  WORD fwSizeType = 0;
    943 
    944     dwStyle &= ~(WS_MINIMIZE|WS_MAXIMIZE);
    945     if(fMinimize) {
    946             fwSizeType = SIZE_MINIMIZED;
    947             dwStyle |= WS_MINIMIZE;
    948     }
    949     else
    950     if(fMaximize) {
    951             fwSizeType = SIZE_MAXIMIZED;
    952             dwStyle |= WS_MAXIMIZE;
    953     }
    954     else    fwSizeType = SIZE_RESTORED;
    955 
    956     return SendInternalMessageA(WM_SIZE, fwSizeType, MAKELONG((USHORT)width, (USHORT)height));
    957895}
    958896//******************************************************************************
     
    981919    }
    982920    return rc;
    983 }
    984 //******************************************************************************
    985 //******************************************************************************
    986 ULONG Win32BaseWindow::MsgSysCommand(ULONG win32sc, ULONG x, ULONG y)
    987 {
    988     return SendInternalMessageA(WM_SYSCOMMAND, win32sc, MAKELONG((USHORT)x, (USHORT)y));
    989921}
    990922//******************************************************************************
     
    1011943}
    1012944//******************************************************************************
    1013 //TODO: virtual key & (possibly) scancode translation, extended keyboard bit & Unicode
    1014 //******************************************************************************
    1015 ULONG Win32BaseWindow::MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags)
    1016 {
    1017  ULONG lParam = 0;
    1018 
    1019     lParam  = repeatcnt;
    1020     lParam |= (scancode << 16);
    1021     setExtendedKey(vkey, &lParam);
    1022 
    1023     if(keyflags & KEY_ALTDOWN)
    1024         lParam |= (1<<29);
    1025     if(keyflags & KEY_PREVDOWN)
    1026         lParam |= (1<<30);
    1027     if(keyflags & KEY_UP)
    1028         lParam |= (1<<31);
    1029     if(keyflags & KEY_DEADKEY) {
    1030         dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
    1031         return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
    1032     }
    1033     else {
    1034         dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
    1035         return SendInternalMessageA(WM_CHAR, cmd, lParam);
    1036     }
    1037 }
    1038 //******************************************************************************
    1039 //******************************************************************************
    1040 ULONG Win32BaseWindow::MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey)
    1041 {
    1042   ULONG lParam=0;
    1043 
    1044     lParam = repeatCount & 0x0FFFF;                 // bit 0-15, repeatcount
    1045     lParam |= (scancode & 0x0FF) << 16;             // bit 16-23, scancode
    1046                                                     // bit 24, 1=extended key
    1047                                                     // bit 25-28, reserved
    1048     lParam |= 0 << 29;                              // bit 29, key is released, always 0 for WM_KEYUP ?? <- conflict according to the MS docs
    1049     lParam |= 1 << 30;                              // bit 30, previous state, always 1 for a WM_KEYUP message
    1050     lParam |= 1 << 31;                              // bit 31, transition state, always 1 for WM_KEYUP
    1051 
    1052     dprintf(("WM_KEYUP: vkey:(%x) param:(%x)", virtualKey, lParam));
    1053 
    1054     setExtendedKey(virtualKey, &lParam);
    1055     return SendInternalMessageA (WM_KEYUP, virtualKey, lParam);
    1056 }
    1057 //******************************************************************************
    1058 //******************************************************************************
    1059 ULONG Win32BaseWindow::MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed)
    1060 {
    1061   ULONG lParam=0;
    1062 
    1063     lParam = repeatCount & 0x0FFFF;                 // bit 0-15, repeatcount
    1064     lParam |= (scancode & 0x0FF) << 16;             // bit 16-23, scancode
    1065                                                     // bit 24, 1=extended key
    1066                                                     // bit 25-28, reserved
    1067                                                     // bit 29, key is pressed, always 0 for WM_KEYDOWN ?? <- conflict according to the MS docs
    1068     if (keyWasPressed)
    1069         lParam |= 1 << 30;                          // bit 30, previous state, 1 means key was pressed
    1070                                                     // bit 31, transition state, always 0 for WM_KEYDOWN
    1071 
    1072     setExtendedKey(virtualKey, &lParam);
    1073 
    1074     dprintf(("WM_KEYDOWN: vkey:(%x) param:(%x)", virtualKey, lParam));
    1075 
    1076     return SendInternalMessageA (WM_KEYDOWN, virtualKey, lParam);
    1077 }
    1078 //******************************************************************************
    1079 //******************************************************************************
    1080 ULONG Win32BaseWindow::MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey)
    1081 {
    1082   ULONG lParam=0;
    1083 
    1084     lParam = repeatCount & 0x0FFFF;                 // bit 0-15,repeatcount
    1085     lParam |= (scancode & 0x0FF) << 16;             // bit 16-23, scancode
    1086                                                     // bit 24, 1=extended key
    1087                                                     // bit 25-28, reserved
    1088     lParam |= 0 << 29;                              // bit 29, key is released, always 1 for WM_SYSKEYUP ?? <- conflict according to the MS docs
    1089     lParam |= 1 << 30;                              // bit 30, previous state, always 1 for a WM_KEYUP message
    1090     lParam |= 1 << 31;                              // bit 31, transition state, always 1 for WM_KEYUP
    1091 
    1092     setExtendedKey(virtualKey, &lParam);
    1093     dprintf(("WM_SYSKEYUP: vkey:(%x) param:(%x)", virtualKey, lParam));
    1094 
    1095     return SendInternalMessageA (WM_SYSKEYUP, virtualKey, lParam);
    1096 }
    1097 //******************************************************************************
    1098 //******************************************************************************
    1099 ULONG Win32BaseWindow::MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed)
    1100 {
    1101  ULONG lParam=0;
    1102 
    1103     lParam = repeatCount & 0x0FFFF;                 // bit 0-15, repeatcount
    1104     lParam |= (scancode & 0x0FF) << 16;             // bit 16-23, scancode
    1105                                                     // bit 24, 1=extended key
    1106                                                     // bit 25-28, reserved
    1107                                                     // bit 29, key is released, always 1 for WM_SYSKEYUP ?? <- conflict according to the MS docs
    1108     if (keyWasPressed)
    1109         lParam |= 1 << 30;                          // bit 30, previous state, 1 means key was pressed
    1110                                                     // bit 31, transition state, always 0 for WM_KEYDOWN
    1111 
    1112     setExtendedKey(virtualKey, &lParam);
    1113     dprintf(("WM_SYSKEYDOWN: vkey:(%x) param:(%x)", virtualKey, lParam));
    1114 
    1115     return SendInternalMessageA (WM_SYSKEYDOWN, virtualKey, lParam);
     945//******************************************************************************
     946ULONG Win32BaseWindow::DispatchMsg(MSG *msg)
     947{
     948    return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
    1116949}
    1117950//******************************************************************************
     
    1129962//******************************************************************************
    1130963//******************************************************************************
    1131 ULONG Win32BaseWindow::MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly)
    1132 {
    1133  ULONG win32msg;
    1134  ULONG win32ncmsg;
     964ULONG Win32BaseWindow::MsgButton(MSG *msg)
     965{
    1135966 BOOL  fClick = FALSE;
    1136967
    1137     if(ISMOUSE_CAPTURED()) {
    1138     if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, ncx, ncy, msg))
    1139         return 0;
    1140     }
    1141 
    1142     dprintf(("MsgButton to (%d,%d)", ncx, ncy));
    1143     switch(msg) {
    1144         case BUTTON_LEFTDOWN:
    1145                 win32msg = WM_LBUTTONDOWN;
    1146                 win32ncmsg = WM_NCLBUTTONDOWN;
     968    dprintf(("MsgButton at (%d,%d)", msg->pt.x, msg->pt.y));
     969    switch(msg->message) { //TODO: double click also?
     970        case WM_LBUTTONDBLCLK:
     971        case WM_RBUTTONDBLCLK:
     972        case WM_MBUTTONDBLCLK:
     973                if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS))
     974                {
     975                    msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
     976                    MsgButton(msg);
     977                    return MsgButton(msg);
     978                }
     979                break;
     980        case WM_LBUTTONDOWN:
     981        case WM_RBUTTONDOWN:
     982        case WM_MBUTTONDOWN:
    1147983                fClick = TRUE;
    1148984                break;
    1149         case BUTTON_LEFTUP:
    1150                 win32msg = WM_LBUTTONUP;
    1151                 win32ncmsg = WM_NCLBUTTONUP;
    1152                 break;
    1153         case BUTTON_LEFTDBLCLICK:
    1154                 if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
    1155                 {
    1156                   win32msg = WM_LBUTTONDBLCLK;
    1157                   win32ncmsg = WM_NCLBUTTONDBLCLK;
    1158                 } else
    1159                 {
    1160                   MsgButton(BUTTON_LEFTDOWN,ncx,ncy,clx,cly);
    1161                   return MsgButton(BUTTON_LEFTUP,ncx,ncy,clx,cly);
    1162                 }
    1163                 break;
    1164         case BUTTON_RIGHTUP:
    1165                 win32msg = WM_RBUTTONUP;
    1166                 win32ncmsg = WM_NCRBUTTONUP;
    1167                 break;
    1168         case BUTTON_RIGHTDOWN:
    1169                 win32msg = WM_RBUTTONDOWN;
    1170                 win32ncmsg = WM_NCRBUTTONDOWN;
    1171                 fClick = TRUE;
    1172                 break;
    1173         case BUTTON_RIGHTDBLCLICK:
    1174                 if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
    1175                 {
    1176                   win32msg = WM_RBUTTONDBLCLK;
    1177                   win32ncmsg = WM_NCRBUTTONDBLCLK;
    1178                 } else
    1179                 {
    1180                   MsgButton(BUTTON_RIGHTDOWN,ncx,ncy,clx,cly);
    1181                   return MsgButton(BUTTON_RIGHTUP,ncx,ncy,clx,cly);
    1182                 }
    1183                 break;
    1184         case BUTTON_MIDDLEUP:
    1185                 win32msg = WM_MBUTTONUP;
    1186                 win32ncmsg = WM_NCMBUTTONUP;
    1187                 break;
    1188         case BUTTON_MIDDLEDOWN:
    1189                 win32msg = WM_MBUTTONDOWN;
    1190                 win32ncmsg = WM_NCMBUTTONDOWN;
    1191                 fClick = TRUE;
    1192                 break;
    1193         case BUTTON_MIDDLEDBLCLICK:
    1194                 if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
    1195                 {
    1196                   win32msg = WM_MBUTTONDBLCLK;
    1197                   win32ncmsg = WM_NCMBUTTONDBLCLK;
    1198                 } else
    1199                 {
    1200                   MsgButton(BUTTON_MIDDLEDOWN,ncx,ncy,clx,cly);
    1201                   return MsgButton(BUTTON_MIDDLEUP,ncx,ncy,clx,cly);
    1202                 }
    1203                 break;
    1204         default:
    1205                 dprintf(("Win32BaseWindow::Button: invalid msg!!!!"));
    1206                 return 1;
     985    }
     986
     987    if(ISMOUSE_CAPTURED())
     988    {
     989        if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, msg->pt.x, msg->pt.y))
     990            return 0;
    1207991    }
    1208992
     
    12241008        {
    12251009                LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop,
    1226                                                 MAKELONG( HTCLIENT, win32msg ) );
     1010                                                MAKELONG( HTCLIENT, msg->message) );
    12271011
    12281012#if 0
     
    12381022    }
    12391023
    1240     SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, win32ncmsg));
    1241 
    1242     //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
    1243     if(lastHitTestVal != HTCLIENT) {
    1244             return SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
    1245     }
    1246     return  SendInternalMessageA(win32msg, 0, MAKELONG(clx, cly));
    1247 }
    1248 //******************************************************************************
    1249 //******************************************************************************
    1250 ULONG Win32BaseWindow::MsgMouseMove(ULONG keystate, ULONG x, ULONG y)
    1251 {
    1252  ULONG winstate = 0;
    1253  ULONG setcursormsg = WM_MOUSEMOVE;
    1254 
    1255     if(ISMOUSE_CAPTURED()) {
    1256         POINT point = {x,y};
    1257 
    1258         MapWindowPoints(getWindowHandle(), HWND_DESKTOP, &point, 1);
    1259         if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, point.x, point.y, keystate))
    1260             return 0;
    1261     }
    1262 
    1263     if(keystate & WMMOVE_LBUTTON)
    1264         winstate |= MK_LBUTTON;
    1265     if(keystate & WMMOVE_RBUTTON)
    1266         winstate |= MK_RBUTTON;
    1267     if(keystate & WMMOVE_MBUTTON)
    1268         winstate |= MK_MBUTTON;
    1269     if(keystate & WMMOVE_SHIFT)
    1270         winstate |= MK_SHIFT;
    1271     if(keystate & WMMOVE_CTRL)
    1272         winstate |= MK_CONTROL;
    1273 
    1274     if(lastHitTestVal != HTCLIENT) {
    1275         setcursormsg = WM_NCMOUSEMOVE;
    1276     }
    1277     //TODO: hiword should be 0 if window enters menu mode (SDK docs)
    1278     SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, setcursormsg));
    1279 
    1280     //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
    1281     if(lastHitTestVal != HTCLIENT) {
    1282             SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y));
    1283     }
    1284     return  SendInternalMessageA(WM_MOUSEMOVE, winstate, MAKELONG(x, y));
    1285 }
    1286 //******************************************************************************
    1287 //TODO: Depending on menu type, we should send WM_INITMENU or WM_INITPOPUPMENU
    1288 //TODO: PM sends it for each submenu that gets activated; Windows only for the first
    1289 //      submenu; once the menu bar is active, moving the cursor doesn't generate other
    1290 //      WM_INITMENU msgs. Not really a problem, but might need to fix this later on.
    1291 //******************************************************************************
    1292 void Win32BaseWindow::MsgInitMenu(HWND hMenu)
    1293 {
    1294     SendInternalMessageA(WM_INITMENU, (WPARAM)hMenu, 0);
     1024    SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
     1025
     1026    return  SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
    12951027}
    12961028//******************************************************************************
     
    13221054        O32_ReleaseDC(OS2Hwnd, hdcErase);
    13231055    return (rc);
     1056}
     1057//******************************************************************************
     1058//******************************************************************************
     1059ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
     1060{
     1061    if(ISMOUSE_CAPTURED()) {
     1062        if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, msg->pt.x, msg->pt.y))
     1063            return 0;
     1064    }
     1065
     1066    //TODO: hiword should be 0 if window enters menu mode (SDK docs)
     1067    SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
     1068
     1069    //translated message == WM_(NC)MOUSEMOVE
     1070    return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
     1071}
     1072//******************************************************************************
     1073//TODO: Depending on menu type, we should send WM_INITMENU or WM_INITPOPUPMENU
     1074//TODO: PM sends it for each submenu that gets activated; Windows only for the first
     1075//      submenu; once the menu bar is active, moving the cursor doesn't generate other
     1076//      WM_INITMENU msgs. Not really a problem, but might need to fix this later on.
     1077//******************************************************************************
     1078ULONG Win32BaseWindow::MsgInitMenu(MSG *msg)
     1079{
     1080    return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
     1081}
     1082//******************************************************************************
     1083//******************************************************************************
     1084ULONG Win32BaseWindow::MsgNCPaint()
     1085{
     1086    return SendInternalMessageA(WM_PAINT, 0, 0);
    13241087}
    13251088//******************************************************************************
     
    16041367    {
    16051368    case WM_CLOSE:
     1369    dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
    16061370        DestroyWindow();
    16071371        return 0;
  • trunk/src/user32/win32wbase.h

    r2140 r2200  
    1 /* $Id: win32wbase.h,v 1.55 1999-12-19 17:46:26 cbratschi Exp $ */
     1/* $Id: win32wbase.h,v 1.56 1999-12-24 18:39:12 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    7171         ULONG  MsgPosChanging(LPARAM lp);
    7272         ULONG  MsgPosChanged(LPARAM lp);
    73          ULONG  MsgMove(ULONG x, ULONG y);
    74          ULONG  MsgHitTest(ULONG x, ULONG y);
    75          ULONG  MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
    7673virtual  ULONG  MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
    7774         ULONG  MsgSetFocus(HWND hwnd);
    7875         ULONG  MsgKillFocus(HWND hwnd);
    79          ULONG  MsgTimer(ULONG TimerID);
    80          ULONG  MsgSysTimer(ULONG TimerID);
    8176         ULONG  MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
    82          ULONG  MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
    83          ULONG  MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
    84          ULONG  MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
    85          ULONG  MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
    86          ULONG  MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
    87          ULONG  MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
    88          ULONG  MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
    89          ULONG  MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
    90          ULONG  MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
     77         ULONG  MsgButton(MSG *msg);
     78         ULONG  MsgMouseMove(MSG *msg);
    9179         ULONG  MsgPaint(ULONG tmp1, BOOL select = TRUE);
    9280         ULONG  MsgEraseBackGround(HDC hdc);
     81         ULONG  MsgInitMenu(MSG *msg);
     82         ULONG  MsgHitTest(MSG *msg);
     83         ULONG  MsgNCPaint();
     84         ULONG  DispatchMsg(MSG *msg);
     85
    9386         ULONG  MsgSetText(LPSTR lpsz, LONG cch);
    9487         ULONG  MsgGetTextLength();
    9588         char  *MsgGetText();
    9689         ULONG  MsgContextMenu(ULONG x,ULONG y);
    97          void   MsgInitMenu(HWND hMenu);
    9890         VOID   updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
    9991
     
    366358        else    return SendInternalMessageA(msg, wParam, lParam);
    367359     }
     360#else
     361friend BOOL  OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
    368362#endif
    369363
     
    394388};
    395389
    396 
    397 #define BUTTON_LEFTDOWN         0
    398 #define BUTTON_LEFTUP           1
    399 #define BUTTON_LEFTDBLCLICK     2
    400 #define BUTTON_RIGHTUP          3
    401 #define BUTTON_RIGHTDOWN        4
    402 #define BUTTON_RIGHTDBLCLICK    5
    403 #define BUTTON_MIDDLEUP         6
    404 #define BUTTON_MIDDLEDOWN       7
    405 #define BUTTON_MIDDLEDBLCLICK   8
    406 
    407390#define WMMOVE_LBUTTON          1
    408391#define WMMOVE_MBUTTON          2
     
    411394#define WMMOVE_SHIFT            16
    412395
    413 
    414 #define CMD_MENU                1
    415 #define CMD_CONTROL             2
    416 #define CMD_ACCELERATOR         3
    417 
    418 #define KEY_ALTDOWN             1
    419 #define KEY_PREVDOWN            2
    420 #define KEY_UP                  4
    421 #define KEY_DEADKEY             8
    422 
    423396#endif //__cplusplus
    424397
  • trunk/src/user32/window.cpp

    r2114 r2200  
    1 /* $Id: window.cpp,v 1.43 1999-12-18 16:31:52 cbratschi Exp $ */
     1/* $Id: window.cpp,v 1.44 1999-12-24 18:39:13 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    532532    if(!window) {
    533533        dprintf(("IsWindow, window %x not found", hwnd));
     534        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    534535        return FALSE;
    535536    }
     
    546547    if(!window) {
    547548        dprintf(("IsWindowEnabled, window %x not found", hwnd));
     549        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    548550        return 0;
    549551    }
     
    11831185HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
    11841186{
    1185         RECT rect;
    1186         HWND hWnd;
    1187         POINT framePt;
     1187  RECT rect;
     1188  HWND hWnd;
    11881189
    11891190        dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
     
    11961197        }
    11971198
    1198         MapWindowPoints(hwndParent,GetParent(hwndParent),&framePt,1);
    1199         if (PtInRect (&rect, framePt) == 0) {
     1199        ClientToScreen(hwndParent, &pt);
     1200        if (PtInRect (&rect, pt) == 0) {
    12001201                // point is outside window
    12011202                return NULL;
  • trunk/src/user32/windowmsg.cpp

    r2084 r2200  
    1 /* $Id: windowmsg.cpp,v 1.10 1999-12-16 00:11:49 sandervl Exp $ */
     1/* $Id: windowmsg.cpp,v 1.11 1999-12-24 18:39:13 sandervl Exp $ */
    22/*
    33 * Win32 window message APIs for OS/2
     
    2121#include <win.h>
    2222#include <heapstring.h>
     23#include <handlemanager.h>
    2324#include "oslibwin.h"
    2425#include "oslibmsg.h"
     
    4546//******************************************************************************
    4647//******************************************************************************
    47 BOOL WIN32API TranslateMessage( const MSG * arg1)
    48 {
    49 //    return O32_TranslateMessage(arg1);
    50    return TRUE;
     48BOOL WIN32API TranslateMessage( const MSG * msg)
     49{
     50   return OSLibWinTranslateMessage((MSG *)msg);
    5151}
    5252//******************************************************************************
     
    7070
    7171    fFoundMsg = OSLibWinPeekMsg(msg, 0, uMsgFilterMin, uMsgFilterMax,
    72                                 (fuRemoveMsg & PM_REMOVE) ? 1 : 0, FALSE);
     72                                fuRemoveMsg, FALSE);
    7373    if(fFoundMsg) {
    74         if (msg->message == WM_QUIT && (fuRemoveMsg & (PM_REMOVE))) {
     74        if (msg->message == WM_QUIT && (fuRemoveMsg & PM_REMOVE)) {
    7575            //TODO: Post WM_QUERYENDSESSION message when WM_QUIT received and system is shutting down
    7676        }
     
    991991{
    992992 DWORD queueStatus;
    993 
    994   dprintf(("USER32:GetInputState()"));
     993 BOOL  rc;
     994
    995995  queueStatus = OSLibWinQueryQueueStatus();
    996996
    997   return (queueStatus & (QS_KEY | QS_MOUSEBUTTON)) ? TRUE : FALSE;
     997  rc = (queueStatus & (QS_KEY | QS_MOUSEBUTTON)) ? TRUE : FALSE;
     998  dprintf(("USER32:GetInputState() returned %d", rc));
     999  return rc;
    9981000}
    9991001//******************************************************************************
     
    10321034        return WAIT_TIMEOUT;
    10331035  }
    1034   return O32_MsgWaitForMultipleObjects(nCount,pHandles,fWaitAll,dwMilliseconds,dwWakeMask);
    1035 }
     1036  //SvL: Call handlemanager function as we need to translate handles
     1037  return HMMsgWaitForMultipleObjects(nCount,pHandles,fWaitAll,dwMilliseconds,dwWakeMask);
     1038}
Note: See TracChangeset for help on using the changeset viewer.