Ignore:
Timestamp:
Aug 25, 1999, 5:08:51 PM (26 years ago)
Author:
dengert
Message:

new window size/move code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/win32wnd.h

    r650 r693  
    1 /* $Id: win32wnd.h,v 1.24 1999-08-23 15:34:47 dengert Exp $ */
     1/* $Id: win32wnd.h,v 1.25 1999-08-25 15:08:51 dengert Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    2323class Win32Window;
    2424
    25 #define OFFSET_WIN32WNDPTR      0
    26 #define OFFSET_WIN32PM_MAGIC    4
    27 
    28 #define WIN32PM_MAGIC           0x12345678
    29 #define CheckMagicDword(a)      (a==WIN32PM_MAGIC)
     25#define OFFSET_WIN32WNDPTR      0
     26#define OFFSET_WIN32PM_MAGIC    4
     27
     28#define WIN32PM_MAGIC           0x12345678
     29#define CheckMagicDword(a)      (a==WIN32PM_MAGIC)
    3030
    3131typedef struct {
    32         USHORT          cb;
    33         Win32Window    *win32wnd;
    34         ULONG           win32CreateStruct;      //or dialog create dword
     32        USHORT          cb;
     33        Win32Window    *win32wnd;
     34        ULONG           win32CreateStruct;      //or dialog create dword
    3535} CUSTOMWNDDATA;
    3636
    3737typedef struct
    3838{
    39         ULONG           Msg;
    40         ULONG           wParam;
    41         ULONG           lParam;
     39        ULONG           Msg;
     40        ULONG           wParam;
     41        ULONG           lParam;
    4242} POSTMSG_PACKET;
    4343
    44 #define WM_WIN32_POSTMESSAGEA   0x4000
    45 #define WM_WIN32_POSTMESSAGEW   0x4001
    46 
    47 #define MAX_WINDOW_NAMELENGTH   256
     44#define WM_WIN32_POSTMESSAGEA   0x4000
     45#define WM_WIN32_POSTMESSAGEW   0x4001
     46
     47#define MAX_WINDOW_NAMELENGTH   256
    4848
    4949class Win32Window : private GenericObject, private ChildWindow
    5050{
    5151public:
    52         DWORD   magic;
    53 
    54                 Win32Window(DWORD objType);
    55                 Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
     52        DWORD   magic;
     53
     54                Win32Window(DWORD objType);
     55                Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
    5656virtual        ~Win32Window();
    5757
    58 virtual  ULONG  MsgCreate(HWND hwndOS2, ULONG initParam);
    59          ULONG  MsgQuit();
    60          ULONG  MsgClose();
    61          ULONG  MsgDestroy();
    62          ULONG  MsgEnable(BOOL fEnable);
    63          ULONG  MsgShow(BOOL fShow);
    64          ULONG  MsgMove(ULONG x, ULONG y);
    65          ULONG  MsgHitTest(ULONG x, ULONG y);
    66          ULONG  MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
    67          ULONG  MsgActivate(BOOL fActivate, HWND hwnd);
    68          ULONG  MsgSetFocus(HWND hwnd);
    69          ULONG  MsgKillFocus(HWND hwnd);
    70          ULONG  MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
    71          ULONG  MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
    72          ULONG  MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
    73          ULONG  MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
    74          ULONG  MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
    75          ULONG  MsgPaint(ULONG tmp1, ULONG tmp2);
    76          ULONG  MsgEraseBackGround(HDC hdc);
    77          ULONG  MsgSetText(LPSTR lpsz, LONG cch);
    78          ULONG  MsgGetTextLength();
    79          char  *MsgGetText();
    80 
    81 virtual  LONG   SetWindowLongA(int index, ULONG value);
    82 virtual  ULONG  GetWindowLongA(int index);
    83 virtual  WORD   SetWindowWord(int index, WORD value);
    84 virtual  WORD   GetWindowWord(int index);
    85 
    86          DWORD  getStyle()                      { return dwStyle; };
    87          DWORD  getExStyle()                    { return dwExStyle; };
    88          HWND   getWindowHandle()               { return Win32Hwnd; };
    89          HWND   getOS2WindowHandle()            { return OS2Hwnd; };
    90          HWND   getOS2FrameWindowHandle()       { return OS2HwndFrame; };
    91          BOOL   isFrameWindow()                 { return OS2Hwnd != OS2HwndFrame; };
    92    Win32Window *getParent()                     { return (Win32Window *)ChildWindow::GetParent(); };
    93          void   setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
    94        WNDPROC  getWindowProc()                 { return win32wndproc; };
    95          void   setWindowProc(WNDPROC newproc)  { win32wndproc = newproc; };
    96         DWORD   getWindowId()                   { return windowId; };
    97          void   setWindowId(DWORD id)           { windowId = id; };
    98          ULONG  getWindowHeight()               { return rectClient.bottom - rectClient.top; };
    99          BOOL   isChild();
    100          PRECT  getClientRect()                 { return &rectClient; };
    101          PRECT  getWindowRect()                 { return &rectWindow; };
    102 
    103          DWORD  getFlags()                      { return flags; };
    104          void   setFlags(DWORD newflags)        { flags = newflags; };
    105 
    106          HACCEL GetAccelTable()                     { return (HACCEL) acceltableResource; };
    107          BOOL   SetAccelTable(ULONG hAccel);
    108 
    109          HMENU  GetMenu()                           { return (HMENU) menuResource; };
    110          BOOL   SetMenu(ULONG hMenu);
    111 
    112          BOOL   SetIcon(HICON hIcon);
    113          HICON  GetIcon()                           { return (HICON) iconResource; };
    114 
    115          BOOL   ShowWindow(ULONG nCmdShow);
    116          BOOL   SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
    117          BOOL   DestroyWindow();
    118          HWND   SetActiveWindow();
    119          HWND   GetParent();
    120          HWND   SetParent(HWND hwndNewParent);
    121          BOOL   IsChild(HWND hwndParent);
    122          HWND   GetTopWindow();
    123          BOOL   UpdateWindow();
    124          BOOL   IsIconic();
    125          HWND   GetWindow(UINT uCmd);
    126          BOOL   EnableWindow(BOOL fEnable);
    127          BOOL   CloseWindow();
    128   static HWND   GetActiveWindow();
    129          BOOL   IsWindow();
    130          BOOL   IsWindowEnabled();
    131          BOOL   IsWindowVisible();
    132          BOOL   IsUnicode()  { return isUnicode; };
    133 
    134          BOOL   GetWindowRect(PRECT pRect);
    135          int    GetWindowTextLengthA();
    136          int    GetWindowTextA(LPSTR lpsz, int cch);
    137          BOOL   SetWindowTextA(LPCSTR lpsz);
    138 
    139        LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
    140        LRESULT  SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
    141        BOOL     PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
    142        BOOL     PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
    143        LRESULT  DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
    144        LRESULT  DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
    145 
    146          void   NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
     58virtual  ULONG  MsgCreate(HWND hwndOS2, ULONG initParam);
     59         ULONG  MsgQuit();
     60         ULONG  MsgClose();
     61         ULONG  MsgDestroy();
     62         ULONG  MsgEnable(BOOL fEnable);
     63         ULONG  MsgShow(BOOL fShow);
     64         ULONG  MsgPosChanging(LPARAM lp);
     65         ULONG  MsgPosChanged(LPARAM lp);
     66         ULONG  MsgMove(ULONG x, ULONG y);
     67         ULONG  MsgHitTest(ULONG x, ULONG y);
     68         ULONG  MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
     69         ULONG  MsgActivate(BOOL fActivate, HWND hwnd);
     70         ULONG  MsgSetFocus(HWND hwnd);
     71         ULONG  MsgKillFocus(HWND hwnd);
     72         ULONG  MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
     73         ULONG  MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
     74         ULONG  MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
     75         ULONG  MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
     76         ULONG  MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
     77         ULONG  MsgPaint(ULONG tmp1, ULONG tmp2);
     78         ULONG  MsgEraseBackGround(HDC hdc);
     79         ULONG  MsgSetText(LPSTR lpsz, LONG cch);
     80         ULONG  MsgGetTextLength();
     81         char  *MsgGetText();
     82
     83virtual  LONG   SetWindowLongA(int index, ULONG value);
     84virtual  ULONG  GetWindowLongA(int index);
     85virtual  WORD   SetWindowWord(int index, WORD value);
     86virtual  WORD   GetWindowWord(int index);
     87
     88         DWORD  getStyle()                      { return dwStyle; };
     89         DWORD  getExStyle()                    { return dwExStyle; };
     90         HWND   getWindowHandle()               { return Win32Hwnd; };
     91         HWND   getOS2WindowHandle()            { return OS2Hwnd; };
     92         HWND   getOS2FrameWindowHandle()       { return OS2HwndFrame; };
     93         BOOL   isFrameWindow()                 { return OS2Hwnd != OS2HwndFrame; };
     94   Win32Window *getParent()                     { return (Win32Window *)ChildWindow::GetParent(); };
     95         void   setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
     96       WNDPROC  getWindowProc()                 { return win32wndproc; };
     97         void   setWindowProc(WNDPROC newproc)  { win32wndproc = newproc; };
     98        DWORD   getWindowId()                   { return windowId; };
     99         void   setWindowId(DWORD id)           { windowId = id; };
     100         ULONG  getWindowHeight()               { return rectClient.bottom - rectClient.top; };
     101         BOOL   isChild();
     102         PRECT  getClientRect()                 { return &rectClient; };
     103         PRECT  getWindowRect()                 { return &rectWindow; };
     104
     105         DWORD  getFlags()                      { return flags; };
     106         void   setFlags(DWORD newflags)        { flags = newflags; };
     107
     108         HACCEL GetAccelTable()                     { return (HACCEL) acceltableResource; };
     109         BOOL   SetAccelTable(ULONG hAccel);
     110
     111         HMENU  GetMenu()                           { return (HMENU) menuResource; };
     112         BOOL   SetMenu(ULONG hMenu);
     113
     114         BOOL   SetIcon(HICON hIcon);
     115         HICON  GetIcon()                           { return (HICON) iconResource; };
     116
     117         BOOL   ShowWindow(ULONG nCmdShow);
     118         BOOL   SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
     119         BOOL   DestroyWindow();
     120         HWND   SetActiveWindow();
     121         HWND   GetParent();
     122         HWND   SetParent(HWND hwndNewParent);
     123         BOOL   IsChild(HWND hwndParent);
     124         HWND   GetTopWindow();
     125         BOOL   UpdateWindow();
     126         BOOL   IsIconic();
     127         HWND   GetWindow(UINT uCmd);
     128         BOOL   EnableWindow(BOOL fEnable);
     129         BOOL   CloseWindow();
     130  static HWND   GetActiveWindow();
     131         BOOL   IsWindow();
     132         BOOL   IsWindowEnabled();
     133         BOOL   IsWindowVisible();
     134         BOOL   IsUnicode()  { return isUnicode; };
     135
     136         BOOL   GetWindowRect(PRECT pRect);
     137         int    GetWindowTextLengthA();
     138         int    GetWindowTextA(LPSTR lpsz, int cch);
     139         BOOL   SetWindowTextA(LPCSTR lpsz);
     140
     141       LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     142       LRESULT  SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
     143       BOOL     PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     144       BOOL     PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
     145       LRESULT  DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
     146       LRESULT  DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
     147
     148         void   NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
    147149
    148150Win32WndClass  *getClass()  { return windowClass; };
    149151
    150 static  HWND  Win32ToOS2Handle(HWND hwnd)
     152static  HWND  Win32ToOS2Handle(HWND hwnd)
    151153{
    152154 Win32Window *window = GetWindowFromHandle(hwnd);
    153155
    154156  if(window) {
    155         return window->getOS2WindowHandle();
     157        return window->getOS2WindowHandle();
    156158  }
    157   else  return hwnd;    //OS/2 window handle
     159  else  return hwnd;    //OS/2 window handle
    158160}
    159161
    160 static  HWND  OS2ToWin32Handle(HWND hwnd)
     162static  HWND  OS2ToWin32Handle(HWND hwnd)
    161163{
    162164 Win32Window *window = GetWindowFromOS2Handle(hwnd);
    163165
    164166  if(window) {
    165         return window->getWindowHandle();
     167        return window->getWindowHandle();
    166168  }
    167   else  return hwnd;    //OS/2 window handle
     169  else  return hwnd;    //OS/2 window handle
    168170}
    169171
     
    172174
    173175protected:
    174        LRESULT  SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
    175        LRESULT  SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
    176         void    Init();
    177 
    178         HWND    OS2Hwnd;
    179         HWND    OS2HwndFrame;
    180         HWND    OS2HwndMenu;
    181         HWND    Win32Hwnd;
    182         BOOL    isUnicode;
    183 
    184         int     posx, posy, width, height;
    185 
    186         // values normally contained in the standard window words
    187         ULONG   dwExStyle;              //GWL_EXSTYLE
    188         ULONG   dwStyle;                //GWL_STYLE
    189       WNDPROC   win32wndproc;           //GWL_WNDPROC
    190         ULONG   hInstance;              //GWL_HINSTANCE
     176       LRESULT  SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
     177       LRESULT  SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
     178        void    Init();
     179
     180        HWND    OS2Hwnd;
     181        HWND    OS2HwndFrame;
     182        HWND    OS2HwndMenu;
     183        HWND    Win32Hwnd;
     184        BOOL    isUnicode;
     185
     186        int     posx, posy, width, height;
     187
     188        // values normally contained in the standard window words
     189        ULONG   dwExStyle;              //GWL_EXSTYLE
     190        ULONG   dwStyle;                //GWL_STYLE
     191      WNDPROC   win32wndproc;           //GWL_WNDPROC
     192        ULONG   hInstance;              //GWL_HINSTANCE
    191193//Moved in ChildWindow class
    192 /////   Win32Window *parent;                    //GWL_HWNDPARENT
    193         ULONG   windowId;               //GWL_ID
    194         ULONG   userData;               //GWL_USERDATA
    195 
    196          HWND   hwndLinkAfter;
    197         DWORD   flags;
    198         DWORD   lastHitTestVal;         //Last value returned by WM_NCHITTEST handler
    199 
    200         BOOL    isIcon;
    201         BOOL    fCreated;
    202         BOOL    fFirstShow;
     194/////   Win32Window *parent;                    //GWL_HWNDPARENT
     195        ULONG   windowId;               //GWL_ID
     196        ULONG   userData;               //GWL_USERDATA
     197
     198         HWND   hwndLinkAfter;
     199        DWORD   flags;
     200        DWORD   lastHitTestVal;         //Last value returned by WM_NCHITTEST handler
     201
     202        BOOL    isIcon;
     203        BOOL    fCreated;
     204        BOOL    fFirstShow;
    203205
    204206   Win32Window *owner;
     
    208210 Win32Resource *iconResource;
    209211
    210         char    windowNameA[MAX_WINDOW_NAMELENGTH];
    211         WCHAR   windowNameW[MAX_WINDOW_NAMELENGTH];
    212         ULONG   wndNameLength;
    213 
    214         ULONG  *userWindowLong;
    215         ULONG   nrUserWindowLong;
    216 
    217         RECT    rectWindow;
    218         RECT    rectClient;
     212        char    windowNameA[MAX_WINDOW_NAMELENGTH];
     213        WCHAR   windowNameW[MAX_WINDOW_NAMELENGTH];
     214        ULONG   wndNameLength;
     215
     216        ULONG  *userWindowLong;
     217        ULONG   nrUserWindowLong;
     218
     219        RECT    rectWindow;
     220        RECT    rectClient;
    219221
    220222Win32WndClass  *windowClass;
     
    224226private:
    225227#ifndef OS2_INCLUDED
    226         BOOL  CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
    227 
    228         void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
    229 
    230         LONG  SendNCCalcSize(BOOL calcValidRect,
    231                              RECT *newWindowRect, RECT *oldWindowRect,
    232                              RECT *oldClientRect, WINDOWPOS *winpos,
    233                              RECT *newClientRect );
     228        BOOL  CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
     229
     230        void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
     231
     232        LONG  SendNCCalcSize(BOOL calcValidRect,
     233                             RECT *newWindowRect, RECT *oldWindowRect,
     234                             RECT *oldClientRect, WINDOWPOS *winpos,
     235                             RECT *newClientRect );
    234236
    235237     LRESULT  SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
    236238     {
    237         if(isUnicode)
    238                 return SendInternalMessageW(msg, wParam, lParam);
    239         else    return SendInternalMessageA(msg, wParam, lParam);
     239        if(isUnicode)
     240                return SendInternalMessageW(msg, wParam, lParam);
     241        else    return SendInternalMessageA(msg, wParam, lParam);
    240242     }
    241243#endif
     
    243245
    244246
    245 #define BUTTON_LEFTDOWN         0
    246 #define BUTTON_LEFTUP           1
    247 #define BUTTON_LEFTDBLCLICK     2
    248 #define BUTTON_RIGHTUP          3
    249 #define BUTTON_RIGHTDOWN        4
    250 #define BUTTON_RIGHTDBLCLICK    5
    251 #define BUTTON_MIDDLEUP         6
    252 #define BUTTON_MIDDLEDOWN       7
    253 #define BUTTON_MIDDLEDBLCLICK   8
    254 
    255 #define WMMOVE_LBUTTON          1
    256 #define WMMOVE_MBUTTON          2
    257 #define WMMOVE_RBUTTON          4
    258 #define WMMOVE_CTRL             8
    259 #define WMMOVE_SHIFT            16
    260 
    261 
    262 #define CMD_MENU                1
    263 #define CMD_CONTROL             2
    264 #define CMD_ACCELERATOR         3
    265 
    266 #define WIN32SC_SIZE         0xf000
    267 #define WIN32SC_MOVE         0xf010
     247#define BUTTON_LEFTDOWN         0
     248#define BUTTON_LEFTUP           1
     249#define BUTTON_LEFTDBLCLICK     2
     250#define BUTTON_RIGHTUP          3
     251#define BUTTON_RIGHTDOWN        4
     252#define BUTTON_RIGHTDBLCLICK    5
     253#define BUTTON_MIDDLEUP         6
     254#define BUTTON_MIDDLEDOWN       7
     255#define BUTTON_MIDDLEDBLCLICK   8
     256
     257#define WMMOVE_LBUTTON          1
     258#define WMMOVE_MBUTTON          2
     259#define WMMOVE_RBUTTON          4
     260#define WMMOVE_CTRL             8
     261#define WMMOVE_SHIFT            16
     262
     263
     264#define CMD_MENU                1
     265#define CMD_CONTROL             2
     266#define CMD_ACCELERATOR         3
     267
     268#define WIN32SC_SIZE         0xf000
     269#define WIN32SC_MOVE         0xf010
    268270#define WIN32SC_MINIMIZE     0xf020
    269271#define WIN32SC_MAXIMIZE     0xf030
    270272#define WIN32SC_NEXTWINDOW   0xf040
    271273#define WIN32SC_PREVWINDOW   0xf050
    272 #define WIN32SC_CLOSE        0xf060
     274#define WIN32SC_CLOSE        0xf060
    273275#define WIN32SC_VSCROLL      0xf070
    274276#define WIN32SC_HSCROLL      0xf080
     
    279281#define WIN32SC_TASKLIST     0xf130
    280282#define WIN32SC_SCREENSAVE   0xf140
    281 #define WIN32SC_HOTKEY       0xf150
    282 
    283 #define KEY_ALTDOWN             1
    284 #define KEY_PREVDOWN            2
    285 #define KEY_UP                  4
    286 #define KEY_DEADKEY             8
     283#define WIN32SC_HOTKEY       0xf150
     284
     285#define KEY_ALTDOWN             1
     286#define KEY_PREVDOWN            2
     287#define KEY_UP                  4
     288#define KEY_DEADKEY             8
    287289
    288290#endif //__cplusplus
Note: See TracChangeset for help on using the changeset viewer.