Ignore:
Timestamp:
Jul 14, 1999, 11:05:59 PM (26 years ago)
Author:
cbratschi
Message:

several bugs fixed, RegisterClass works, CreateWindow on the way

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/pmwindow.cpp

    r300 r304  
    1 /* $Id: pmwindow.cpp,v 1.2 1999-07-14 08:35:35 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.3 1999-07-14 21:05:58 cbratschi Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    3636
    3737  if(!hab || !hmq) {
    38         dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
    39         return(FALSE);
     38        UINT error;
     39
     40        //CB: only fail on real error
     41        error = WinGetLastError(hab) & 0xFFFF; //error code
     42        if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
     43        {
     44          dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
     45          dprintf((" Error = %x",error));
     46          return(FALSE);
     47        } else
     48        {
     49          //CB: get queue handle (todo)
     50        }
    4051  }
    4152
     
    4657     CS_SIZEREDRAW,                     /* Class style                  */
    4758     8)) {
    48         dprintf(("WinRegisterClass Win32Window failed"));
    49         return(FALSE);
     59        dprintf(("WinRegisterClass Win32Window failed"));
     60        return(FALSE);
    5061   }
    5162
     
    6879
    6980  if(msg != WM_CREATE && win32wnd == NULL && magic != WIN32PM_MAGIC) {
    70         dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
    71         goto RunDefWndProc;
     81        dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
     82        goto RunDefWndProc;
    7283  }
    7384  switch( msg )
    74   {     
     85  {
    7586    case WM_CREATE:
    76         //Processing is done in after WinCreateWindow returns
    77         break;
    78        
     87        //Processing is done in after WinCreateWindow returns
     88        break;
     89
    7990    case WM_QUIT:
    80         if(win32wnd->MsgQuit()) {
    81                 goto RunDefWndProc;
    82         }
    83         break;
    84        
     91        if(win32wnd->MsgQuit()) {
     92                goto RunDefWndProc;
     93        }
     94        break;
     95
    8596    case WM_CLOSE:
    86         if(win32wnd->MsgClose()) {
    87                 goto RunDefWndProc;
    88         }
    89         break;
     97        if(win32wnd->MsgClose()) {
     98                goto RunDefWndProc;
     99        }
     100        break;
    90101
    91102    case WM_DESTROY:
    92         if(win32wnd->MsgDestroy()) {
    93                 goto RunDefWndProc;
    94         }
    95         break;
     103        if(win32wnd->MsgDestroy()) {
     104                goto RunDefWndProc;
     105        }
     106        break;
    96107
    97108    case WM_ENABLE:
    98         if(win32wnd->MsgEnable((ULONG)mp1)) {
    99                 goto RunDefWndProc;
    100         }
    101         break;
     109        if(win32wnd->MsgEnable((ULONG)mp1)) {
     110                goto RunDefWndProc;
     111        }
     112        break;
    102113
    103114    case WM_SHOW:
    104         if(win32wnd->MsgShow((ULONG)mp1)) {
    105                 goto RunDefWndProc;
    106         }
    107         break;
     115        if(win32wnd->MsgShow((ULONG)mp1)) {
     116                goto RunDefWndProc;
     117        }
     118        break;
    108119
    109120    case WM_MOVE:
     
    114125     ULONG  xScreen, yScreen, yParent, xParent;
    115126
    116         rc = WinQueryWindowRect(hwnd, &rectl);
    117         if(rc == TRUE) {
    118                 point.x = rectl.xLeft;
    119                 point.y = rectl.yBottom;
    120 
    121                 //If the window has a parent, calculate position relative to that window
    122                 if((hwndParent = WinQueryWindow(hwnd, QW_PARENT)) != WinQueryDesktopWindow(hab, NULLHANDLE)) {
    123                         rc = WinMapWindowPoints(hwnd, hwndParent, &point, 1);
    124                         if(rc == FALSE) {
    125                                 dprintf(("WM_MOVE: WinMapWindowPoints (parent) failed!"));
    126                                 break;
    127                         }
    128                         rc = WinQueryWindowRect(hwndParent, &rectl2);
    129                         if(rc == FALSE) {
    130                                 dprintf(("WM_MOVE: WinQueryWindowRect(HWND_DESKTOP, &rectl) failed!"));
    131                                 break;
    132                         }
    133                         yParent = point.x;
    134                         yParent = OS2TOWIN32POINT(rectl2.yTop - rectl2.yBottom, point.y);
    135                 }
    136                 else    xParent = yParent = -1;
    137 
    138                 point.x = rectl.xLeft;
    139                 point.y = rectl.yBottom;
    140 
    141                 rc = WinMapWindowPoints(hwnd, HWND_DESKTOP, &point, 1);
    142                 if(rc == FALSE) {
    143                         dprintf(("WM_MOVE: WinMapWindowPoints (desktop) failed!"));
    144                         break;
    145                 }
    146                 rc = WinQueryWindowRect(HWND_DESKTOP, &rectl);
    147                 if(rc == FALSE) {
    148                         dprintf(("WM_MOVE: WinQueryWindowRect(HWND_DESKTOP, &rectl) failed!"));
    149                         break;
    150                 }
    151                 xScreen = point.x;
    152                 yScreen = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, point.y);
    153 
    154                 if(win32wnd->MsgMove(xScreen, yScreen, xParent, yParent)) {
    155                         goto RunDefWndProc;
    156                 }
    157         }
    158         else {
    159                 dprintf(("WM_MOVE: WinQueryWindowRect failed!"));
    160         }
    161         break;
     127        rc = WinQueryWindowRect(hwnd, &rectl);
     128        if(rc == TRUE) {
     129                point.x = rectl.xLeft;
     130                point.y = rectl.yBottom;
     131
     132                //If the window has a parent, calculate position relative to that window
     133                if((hwndParent = WinQueryWindow(hwnd, QW_PARENT)) != WinQueryDesktopWindow(hab, NULLHANDLE)) {
     134                        rc = WinMapWindowPoints(hwnd, hwndParent, &point, 1);
     135                        if(rc == FALSE) {
     136                                dprintf(("WM_MOVE: WinMapWindowPoints (parent) failed!"));
     137                                break;
     138                        }
     139                        rc = WinQueryWindowRect(hwndParent, &rectl2);
     140                        if(rc == FALSE) {
     141                                dprintf(("WM_MOVE: WinQueryWindowRect(HWND_DESKTOP, &rectl) failed!"));
     142                                break;
     143                        }
     144                        yParent = point.x;
     145                        yParent = OS2TOWIN32POINT(rectl2.yTop - rectl2.yBottom, point.y);
     146                }
     147                else    xParent = yParent = -1;
     148
     149                point.x = rectl.xLeft;
     150                point.y = rectl.yBottom;
     151
     152                rc = WinMapWindowPoints(hwnd, HWND_DESKTOP, &point, 1);
     153                if(rc == FALSE) {
     154                        dprintf(("WM_MOVE: WinMapWindowPoints (desktop) failed!"));
     155                        break;
     156                }
     157                rc = WinQueryWindowRect(HWND_DESKTOP, &rectl);
     158                if(rc == FALSE) {
     159                        dprintf(("WM_MOVE: WinQueryWindowRect(HWND_DESKTOP, &rectl) failed!"));
     160                        break;
     161                }
     162                xScreen = point.x;
     163                yScreen = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, point.y);
     164
     165                if(win32wnd->MsgMove(xScreen, yScreen, xParent, yParent)) {
     166                        goto RunDefWndProc;
     167                }
     168        }
     169        else {
     170                dprintf(("WM_MOVE: WinQueryWindowRect failed!"));
     171        }
     172        break;
    162173    }
    163174
    164175    case WM_WINDOWPOSCHANGED:
    165176    {
    166         break;
     177        break;
    167178    }
    168179
    169180    case WM_ADJUSTWINDOWPOS:
    170181    {
    171 //      if(win32wnd->MsgWindowPosChanging(0, 0)) {
    172         break;
     182//      if(win32wnd->MsgWindowPosChanging(0, 0)) {
     183        break;
    173184    }
    174185
     
    177188     HPS hps;
    178189
    179         hps = WinGetPS(hwnd);
    180         if(win32wnd->MsgEraseBackGround((ULONG)hps))
     190        hps = WinGetPS(hwnd);
     191        if(win32wnd->MsgEraseBackGround((ULONG)hps))
    181192        {
    182                 /*
    183                  * Return TRUE to request PM to paint the window background
    184                  * in SYSCLR_WINDOW.
    185                  */
    186                 WinReleasePS(hps);
    187                 return (MRESULT)( TRUE );
    188         }
    189         WinReleasePS(hps);
    190         return (MRESULT) FALSE;
     193                /*
     194                 * Return TRUE to request PM to paint the window background
     195                 * in SYSCLR_WINDOW.
     196                 */
     197                WinReleasePS(hps);
     198                return (MRESULT)( TRUE );
     199        }
     200        WinReleasePS(hps);
     201        return (MRESULT) FALSE;
    191202    }
    192203    case WM_SIZE:
     
    194205     SWP swp;
    195206
    196         rc = WinQueryWindowPos(hwnd, &swp);
    197         if(rc == FALSE) {
    198                 dprintf(("WM_SIZE: WinQueryWindowPos failed!"));
    199                 break;
    200         }
    201         if(win32wnd->MsgSize(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2),
    202                                 (swp.fl & SWP_MINIMIZE) != 0,
    203                                 (swp.fl & SWP_MAXIMIZE) != 0)) 
     207        rc = WinQueryWindowPos(hwnd, &swp);
     208        if(rc == FALSE) {
     209                dprintf(("WM_SIZE: WinQueryWindowPos failed!"));
     210                break;
     211        }
     212        if(win32wnd->MsgSize(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2),
     213                                (swp.fl & SWP_MINIMIZE) != 0,
     214                                (swp.fl & SWP_MAXIMIZE) != 0))
    204215        {
    205                 goto RunDefWndProc;
    206         }
    207 
    208         break;
     216                goto RunDefWndProc;
     217        }
     218
     219        break;
    209220    }
    210221
     
    213224      HWND hwndActivate = (HWND)mp1;
    214225
    215         if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    216                 //another (non-win32) application's window
    217                 //set to NULL (allowed according to win32 SDK) to avoid problems
    218                 hwndActivate = NULL;
    219         }
    220         if(win32wnd->MsgActivate(1, hwndActivate)) {
    221                 goto RunDefWndProc;
    222         }
    223         break;
     226        if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     227                //another (non-win32) application's window
     228                //set to NULL (allowed according to win32 SDK) to avoid problems
     229                hwndActivate = NULL;
     230        }
     231        if(win32wnd->MsgActivate(1, hwndActivate)) {
     232                goto RunDefWndProc;
     233        }
     234        break;
    224235    }
    225236    case WM_FOCUSCHANGE:
    226         break;
     237        break;
    227238
    228239    case WM_SETFOCUS:
     
    230241      HWND hwndFocus = (HWND)mp1;
    231242
    232         if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    233                 //another (non-win32) application's window
    234                 //set to NULL (allowed according to win32 SDK) to avoid problems
    235                 hwndFocus = NULL;
    236         }
    237         if((ULONG)mp2 == TRUE) {
    238                 rc = win32wnd->MsgSetFocus(hwndFocus);
    239         }
    240         else    rc = win32wnd->MsgKillFocus(hwndFocus);
    241         if(rc) {
    242                 goto RunDefWndProc;
    243         }
    244         break;
     243        if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     244                //another (non-win32) application's window
     245                //set to NULL (allowed according to win32 SDK) to avoid problems
     246                hwndFocus = NULL;
     247        }
     248        if((ULONG)mp2 == TRUE) {
     249                rc = win32wnd->MsgSetFocus(hwndFocus);
     250        }
     251        else    rc = win32wnd->MsgKillFocus(hwndFocus);
     252        if(rc) {
     253                goto RunDefWndProc;
     254        }
     255        break;
    245256    }
    246257    //**************************************************************************
     
    248259    //**************************************************************************
    249260    case WM_BUTTON1DOWN:
    250         if(win32wnd->MsgButton(BUTTON_LEFTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    251                 goto RunDefWndProc;
    252         }
    253         break;
     261        if(win32wnd->MsgButton(BUTTON_LEFTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     262                goto RunDefWndProc;
     263        }
     264        break;
    254265    case WM_BUTTON1UP:
    255         if(win32wnd->MsgButton(BUTTON_LEFTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    256                 goto RunDefWndProc;
    257         }
    258         break;
     266        if(win32wnd->MsgButton(BUTTON_LEFTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     267                goto RunDefWndProc;
     268        }
     269        break;
    259270    case WM_BUTTON1DBLCLK:
    260         if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    261                 goto RunDefWndProc;
    262         }
    263         break;
     271        if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     272                goto RunDefWndProc;
     273        }
     274        break;
    264275    case WM_BUTTON2DOWN:
    265         if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    266                 goto RunDefWndProc;
    267         }
    268         break;
     276        if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     277                goto RunDefWndProc;
     278        }
     279        break;
    269280    case WM_BUTTON2UP:
    270         if(win32wnd->MsgButton(BUTTON_RIGHTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    271                 goto RunDefWndProc;
    272         }
    273         break;
     281        if(win32wnd->MsgButton(BUTTON_RIGHTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     282                goto RunDefWndProc;
     283        }
     284        break;
    274285    case WM_BUTTON2DBLCLK:
    275         if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    276                 goto RunDefWndProc;
    277         }
    278         break;
     286        if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     287                goto RunDefWndProc;
     288        }
     289        break;
    279290    case WM_BUTTON2MOTIONSTART:
    280291    case WM_BUTTON2MOTIONEND:
     
    289300    case WM_BUTTON3MOTIONEND:
    290301    case WM_BUTTON3CLICK:
    291         break;
     302        break;
    292303
    293304    case WM_MOUSEMOVE:
    294         break;
     305        break;
    295306
    296307    //**************************************************************************
     
    298309    //**************************************************************************
    299310    case WM_VSCROLL:
    300         break;
     311        break;
    301312    case WM_HSCROLL:
    302         break;
     313        break;
    303314
    304315    case WM_CONTROL:
    305         break;
     316        break;
    306317
    307318    case WM_COMMAND:
    308319    case WM_SYSCOMMAND:
    309         break;
     320        break;
    310321
    311322    case WM_CHAR:
    312         break;
     323        break;
    313324
    314325    case WM_INITMENU:
     
    316327    case WM_MENUEND:
    317328    case WM_NEXTMENU:
    318         break;
     329        break;
    319330
    320331    case WM_TIMER:
    321         break;
     332        break;
    322333
    323334    case WM_PAINT:
    324         if(win32wnd->MsgPaint(0, 0)) {
    325                 goto RunDefWndProc;
    326         }
    327         break;
     335        if(win32wnd->MsgPaint(0, 0)) {
     336                goto RunDefWndProc;
     337        }
     338        break;
    328339
    329340    case WM_SYSCOLORCHANGE:
    330341    case WM_SYSVALUECHANGED:
    331         break;
     342        break;
    332343
    333344    case WM_CALCVALIDRECTS:
     
    353364    case WM_SAVEAPPLICATION:
    354365    case WM_SEMANTICEVENT:
    355         break;
     366        break;
    356367    default:
    357         RestoreOS2TIB();       
    358         return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     368        RestoreOS2TIB();
     369        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    359370  }
    360   RestoreOS2TIB();     
     371  RestoreOS2TIB();
    361372  return (MRESULT)FALSE;
    362373
    363374RunDefWndProc:
    364   RestoreOS2TIB();     
     375  RestoreOS2TIB();
    365376  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    366377} /* End of Win32WindowProc */
Note: See TracChangeset for help on using the changeset viewer.