Changeset 300 for trunk/src


Ignore:
Timestamp:
Jul 14, 1999, 10:35:38 AM (26 years ago)
Author:
sandervl
Message:

Very preliminary code for Open32 replacement

Location:
trunk/src/user32/new
Files:
42 added
5 edited

Legend:

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

    r4 r300  
    1 /* $Id: pmwindow.cpp,v 1.1 1999-05-24 20:20:04 ktk Exp $ */
    2 
     1/* $Id: pmwindow.cpp,v 1.2 1999-07-14 08:35:35 sandervl Exp $ */
    32/*
    43 * Win32 Window Managment Code for OS/2
    54 *
    6  * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
     5 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
     6 *
     7 *
     8 * Project Odin Software License can be found in LICENSE.TXT
    79 *
    810 */
     
    1113
    1214#include <os2.h>                        /* PM header file               */
    13 #include "misc.h"
    14 #include "win32wnd.h"
    15 #include "win32dlg.h"
     15#include <os2wrap.h>
     16#include "win32type.h"
     17#include <wprocess.h>
     18#include <misc.h>
     19#include <win32wnd.h>
     20#include <win32dlg.h>
     21#include "pmwindow.h"
     22#include "oslibwin.h"
    1623
    1724HMQ  hmq = 0;                             /* Message queue handle         */
     
    1926
    2027MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
    21 MRESULT EXPENTRY Win32DialogProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2);
    22 
    23 //******************************************************************************
    24 //Initialize PM; create hab, message queue and register special Win32 window class
     28
     29//******************************************************************************
     30//Initialize PM; create hab, message queue and register special Win32 window classes
    2531//******************************************************************************
    2632BOOL InitPM()
     
    3642  if(!WinRegisterClass(                 /* Register window class        */
    3743     hab,                               /* Anchor block handle          */
    38      (PSZ)"Win32Window",                /* Window class name            */
     44     (PSZ)WIN32_STDCLASS,               /* Window class name            */
    3945     (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    4046     CS_SIZEREDRAW,                     /* Class style                  */
    41      4)) {
     47     8)) {
    4248        dprintf(("WinRegisterClass Win32Window failed"));
    4349        return(FALSE);
    4450   }
    4551
    46   if(!WinRegisterClass(                 /* Register window class        */
    47      hab,                               /* Anchor block handle          */
    48      (PSZ)"Win32Dialog",                /* Window class name            */
    49      (PFNWP)Win32DialogProc,            /* Address of window procedure  */
    50      CS_SIZEREDRAW,                     /* Class style                  */
    51      4)) {
    52         dprintf(("WinRegisterClass Win32Dialog failed"));
    53         return(FALSE);
    54    }
    55 
    5652   return(TRUE);
    5753} /* End of main */
     
    6157MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    6258{
    63  Win32Window *win32wnd = (Win32Window *)WinQueryWindowULong(hwnd, 0);
    64  MRESULT      rc;
    65 
     59 Win32Window  *win32wnd;
     60 ULONG         magic;
     61 APIRET        rc;
     62
     63  //Restore our FS selector
     64  SetWin32TIB();
     65
     66  win32wnd = (Win32Window *)WinQueryWindowULong(hwnd, OFFSET_WIN32WNDPTR);
     67  magic    = WinQueryWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
     68
     69  if(msg != WM_CREATE && win32wnd == NULL && magic != WIN32PM_MAGIC) {
     70        dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
     71        goto RunDefWndProc;
     72  }
    6673  switch( msg )
    67   {
     74  {     
    6875    case WM_CREATE:
    69         win32wnd = new Win32Window(hwnd, msg, mp1, mp2);
    70         if(win32wnd == NULL) {
    71                 dprintf(("new win32wnd failed!"));
    72         }
    73         if(WinSetWindowULong(hwnd, 0, (ULONG)win32wnd) == FALSE) {
    74                 dprintf(("WinSetWindowULong %X failed!!", hwnd));
    75         }
     76        //Processing is done in after WinCreateWindow returns
    7677        break;
    77 
     78       
     79    case WM_QUIT:
     80        if(win32wnd->MsgQuit()) {
     81                goto RunDefWndProc;
     82        }
     83        break;
     84       
     85    case WM_CLOSE:
     86        if(win32wnd->MsgClose()) {
     87                goto RunDefWndProc;
     88        }
     89        break;
     90
     91    case WM_DESTROY:
     92        if(win32wnd->MsgDestroy()) {
     93                goto RunDefWndProc;
     94        }
     95        break;
     96
     97    case WM_ENABLE:
     98        if(win32wnd->MsgEnable((ULONG)mp1)) {
     99                goto RunDefWndProc;
     100        }
     101        break;
     102
     103    case WM_SHOW:
     104        if(win32wnd->MsgShow((ULONG)mp1)) {
     105                goto RunDefWndProc;
     106        }
     107        break;
     108
     109    case WM_MOVE:
     110    {
     111     RECTL  rectl, rectl2;
     112     POINTL point;
     113     HWND   hwndParent;
     114     ULONG  xScreen, yScreen, yParent, xParent;
     115
     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;
     162    }
     163
     164    case WM_WINDOWPOSCHANGED:
     165    {
     166        break;
     167    }
     168
     169    case WM_ADJUSTWINDOWPOS:
     170    {
     171//      if(win32wnd->MsgWindowPosChanging(0, 0)) {
     172        break;
     173    }
     174
     175    case WM_ERASEBACKGROUND:
     176    {
     177     HPS hps;
     178
     179        hps = WinGetPS(hwnd);
     180        if(win32wnd->MsgEraseBackGround((ULONG)hps))
     181        {
     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;
     191    }
     192    case WM_SIZE:
     193    {
     194     SWP swp;
     195
     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))
     204        {
     205                goto RunDefWndProc;
     206        }
     207
     208        break;
     209    }
     210
     211    case WM_ACTIVATE:
     212    {
     213      HWND hwndActivate = (HWND)mp1;
     214
     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;
     224    }
     225    case WM_FOCUSCHANGE:
     226        break;
     227
     228    case WM_SETFOCUS:
     229    {
     230      HWND hwndFocus = (HWND)mp1;
     231
     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;
     245    }
     246    //**************************************************************************
     247    //Mouse messages
     248    //**************************************************************************
     249    case WM_BUTTON1DOWN:
     250        if(win32wnd->MsgButton(BUTTON_LEFTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     251                goto RunDefWndProc;
     252        }
     253        break;
     254    case WM_BUTTON1UP:
     255        if(win32wnd->MsgButton(BUTTON_LEFTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     256                goto RunDefWndProc;
     257        }
     258        break;
     259    case WM_BUTTON1DBLCLK:
     260        if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     261                goto RunDefWndProc;
     262        }
     263        break;
     264    case WM_BUTTON2DOWN:
     265        if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     266                goto RunDefWndProc;
     267        }
     268        break;
     269    case WM_BUTTON2UP:
     270        if(win32wnd->MsgButton(BUTTON_RIGHTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     271                goto RunDefWndProc;
     272        }
     273        break;
     274    case WM_BUTTON2DBLCLK:
     275        if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     276                goto RunDefWndProc;
     277        }
     278        break;
     279    case WM_BUTTON2MOTIONSTART:
     280    case WM_BUTTON2MOTIONEND:
     281    case WM_BUTTON2CLICK:
     282    case WM_BUTTON1MOTIONSTART:
     283    case WM_BUTTON1MOTIONEND:
     284    case WM_BUTTON1CLICK:
     285    case WM_BUTTON3DOWN:
     286    case WM_BUTTON3UP:
     287    case WM_BUTTON3DBLCLK:
     288    case WM_BUTTON3MOTIONSTART:
     289    case WM_BUTTON3MOTIONEND:
     290    case WM_BUTTON3CLICK:
     291        break;
     292
     293    case WM_MOUSEMOVE:
     294        break;
     295
     296    //**************************************************************************
     297    //Slider messages
     298    //**************************************************************************
     299    case WM_VSCROLL:
     300        break;
     301    case WM_HSCROLL:
     302        break;
     303
     304    case WM_CONTROL:
     305        break;
     306
     307    case WM_COMMAND:
     308    case WM_SYSCOMMAND:
     309        break;
     310
     311    case WM_CHAR:
     312        break;
     313
     314    case WM_INITMENU:
     315    case WM_MENUSELECT:
     316    case WM_MENUEND:
     317    case WM_NEXTMENU:
     318        break;
     319
     320    case WM_TIMER:
     321        break;
     322
     323    case WM_PAINT:
     324        if(win32wnd->MsgPaint(0, 0)) {
     325                goto RunDefWndProc;
     326        }
     327        break;
     328
     329    case WM_SYSCOLORCHANGE:
     330    case WM_SYSVALUECHANGED:
     331        break;
     332
     333    case WM_CALCVALIDRECTS:
     334    case WM_SETWINDOWPARAMS:
     335    case WM_QUERYWINDOWPARAMS:
     336    case WM_HITTEST:
     337    case WM_SETSELECTION:
     338    case WM_PPAINT:
     339    case WM_PSETFOCUS:
     340    case WM_PSYSCOLORCHANGE:
     341    case WM_PSIZE:
     342    case WM_PACTIVATE:
     343    case WM_PCONTROL:
     344    case WM_HELP:
     345    case WM_APPTERMINATENOTIFY:
     346    case WM_PRESPARAMCHANGED:
     347    case WM_DRAWITEM:
     348    case WM_MEASUREITEM:
     349    case WM_CONTROLPOINTER:
     350    case WM_QUERYDLGCODE:
     351    case WM_SUBSTITUTESTRING:
     352    case WM_MATCHMNEMONIC:
     353    case WM_SAVEAPPLICATION:
     354    case WM_SEMANTICEVENT:
     355        break;
    78356    default:
    79       /*
    80        * Everything else comes here.  This call MUST exist
    81        * in your window procedure.
    82        */
    83         if(win32wnd == NULL) {
    84                 dprintf(("Win32WindowProc: win32wnd NULL!"));
    85                 return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    86         }
    87 
    88         if(win32wnd->ProcessMessage(hwnd, msg, mp1, mp2, &rc) == TRUE) {
    89                 return(rc);
    90         }
    91         return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     357        RestoreOS2TIB();       
     358        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    92359  }
     360  RestoreOS2TIB();     
    93361  return (MRESULT)FALSE;
     362
     363RunDefWndProc:
     364  RestoreOS2TIB();     
     365  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    94366} /* End of Win32WindowProc */
    95367//******************************************************************************
    96 //Win32 dialog message handler
    97 //******************************************************************************
    98 MRESULT EXPENTRY Win32DialogProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
    99 {
    100  Win32Dialog *win32dlg = (Win32Dialog *)WinQueryWindowULong(hwndDlg, 0);
    101  MRESULT      rc;
    102 
    103   switch(msg)
    104   {
    105     case WM_INITDLG:
    106         win32dlg = new Win32Dialog(hwndDlg, msg, mp1, mp2);
    107         if(win32dlg == NULL) {
    108                 dprintf(("new win32dlg failed!"));
    109         }
    110         if(WinSetWindowULong(hwndDlg, 0, (ULONG)win32dlg) == FALSE) {
    111                 dprintf(("WinSetWindowULong %X failed!!", hwndDlg));
    112         }
    113         break;
    114 
    115     default:
    116       /*
    117        * Any event messages that the dialog procedure has not processed
    118        * come here and are processed by WinDefDlgProc.
    119        * This call MUST exist in your dialog procedure.
    120        */
    121         if(win32dlg == NULL) {
    122                 dprintf(("Win32DialogProc: win32dlg NULL!"));
    123                 return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
    124         }
    125         if(win32dlg->ProcessDlgMessage(hwndDlg, msg, mp1, mp2, &rc) == TRUE) {
    126                 return(rc);
    127         }
    128         return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
    129   }
    130   return (MRESULT) FALSE;
    131 }
    132 //******************************************************************************
    133 //******************************************************************************
     368//******************************************************************************
  • trunk/src/user32/new/win32class.cpp

    r4 r300  
    1 /* $Id: win32class.cpp,v 1.1 1999-05-24 20:20:04 ktk Exp $ */
    2 
     1/* $Id: win32class.cpp,v 1.2 1999-07-14 08:35:36 sandervl Exp $ */
    32/*
    43 * Win32 Window Class Managment Code for OS/2
    54 *
    65 *
    7  * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
     6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
    87 *
    98 */
    109#include <os2win.h>
     10#include <stdio.h>
     11#include <stdlib.h>
     12#include <string.h>
    1113#include <stdarg.h>
    1214#include <assert.h>
    13 #include "misc.h"
    14 #include "user32.h"
    15 #include "win32class.h"
    16 #include "win32wnd.h"
     15#include <misc.h>
     16#include <win32class.h>
     17#include <win32wnd.h>
    1718
    1819//******************************************************************************
    1920//Win32WndClass methods:
    2021//******************************************************************************
    21 Win32WndClass::Win32WndClass(WNDCLASSEXA wndclass, BOOL isUnicode)
    22 {
    23   //Insert it in front of the rest
    24   next        = wndclasses;
    25   wndclasses  = this;
    26   if((ULONG)wndclass->lpszClassName >> 16 != 0) {
    27         className  = (char *) malloc(strlen(wndclass->lpszClassName)+1);
    28         classNameW = (WCHAR *)malloc((strlen(wndclass->lpszClassName)+1)*sizeof(WCHAR));
    29         if(className == NULL || classNameW == NULL) {
    30                 dprintf(("Win32Class ctr; className/classNameW == NULL"));
     22Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, BOOL isUnicode) : GenericObject(&wndclasses, OBJTYPE_CLASS)
     23{
     24  if(HIWORD(wndclass->lpszClassName)) {
     25        if(isUnicode) {
     26                classNameA = (PCHAR)malloc(lstrlenW((LPWSTR)wndclass->lpszClassName)+1);
     27                classNameW = (WCHAR *)malloc((lstrlenW((LPWSTR)wndclass->lpszClassName)+1)*sizeof(WCHAR));
     28        }
     29        else {
     30                classNameA = (PCHAR)malloc(strlen(wndclass->lpszClassName)+1);
     31                classNameW = (WCHAR *)malloc((strlen(wndclass->lpszClassName)+1)*sizeof(WCHAR));
     32        }
     33        if(classNameA == NULL || classNameW == NULL) {
     34                dprintf(("Win32Class ctr; classNameA/classNameW == NULL"));
    3135                exit(1);
    3236        }
    33         strcpy(className, wndclass->lpszClassName);
    34         AsciiToUnicode(className, classNameW);
    35         classAtom       = GlobalAddAtom(className);
     37        if(isUnicode) {
     38                lstrcpyW(classNameW, (LPWSTR)wndclass->lpszClassName);
     39                UnicodeToAscii(classNameW, classNameA);
     40        }
     41        else {
     42                strcpy((char *)classNameA, wndclass->lpszClassName);
     43                AsciiToUnicode(classNameA, classNameW);
     44        }
     45        classAtom       = GlobalAddAtomA(classNameA);
    3646  }
    3747  else {
    38         className       = NULL;
     48        classNameA      = NULL;
    3949        classNameW      = NULL;
    4050        classAtom       = (DWORD)wndclass->lpszClassName;
     
    5161  dprintf(("USER32:  wndclass->hCursor %X\n", wndclass->hCursor));
    5262  dprintf(("USER32:  wndclass->hbrBackground %X\n", wndclass->hbrBackground));
    53   if((ULONG)wndclass->lpszClassName >> 16 == 0)
     63  if(HIWORD(wndclass->lpszClassName))
    5464       dprintf(("USER32:  wndclass->lpszClassName %X\n", wndclass->lpszClassName));
    5565  else dprintf(("USER32:  wndclass->lpszClassName %s\n", wndclass->lpszClassName));
    5666
    57   if((ULONG)wc.lpszMenuName >> 16 != 0) {//convert string name identifier to numeric id
     67  if(HIWORD(wndclass->lpszMenuName)) {//convert string name identifier to numeric id
    5868       dprintf(("USER32:  lpszMenuName %s\n", wndclass->lpszMenuName));
    5969  }
     
    6272  nrExtraClassWords     = wndclass->cbClsExtra;
    6373  nrExtraWindowWords    = wndclass->cbWndExtra;
    64   backgroundBrush       = wndclass->hbrBackGround;      //TODO: fErase of PAINSTRUCT in WM_PAINT if == NULL
     74  backgroundBrush       = wndclass->hbrBackground;      //TODO: fErase of PAINSTRUCT in WM_PAINT if == NULL
    6575  hCursor               = wndclass->hCursor;
    6676  hIcon                 = wndclass->hIcon;
    6777  hInstance             = wndclass->hInstance;
    68   if(wndclass->lpszMenuName && (ULONG)wndclass->lpszMenuName >> 16) {
    69         menuName  = (ULONG)malloc(strlen(wndclass->lpszMenuName)+1);
    70         menuNameW = (ULONG)malloc((strlen(wndclass->lpszMenuName)+1)*sizeof(WCHAR));
    71         if(menuName == NULL || menuNameW == NULL) {
    72                 dprintf(("Win32Class ctr; menuName/menuNameW == NULL"));
    73                 exit(1);
    74         }
    75         strcpy((char *)menuName, wndclass->lpszMenuName);
    76         AsciiToUnicode(menuName, menuNameW);
    77   }
    78   else {
    79         menuName  = (ULONG)wndclass->lpszMenuName;
    80         menuNameW = (ULONG)wndclass->lpszMenuName;
    81   }
     78
     79  menuNameA = 0;
     80  menuNameW = 0;
     81  setMenuName((LPSTR)wndclass->lpszMenuName);
    8282
    8383  windowStyle           = wndclass->style;
     
    9595  else  userClassLong = NULL;
    9696
    97   hIconSm = wndclass->hIconSm;
    98 
    99   dprintf(("Win32WndClass::Win32WndClass %d\n", id));
     97  cWindows = 0;
     98  hIconSm  = wndclass->hIconSm;
    10099}
    101100//******************************************************************************
     
    103102Win32WndClass::~Win32WndClass()
    104103{
    105   Win32WndClass *wndclass = Win32WndClass::wndclasses;
    106 
    107   if(wndclass == this) {
    108         wndclasses = next;
    109   }
    110   else {
    111         while(wndclass->next != NULL) {
    112                 if(wndclass->next == this) {
    113                         wndclass->next = next;
    114                         break;
    115                 }
    116                 wndclass = wndclass->next;
    117         }
    118   }
    119104  if(userClassLong)     free(userClassLong);
    120   if(className)         free(className);
     105  if(classNameA)        free(classNameA);
    121106  if(classNameW)        free(classNameW);
    122   if(menuName && (ULONG)menuName >> 16) {
    123         free(menuName)
     107  if(menuNameA && HIWORD(menuNameA)) {
     108        free(menuNameA);
    124109        assert(menuNameW);
    125110        free(menuNameW);
     
    130115Win32WndClass *Win32WndClass::FindClass(HINSTANCE hInstance, LPSTR id)
    131116{
    132   Win32WndClass *wndclass = wndclasses;
     117  Win32WndClass *wndclass = (Win32WndClass *)wndclasses;
    133118
    134119  if(wndclass == NULL)  return(NULL);
    135120
    136   if((ULONG)id >> 16 != 0) {
    137         if(stricmp(wndclass->className, id) == 0 && wndclass->hInstance == hInstance) {
     121  if(HIWORD(id) != 0) {
     122        if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
    138123                return(wndclass);
    139124        }
    140125        else {
    141                 wndclass = wndclass->next;
     126                wndclass = (Win32WndClass *)wndclass->GetNext();
    142127                while(wndclass != NULL) {
    143                         if(stricmp(wndclass->className, id) == 0 && wndclass->hInstance == hInstance) {
     128                        if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
    144129                                return(wndclass);
    145130                        }
    146                         wndclass = wndclass->next;
     131                        wndclass = (Win32WndClass *)wndclass->GetNext();
    147132                }
    148133        }
     
    153138        }
    154139        else {
    155                 wndclass = wndclass->next;
     140                wndclass = (Win32WndClass *)wndclass->GetNext();
    156141                while(wndclass != NULL) {
    157142                        if(wndclass->classAtom == (DWORD)id && wndclass->hInstance == hInstance) {
    158143                                return(wndclass);
    159144                        }
    160                         wndclass = wndclass->next;
     145                        wndclass = (Win32WndClass *)wndclass->GetNext();
    161146                }
    162147        }
    163148  }
    164   dprintf(("Class %X (inst %X) not found!", id, hInstance);
     149  dprintf(("Class %X (inst %X) not found!", id, hInstance));
    165150  return(NULL);
    166151}
     
    171156  wndclass->cbClsExtra    = nrExtraClassWords;
    172157  wndclass->cbWndExtra    = nrExtraWindowWords;
    173   wndclass->hbrBackGround = backgroundBrush;
     158  wndclass->hbrBackground = backgroundBrush;
    174159  wndclass->hCursor       = hCursor;
    175160  wndclass->hIcon         = hIcon;
    176161  wndclass->hInstance     = hInstance;
    177   wndclass->lpszMenuName  = (LPCTSTR)menuName;
    178   wndclass->lpszClassName = (className) ? (LPCTSTR)className : (LPCTSTR)classAtom;
     162  wndclass->lpszMenuName  = (LPCTSTR)menuNameA;
     163  wndclass->lpszClassName = (classNameA) ? (LPCTSTR)classNameA : (LPCTSTR)classAtom;
    179164  wndclass->style         = windowStyle;
    180165  wndclass->lpfnWndProc   = windowProc;
     
    188173  wndclass->cbClsExtra    = nrExtraClassWords;
    189174  wndclass->cbWndExtra    = nrExtraWindowWords;
    190   wndclass->hbrBackGround = backgroundBrush;
     175  wndclass->hbrBackground = backgroundBrush;
    191176  wndclass->hCursor       = hCursor;
    192177  wndclass->hIcon         = hIcon;
     
    203188ULONG Win32WndClass::getClassName(LPSTR lpszClassName, ULONG cchClassName)
    204189{
    205   if((ULONG)className >> 16 != 0) {
    206         strncpy(lpszClassName, className, cchClassName-1);
     190  if(HIWORD(classNameA)) {
     191        strncpy(lpszClassName, classNameA, cchClassName-1);
    207192        return strlen(lpszClassName);
    208193  }
     
    216201 ULONG len;
    217202
    218   if((ULONG)classNameW >> 16 != 0) {
    219         len = min(UniStrLen((UniChar*)classNameW)+1, cchClassName);
    220         memcpy(lpszClassName, classNameW, len*sizeof(WCHAR));
    221         return len;
     203  if(HIWORD(classNameW)) {
     204        lstrcpyW(lpszClassName, classNameW);
     205        return lstrlenW(lpszClassName)*sizeof(WCHAR);
    222206  }
    223207  *(ULONG *)lpszClassName = classAtom;
    224208  return(sizeof(ULONG));
     209}
     210//******************************************************************************
     211//******************************************************************************
     212void Win32WndClass::setMenuName(LPSTR newMenuName)
     213{
     214  if(HIWORD(menuNameA)) {
     215        free(menuNameA);
     216        free(menuNameW);
     217        menuNameA = 0;
     218        menuNameW = 0;
     219  }
     220  if(HIWORD(newMenuName)) {
     221        if(isUnicode) {
     222                menuNameA = (PCHAR)malloc(lstrlenW((LPWSTR)newMenuName)+1);
     223                menuNameW = (WCHAR *)malloc((lstrlenW((LPWSTR)newMenuName)+1)*sizeof(WCHAR));
     224        }
     225        else {
     226                menuNameA = (PCHAR)malloc(strlen(newMenuName)+1);
     227                menuNameW = (WCHAR *)malloc((strlen(newMenuName)+1)*sizeof(WCHAR));
     228        }
     229        if(menuNameA == NULL || menuNameW == NULL) {
     230                dprintf(("Win32Class ctr; menuName/menuNameW == NULL"));
     231                exit(1);
     232        }
     233        if(isUnicode) {
     234                lstrcpyW(menuNameW, (LPWSTR)newMenuName);
     235                UnicodeToAscii(menuNameW, menuNameA);
     236        }
     237        else {
     238                strcpy((char *)menuNameA, newMenuName);
     239                AsciiToUnicode(menuNameA, menuNameW);
     240        }
     241  }
     242  else {//id
     243        menuNameA = (PCHAR)newMenuName;
     244        menuNameW = (WCHAR *)newMenuName;
     245  }
    225246}
    226247//******************************************************************************
     
    242263                return hInstance;
    243264        case GCL_MENUNAME:
    244                 return (isUnicode) ? menuNameW : menuName;
     265                return (isUnicode) ? (ULONG)menuNameW : (ULONG)menuNameA;
    245266        case GCL_STYLE:
    246267                return windowStyle;
    247268        case GCL_WNDPROC:
    248                 return windowProc;
     269                return (ULONG)windowProc;
    249270        case GCW_ATOM: //TODO: does this really happen in windows?
    250271                SetLastError(ERROR_INVALID_PARAMETER);
     
    260281//******************************************************************************
    261282//******************************************************************************
    262 WORD Win32WndClass::getClassWord(int index);
     283WORD Win32WndClass::getClassWord(int index)
    263284{
    264285  switch(index) {
     
    276297//TODO: What effects what immediately?
    277298//******************************************************************************
    278 ULONG Win32WndClass::setClassLong(int index, LONG lNewVal, BOOL isUnicode);
     299ULONG Win32WndClass::setClassLongA(int index, LONG lNewVal, BOOL isUnicode)
    279300{
    280301 ULONG rc;
     
    306327                break;
    307328        case GCL_MENUNAME:
    308                 if(isUnicode) {
    309                         rc = menuNameW;
    310                         menuNameW = lNewVal;    //FIXME
    311                 }
    312                 else { 
    313                         rc = menuName;
    314                         menuName = lNewVal;     //FIXME
    315                 }
     329                rc = 0; //old value is meaningless (according to Wine)
     330                setMenuName((LPSTR)lNewVal);
    316331                break;
    317332        case GCL_STYLE:
     
    320335                break;
    321336        case GCL_WNDPROC:
    322                 rc = windowProc;
    323                 windowProc = lNewVal;
     337                rc = (ULONG)windowProc;
     338                windowProc = (WNDPROC)lNewVal;
    324339                break;
    325340        case GCW_ATOM: //TODO: does this really happen in windows?
     
    339354//******************************************************************************
    340355//******************************************************************************
    341 WORD Win32WndClass::setClassWord(int index, WORD wNewVal);
     356WORD Win32WndClass::setClassWord(int index, WORD wNewVal)
    342357{
    343358 WORD rc;
     
    375390//******************************************************************************
    376391//******************************************************************************
    377 Win32WndClass *Win32WndClass::wndclasses = NULL;
    378 
    379 //******************************************************************************
    380 //SvL: 18-7-'98: Moved here from user32.cpp
    381 //******************************************************************************
    382 ATOM WIN32API OS2RegisterClassA(WNDCLASS *lpWndClass)
    383 {
    384  WNDCLASSEXA wc;
    385  Win32Class *wclass;
    386 
    387    memcpy(&wc, lpWndClass, sizeof(WNDCLASS));
    388    wc.hIconSm = 0;
    389    
    390    wclass = new Win32Class(&wc);
    391    if(wclass == NULL) {
    392         dprintf(("RegisterClassA wclass == NULL!"));
    393         return(0);
    394    }
    395    return(wclass->getAtom());
    396 }
    397 //******************************************************************************
    398 //SvL: 18-7-'98: Moved here from user32.cpp
    399 //******************************************************************************
    400 ATOM WIN32API OS2RegisterClassExA(WNDCLASSEXA *lpWndClass)
    401 {
    402  Win32Class *wclass;
    403 
    404    wclass = new Win32Class(lpWndClass);
    405    if(wclass == NULL) {
    406         dprintf(("RegisterClassExA wclass == NULL!"));
    407         return(0);
    408    }
    409    return(wclass->getAtom());
    410 }
    411 //******************************************************************************
    412 //******************************************************************************
    413 WORD WIN32API OS2RegisterClassW(WNDCLASSW *lpwc)
    414 {
    415  ATOM rc;
    416  WNDCLASSEX wclass;
    417 
    418     dprintf(("RegisterClassW\n"));
    419     memcpy(&wclass, lpwc, sizeof(WNDCLASS));
    420     if(wclass.lpszMenuName && ((ULONG)wclass.lpszMenuName >> 16 != 0)) {
    421         wclass.lpszMenuName = UnicodeToAsciiString((LPWSTR)lpwc->lpszMenuName);
    422     }
    423     if(wclass.lpszClassName && ((ULONG)wclass.lpszClassName >> 16 != 0)) {
    424         wclass.lpszClassName = UnicodeToAsciiString((LPWSTR)lpwc->lpszClassName);
    425     }
    426     rc = OS2RegisterClassA(&wclass);
    427 
    428     if(lpwc->lpszMenuName && ((ULONG)lpwc->lpszMenuName >> 16 != 0)) {
    429         FreeAsciiString((char *)wclass.lpszMenuName);
    430     }
    431     if(lpwc->lpszClassName && ((ULONG)lpwc->lpszClassName >> 16 != 0)) {
    432         FreeAsciiString((char *)wclass.lpszClassName);
    433     }
    434     return(rc);
    435 }
    436 //******************************************************************************
    437 //******************************************************************************
    438 ATOM WIN32API OS2RegisterClassExW(CONST WNDCLASSEXW *lpwc)
    439 {
    440  ATOM rc;
    441  WNDCLASSEXA wclass;
    442 
    443     dprintf(("RegisterClassExW\n"));
    444     memcpy(&wclass, lpwc, sizeof(WNDCLASSEXA));
    445     if(wclass.lpszMenuName && ((ULONG)wclass.lpszMenuName >> 16 != 0)) {
    446         wclass.lpszMenuName = UnicodeToAsciiString((LPWSTR)lpwc->lpszMenuName);
    447     }
    448     if(wclass.lpszClassName && ((ULONG)wclass.lpszClassName >> 16 != 0)) {
    449         wclass.lpszClassName = UnicodeToAsciiString((LPWSTR)lpwc->lpszClassName);
    450     }
    451     rc = OS2RegisterClassExA(&wclass);
    452 
    453     if(lpwc->lpszMenuName && ((ULONG)lpwc->lpszMenuName >> 16 != 0)) {
    454         FreeAsciiString((char *)wclass.lpszMenuName);
    455     }
    456     if(lpwc->lpszClassName && ((ULONG)lpwc->lpszClassName >> 16 != 0)) {
    457         FreeAsciiString((char *)wclass.lpszClassName);
    458     }
    459     return(rc);
    460 }
    461 //******************************************************************************
    462 //******************************************************************************
    463 BOOL WIN32API OS2UnregisterClassA(LPCSTR lpszClassName, HINSTANCE hinst)
    464 {
    465    dprintf(("USER32:  OS2UnregisterClassA\n"));
    466    Win32WndClass::UnregisterClass(hinst, (LPSTR)lpszClassName);
    467 
    468    //Spintest returns FALSE in dll termination, so pretend it succeeded
    469    return(TRUE);
    470 }
    471 //******************************************************************************
    472 //******************************************************************************
    473 BOOL WIN32API OS2UnregisterClassW(LPWSTR lpszClassName, HINSTANCE hinst)
    474 {
    475  char *astring = NULL;
    476 
    477   dprintf(("USER32:  OS2UnregisterClassW\n"));
    478   if((ULONG)lpszClassName >> 16 != 0) {
    479         astring = UnicodeToAsciiString(lpszClassName);
    480   }
    481   else  astring = (char *)lpszClassName;
    482 
    483   Win32WndClass::UnregisterClass(hinst, (LPSTR)astring);
    484   if(astring >> 16 != 0)       
    485         FreeAsciiString((char *)astring);
    486   //Spintest returns FALSE in dll termination, so pretend it succeeded
    487   return(TRUE);
    488 }
    489 //******************************************************************************
    490 //******************************************************************************
    491 BOOL WIN32API OS2GetClassInfoA(HINSTANCE hInstance, LPCSTR lpszClass, PWNDCLASSA lpwc)
    492 {
    493  WNDCLASSEXA    wc;
    494  BOOL           rc;
    495  Win32WndClass *wndclass;
    496 
    497   dprintf(("USER32:  OS2GetClassInfoA\n"));
    498 
    499   wndclass = FindClass(hInstance, lpszClass);
    500   if(wndclass) {
    501         wndclass->getClassInfo(&wc);
    502         memcpy(lpwc, &wc, sizeof(WNDCLASSA));
    503         return(TRUE);
    504   }
    505   return(FALSE); 
    506 }
    507 //******************************************************************************
    508 //******************************************************************************
    509 BOOL WIN32API OS2GetClassInfoW(HINSTANCE  hinst, LPWSTR lpszClass, PWNDCLASSW lpwc)
    510 {
    511  WNDCLASSEXW    wc;
    512  BOOL           rc;
    513  Win32WndClass *wndclass;
    514  char          *astring = NULL;
    515 
    516   dprintf(("USER32:  OS2GetClassInfoW\n"));
    517 
    518   if((ULONG)lpszClass >> 16 != 0) {
    519         astring = UnicodeToAsciiString(lpszClass);
    520   }
    521   else  astring = (char *)lpszClass;
    522 
    523   wndclass = FindClass(hInstance, astring);
    524   if((ULONG)astring >> 16 != 0)
    525         FreeAsciiString((char *)astring);
    526   if(wndclass) {
    527         wndclass->getClassInfo(&wc);
    528         memcpy(lpwc, &wc, sizeof(WNDCLASSW));
    529         return(TRUE);
    530   }
    531   return(FALSE); 
    532 }
    533 /****************************************************************************
    534  * Name      : BOOL WIN32API OS2GetClassInfoExA
    535  * Purpose   : The GetClassInfoEx function retrieves information about a window
    536  *             class, including the handle of the small icon associated with the
    537  *             window class. GetClassInfo does not retrieve the handle of the small icon.
    538  * Parameters: HINSTANCE    hinst     handle of application instance
    539  *             LPCTSTR      lpszClass address of class name string
    540  *             LPWNDCLASSEX lpwcx     address of structure for class data
    541  * Variables :
    542  * Result    : If the function finds a matching class and successfully copies
    543  *               the data, the return value is TRUE;
    544  *             otherwise, it is FALSE.
    545  *             To get extended error information, call GetLastError.
    546  * Remark    : PH: does not obtain handle of the small icon
    547  *****************************************************************************/
    548 BOOL WIN32API OS2GetClassInfoExA(HINSTANCE     hInstance,
    549                                  LPCTSTR       lpszClass,
    550                                  LPWNDCLASSEXA lpwcx)
    551 {
    552  BOOL           rc;
    553  Win32WndClass *wndclass;
    554  
    555   dprintf(("USER32:GetClassInfoExA (%08xh,%x,%08x).\n",
    556          hInstance,
    557          lpszClass,
    558          lpwcx));
    559  
    560   wndclass = FindClass(hInstance, lpszClass);
    561   if(wndclass) {
    562         wndclass->getClassInfo(lpwcx);
    563         return(TRUE);
    564   }
    565   return(FALSE); 
    566 }
    567 /*****************************************************************************
    568  * Name      : BOOL WIN32API OS2GetClassInfoExW
    569  * Purpose   : The GetClassInfoEx function retrieves information about a window
    570  *             class, including the handle of the small icon associated with the
    571  *             window class. GetClassInfo does not retrieve the handle of the small icon.
    572  * Parameters: HINSTANCE    hinst     handle of application instance
    573  *             LPCWSTR      lpszClass address of class name string
    574  *             LPWNDCLASSEX lpwcx     address of structure for class data
    575  * Variables :
    576  * Result    : If the function finds a matching class and successfully copies
    577  *               the data, the return value is TRUE;
    578  *             otherwise, it is FALSE.
    579  *             To get extended error information, call GetLastError.
    580  * Remark    : does not obtain handle of the small icon
    581  *
    582  *****************************************************************************/
    583 BOOL WIN32API OS2GetClassInfoExW(HINSTANCE     hInstance,
    584                                  LPCWSTR       lpszClass,
    585                                  LPWNDCLASSEXW lpwcx)
    586 {
    587  BOOL           rc;
    588  Win32WndClass *wndclass;
    589  char          *astring = NULL;
    590 
    591   dprintf(("USER32: OS2GetClassInfoExW\n"));
    592 
    593   if((ULONG)lpszClass >> 16 != 0) {
    594         astring = UnicodeToAsciiString(lpszClass);
    595   }
    596   else  astring = (char *)lpszClass;
    597 
    598   wndclass = FindClass(hInstance, astring);
    599   if((ULONG)astring >> 16 != 0)
    600         FreeAsciiString((char *)astring);
    601   if(wndclass) {
    602         wndclass->getClassInfo(lpwcx);
    603         return(TRUE);
    604   }
    605   return(FALSE); 
    606 }
    607 //******************************************************************************
    608 //******************************************************************************
    609 int WIN32API OS2GetClassNameA(HWND hwnd, LPSTR lpszClassName, int cchClassName)
    610 {
    611  Win32Window *wnd;
    612 
    613     dprintf(("USER32: OS2GetClassNameA\n"));
    614     wnd = WIN2OS2HWND(hwnd);
    615     if(wnd == NULL) {
    616         dprintf(("GetClassNameA wnd == NULL"));
    617         return(0);
    618     }
    619     return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
    620 }
    621 //******************************************************************************
    622 //******************************************************************************
    623 int WIN32API OS2GetClassNameW(HWND hwnd, LPWSTR lpszClassName, int cchClassName)
    624 {
    625  Win32Window *wnd;
    626 
    627     dprintf(("USER32: OS2GetClassNameW\n"));
    628     wnd = WIN2OS2HWND(hwnd);
    629     if(wnd == NULL) {
    630         dprintf(("GetClassNameA wnd == NULL"));
    631         return(0);
    632     }
    633     return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
    634 }
    635 //******************************************************************************
    636 //******************************************************************************
    637 DWORD WIN32API OS2SetClassLongA(HWND hwnd, int nIndex, LONG lNewVal)
    638 {
    639  Win32Window *wnd;
    640 
    641     dprintf(("USER32: OS2SetClassLongA\n"));
    642     wnd = WIN2OS2HWND(hwnd);
    643     if(wnd == NULL) {
    644         dprintf(("SetClassLongA wnd == NULL"));
    645         return(0);
    646     }
    647     return (wnd->getClass())->setClassLongA(nIndex, lNewVal);
    648 }
    649 //******************************************************************************
    650 //******************************************************************************
    651 DWORD WIN32API OS2SetClassLongW(HWND hwnd, int nIndex, LONG lNewVal)
    652 {
    653  Win32Window *wnd;
    654 
    655     dprintf(("USER32: OS2SetClassLongW\n"));
    656     wnd = WIN2OS2HWND(hwnd);
    657     if(wnd == NULL) {
    658         dprintf(("SetClassLongW wnd == NULL"));
    659         return(0);
    660     }
    661     return (wnd->getClass())->setClassLongW(nIndex, lNewVal);
    662 }
    663 //******************************************************************************
    664 //******************************************************************************
    665 WORD WIN32API OS2SetClassWord(HWND hwnd, int nIndex, WORD  wNewVal)
    666 {
    667  Win32Window *wnd;
    668 
    669     dprintf(("USER32: OS2SetClassWordA\n"));
    670     wnd = WIN2OS2HWND(hwnd);
    671     if(wnd == NULL) {
    672         dprintf(("SetClassWordA wnd == NULL"));
    673         return(0);
    674     }
    675     return (wnd->getClass())->setClassWord(nIndex, wNewVal);
    676 }
    677 //******************************************************************************
    678 //******************************************************************************
    679 WORD WIN32API OS2GetClassWord(HWND hwnd, int nIndex)
    680 {
    681  Win32Window *wnd;
    682 
    683     dprintf(("USER32: OS2GetClassWordA\n"));
    684     wnd = WIN2OS2HWND(hwnd);
    685     if(wnd == NULL) {
    686         dprintf(("GetClassWordA wnd == NULL"));
    687         return(0);
    688     }
    689     return (wnd->getClass())->getClassWord(nIndex);
    690 }
    691 //******************************************************************************
    692 //******************************************************************************
    693 DWORD WIN32API OS2GetClassLongA(HWND hwnd, int nIndex)
    694 {
    695  Win32Window *wnd;
    696 
    697     dprintf(("USER32: OS2GetClassLongA\n"));
    698     wnd = WIN2OS2HWND(hwnd);
    699     if(wnd == NULL) {
    700         dprintf(("OS2GetClassLongA wnd == NULL"));
    701         return(0);
    702     }
    703     return (wnd->getClass())->getClassLongA(nIndex);
    704 }
    705 //******************************************************************************
    706 //******************************************************************************
    707 DWORD WIN32API OS2GetClassLongW(HWND hwnd, int nIndex)
    708 {
    709  Win32Window *wnd;
    710 
    711     dprintf(("USER32: OS2GetClassLongW\n"));
    712     wnd = WIN2OS2HWND(hwnd);
    713     if(wnd == NULL) {
    714         dprintf(("OS2GetClassLongW wnd == NULL"));
    715         return(0);
    716     }
    717     return (wnd->getClass())->getClassLongW(nIndex);
    718 }
    719 //******************************************************************************
    720 //******************************************************************************
     392GenericObject *Win32WndClass::wndclasses = NULL;
     393
  • trunk/src/user32/new/win32class.h

    r4 r300  
    1 /* $Id: win32class.h,v 1.1 1999-05-24 20:20:04 ktk Exp $ */
    2 
     1/* $Id: win32class.h,v 1.2 1999-07-14 08:35:37 sandervl Exp $ */
     2/*
     3 * Win32 Window Class Managment Code for OS/2
     4 *
     5 *
     6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
     7 *
     8 */
    39#ifndef __WIN32CLASS_H__
    410#define __WIN32CLASS_H__
    511
    6 //SvL: 18-7-'98, Registers system window classes (button, listbox etc etc)
    7 extern "C" {
    8 void RegisterSystemClasses(ULONG hModule);
    9 }
     12#include <gen_object.h>
    1013
    11 class Win32WndClass
     14class Win32WndClass : public GenericObject
    1215{
    1316public:
    14         Win32WndClass(WNDCLASSEXA wndclass, BOOL isUnicode);
     17        Win32WndClass(WNDCLASSEXA *wndclass, BOOL isUnicode = FALSE);
    1518       ~Win32WndClass();
    1619
     
    3639         ULONG  getClassName(LPWSTR lpszClassName, ULONG cchClassName);
    3740
     41       WNDPROC  getWindowProc()         { return windowProc; };
     42         LPSTR  getMenuNameA()          { return menuNameA; };
     43         DWORD  getExtraWndWords()      { return nrExtraWindowWords; };
     44
     45          void  setMenuName(LPSTR newMenuName);
     46
     47          void  IncreaseWindowCount()   { cWindows++; };
     48          void  DecreaseWindowCount()   { cWindows--; };
     49          DWORD GetWindowCount()        { return cWindows; };
     50         
    3851 static  void   UnregisterClassA(HINSTANCE hinst, LPSTR id);
    3952
     
    5063 HICON          hIcon;                  //GCL_HICON
    5164 HINSTANCE      hInstance;              //GCL_HMODULE
    52  ULONG          menuName;               //GCL_MENUNAME
    53  ULONG          menuNameW;              //GCL_MENUNAME
     65 PCHAR          menuNameA;              //GCL_MENUNAME
     66 WCHAR         *menuNameW;              //GCL_MENUNAME
    5467 ULONG          windowStyle;            //GCL_STYLE
    55  WINWNDPROC     windowProc;             //GCL_WNDPROC
     68 WNDPROC        windowProc;             //GCL_WNDPROC
    5669 ULONG          classAtom;              //GCW_ATOM
    5770
    58  ULONG          className;
    59  ULONG          classNameW;
     71 PCHAR          classNameA;
     72 WCHAR         *classNameW;
    6073 HICON          hIconSm;
    6174
    6275 //User data class words/longs
    6376 ULONG         *userClassLong;
     77
     78 //nr of windows created with this class
     79 ULONG          cWindows;
    6480 
    65  static         Win32WndClass  *wndclasses;
    66                 Win32WndClass  *next;
     81 static GenericObject *wndclasses;
    6782};
    6883
  • trunk/src/user32/new/win32dlg.h

    r4 r300  
    1 /* $Id: win32dlg.h,v 1.1 1999-05-24 20:20:04 ktk Exp $ */
    2 
     1/* $Id: win32dlg.h,v 1.2 1999-07-14 08:35:37 sandervl Exp $ */
     2/*
     3 * Win32 Dialog Code for OS/2
     4 *
     5 *
     6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
     7 *
     8 *
     9 * Project Odin Software License can be found in LICENSE.TXT
     10 *
     11 */
    312#ifndef __WIN32DLG_H__
    413#define __WIN32DLG_H__
    514
    6 #include "win32wnd.h"
     15#include <win32wnd.h>
    716
    817#ifdef __cplusplus
    918
    10 class Win32Dialog : Win32Window
     19class Win32Dialog : public Win32Window
    1120{
    1221public:
    13          Win32Dialog(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     22         Win32Dialog();
    1423virtual ~Win32Dialog();
    1524
    16      MRESULT    ProcessDlgMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     25virtual  ULONG  MsgOS2Create(HWND hwndOS2, ULONG initParam);
    1726
    18 virtual  BOOL   SetWindowLong(int index, ULONG value);
    19 virtual  ULONG  GetWindowLong(int index);
     27virtual  LONG   SetWindowLongA(int index, ULONG value);
     28virtual  ULONG  GetWindowLongA(int index);
    2029
    2130protected:
    2231        // values normally contained in the standard dialog words
    23     WINDLGPROC  Win32DlgProc;   //DWL_WNDPROC
     32      DLGPROC   Win32DlgProc;   //DWL_WNDPROC
    2433        ULONG   msgResult;      //DWL_MSGRESULT
    2534        ULONG   userDlgData;    //DWL_USER
    2635
    2736private:
    28 
    29 
    3037};
    3138
  • trunk/src/user32/new/win32wnd.h

    r4 r300  
    1 /* $Id: win32wnd.h,v 1.1 1999-05-24 20:20:05 ktk Exp $ */
    2 
     1/* $Id: win32wnd.h,v 1.2 1999-07-14 08:35:37 sandervl Exp $ */
     2/*
     3 * Win32 Window Code for OS/2
     4 *
     5 *
     6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
     7 *
     8 *
     9 * Project Odin Software License can be found in LICENSE.TXT
     10 *
     11 */
    312#ifndef __WIN32WND_H__
    413#define __WIN32WND_H__
     
    615#ifdef __cplusplus
    716
    8 #include "win32class.h"
     17#include <win32class.h>
     18#include <gen_object.h>
    919
    10 #define WIN2OS2HWND(a)  (a^a)
     20class Win32Window;
     21
     22#define WIN2OS2HWND(a)  (Win32Window*)(a^a)
    1123#define OS22WINHWND(a)  (a^a)
    1224
    13 //Win32 window message handler
    14 typedef LRESULT  (* WIN32API WINWNDPROC) ( HWND, UINT, WPARAM, LPARAM );
     25#define OFFSET_WIN32WNDPTR      0
     26#define OFFSET_WIN32PM_MAGIC    4
    1527
    16 class Win32Window
     28#define WIN32PM_MAGIC   0x12345678
     29
     30typedef struct {
     31        USHORT          cb;
     32        Win32Window    *win32wnd;
     33        ULONG           win32CreateStruct;      //or dialog create dword
     34} CUSTOMWNDDATA;
     35
     36class Win32Window : public GenericObject
    1737{
    1838public:
    19                 Win32Window(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     39        DWORD   magic;
     40
     41                Win32Window(DWORD objType);
     42                Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
    2043virtual        ~Win32Window();
    2144
    22      MRESULT    ProcessMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     45virtual  ULONG  MsgCreate(HWND hwndOS2, ULONG initParam);
     46         ULONG  MsgQuit();
     47         ULONG  MsgClose();
     48         ULONG  MsgDestroy();
     49         ULONG  MsgEnable(BOOL fEnable);
     50         ULONG  MsgShow(BOOL fShow);
     51         ULONG  MsgMove(ULONG xScreen, ULONG yScreen, ULONG xParent, ULONG yParent);
     52         ULONG  MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
     53         ULONG  MsgActivate(BOOL fActivate, HWND hwnd);
     54         ULONG  MsgSetFocus(HWND hwnd);
     55         ULONG  MsgKillFocus(HWND hwnd);
     56         ULONG  MsgButton(ULONG msg, ULONG x, ULONG y);
     57         ULONG  MsgPaint(ULONG tmp1, ULONG tmp2);
     58         ULONG  MsgEraseBackGround(ULONG hps);
    2359
    24 virtual  BOOL   SetWindowLong(int index, ULONG value);
    25 virtual  ULONG  GetWindowLong(int index);
     60virtual  LONG   SetWindowLongA(int index, ULONG value);
     61virtual  ULONG  GetWindowLongA(int index);
     62virtual  WORD   SetWindowWord(int index, WORD value);
     63virtual  WORD   GetWindowWord(int index);
    2664
    27          BOOL   PostMessageA(HWND hwnd, ULONG msg, WPARAM wParam, LPARAM lParam);
    28          BOOL   PostMessageW(HWND hwnd, ULONG msg, WPARAM wParam, LPARAM lParam);
     65         DWORD  getStyle()                      { return dwStyle; };
     66         DWORD  getExStyle()                    { return dwExStyle; };
     67         HWND   getWindowHandle()               { return Win32Hwnd; };
     68         HWND   getOS2WindowHandle()            { return OS2Hwnd; };
     69   Win32Window *getParent()                     { return parent; };
     70         void   setParent(Win32Window *pwindow) { parent = pwindow; };
     71       WNDPROC  getWindowProc()                 { return win32wndproc; };
     72         void   setWindowProc(WNDPROC newproc)  { win32wndproc = newproc; };
     73        DWORD   getWindowId()                   { return windowId; };
     74         void   setWindowId(DWORD id)           { windowId = id; };
     75
     76       LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     77       LRESULT  SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
     78       LRESULT  DefWindowProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
     79       LRESULT  DefWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
     80
     81         void   NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
    2982
    3083Win32WndClass  *getClass()  { return windowClass; };
    3184
    3285protected:
     86        void    Init();
     87
     88
    3389        HWND    OS2Hwnd;
    3490        HWND    Win32Hwnd;
     
    3894
    3995        // values normally contained in the standard window words
    40         ULONG   ExtendedWindowStyle;    //GWL_EXSTYLE
    41         ULONG   WindowStyle;            //GWL_STYLE
    42    //ptr to WINWNDPROC in windowClass
    43    WINWNDPROC  *win32wndproc;           //GWL_WNDPROC
     96        ULONG   dwExStyle;              //GWL_EXSTYLE
     97        ULONG   dwStyle;                //GWL_STYLE
     98      WNDPROC   win32wndproc;           //GWL_WNDPROC
    4499        ULONG   hInstance;              //GWL_HINSTANCE
    45         HWND    hwndParent;             //GWL_HWNDPARENT
     100   Win32Window *parent;                 //GWL_HWNDPARENT
    46101        ULONG   windowId;               //GWL_ID
    47102        ULONG   userData;               //GWL_USERDATA
     103
     104         HWND   hwndLinkAfter;
     105        DWORD   flags;
     106
     107   Win32Window *owner;                 
     108
     109        char   *windowName;
     110        ULONG   wndNameLength;
    48111
    49112        char   *windowText;
    50113        ULONG   wndTextLength;
    51114       
    52         ULONG  *UserWindowLong;
     115        ULONG  *userWindowLong;
    53116        ULONG   nrUserWindowLong;
    54117
    55118Win32WndClass  *windowClass;
    56119
    57   Win32Window  *parent;
    58   Win32Window  *child;
    59   Win32Window  *nextchild;
     120static GenericObject *windows;
    60121
    61122private:
     123        BOOL  CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
     124
     125        void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
     126};
    62127
    63128
    64 };
    65 
     129#define BUTTON_LEFTDOWN         0
     130#define BUTTON_LEFTUP           1
     131#define BUTTON_LEFTDBLCLICK     2
     132#define BUTTON_RIGHTUP          3
     133#define BUTTON_RIGHTDOWN        4
     134#define BUTTON_RIGHTDBLCLICK    5
    66135
    67136#endif //__cplusplus
Note: See TracChangeset for help on using the changeset viewer.