Ignore:
Timestamp:
Jul 18, 1999, 8:04:30 PM (26 years ago)
Author:
sandervl
Message:

* empty log message *

File:
1 edited

Legend:

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

    r331 r332  
    1 /* $Id: window.cpp,v 1.6 1999-07-18 17:12:03 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.7 1999-07-18 18:04:30 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    118118//******************************************************************************
    119119//******************************************************************************
    120 HWND WIN32API CreateWindowExW(DWORD     arg1,
    121                               LPCWSTR   arg2,
    122                               LPCWSTR   arg3,
    123                               DWORD     dwStyle,
    124                               int       arg5,
    125                               int       arg6,
    126                               int       arg7,
    127                               int       arg8,
    128                               HWND      arg9,
    129                               HMENU     arg10,
    130                               HINSTANCE arg11,
    131                               PVOID     arg12)
    132 {
    133   HWND hwnd;
    134   char *astring1 = NULL,
    135        *astring2 = NULL;
    136 
    137   /* @@@PH 98/06/21 changed to call OS2CreateWindowExA */
    138   if(HIWORD(arg2) != 0)
    139     astring1 = UnicodeToAsciiString((LPWSTR)arg2);
    140   else
    141     astring1 = (char *)arg2;
    142 
    143   astring2 = UnicodeToAsciiString((LPWSTR)arg3);
    144 
    145 #ifdef DEBUG
    146     WriteLog("USER32:  CreateWindowExW: dwExStyle = %X\n", arg1);
    147     if((int)arg2 >> 16 != 0)
    148          WriteLog("USER32:  CreateWindow: classname = %s\n", astring1);
    149     else WriteLog("USER32:  CreateWindow: classname = %X\n", arg2);
    150     WriteLog("USER32:  CreateWindow: windowname= %s\n", astring2);
    151     WriteLog("USER32:  CreateWindow: dwStyle   = %X\n", dwStyle);
    152     WriteLog("USER32:  CreateWindow: x         = %d\n", arg5);
    153     WriteLog("USER32:  CreateWindow: y         = %d\n", arg6);
    154     WriteLog("USER32:  CreateWindow: nWidth    = %d\n", arg7);
    155     WriteLog("USER32:  CreateWindow: nHeight   = %d\n", arg8);
    156     WriteLog("USER32:  CreateWindow: parent    = %X\n", arg9);
    157     WriteLog("USER32:  CreateWindow: hwmenu    = %X\n", arg10);
    158     WriteLog("USER32:  CreateWindow: hinstance = %X\n", arg11);
    159     WriteLog("USER32:  CreateWindow: param     = %X\n", arg12);
    160  #endif
    161 
    162   hwnd = CreateWindowExA(arg1,
    163                             astring1,
    164                             astring2,
    165                             dwStyle,
    166                             arg5,
    167                             arg6,
    168                             arg7,
    169                             arg8,
    170                             arg9,
    171                             arg10,
    172                             arg11,
    173                             arg12);
    174 
    175     if(HIWORD(arg1) != 0)
    176         FreeAsciiString(astring1);
    177 
    178     FreeAsciiString(astring2);
    179 
    180 #ifdef DEBUG
    181     WriteLog("USER32:  ************CreateWindowExW hwnd = %X (%X)\n", hwnd, GetLastError());
    182 #endif
    183     return(hwnd);
     120HWND WIN32API CreateWindowExW(DWORD exStyle, LPCWSTR className,
     121                              LPCWSTR windowName, DWORD style, INT x,
     122                              INT y, INT width, INT height,
     123                              HWND parent, HMENU menu,
     124                              HINSTANCE instance, LPVOID data )
     125{
     126  Win32Window *window;
     127  ATOM classAtom;
     128  CREATESTRUCTA cs;
     129
     130    if(exStyle & WS_EX_MDICHILD)
     131        return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
     132
     133    /* Find the class atom */
     134    if (!(classAtom = GlobalFindAtomW(className)))
     135    {
     136        dprintf(("CreateWindowEx32A: bad class name "));
     137        if (!HIWORD(className)) {
     138                dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
     139        }
     140//        else    dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
     141        SetLastError(ERROR_INVALID_PARAMETER);
     142        return 0;
     143    }
     144
     145    /* Create the window */
     146    cs.lpCreateParams = data;
     147    cs.hInstance      = instance;
     148    cs.hMenu          = menu;
     149    cs.hwndParent     = parent;
     150    cs.x              = x;
     151    cs.y              = y;
     152    cs.cx             = width;
     153    cs.cy             = height;
     154    cs.style          = style;
     155    cs.lpszName       = (LPSTR)windowName;
     156    cs.lpszClass      = (LPSTR)className;
     157    cs.dwExStyle      = exStyle;
     158    window = new Win32Window( &cs, classAtom, TRUE );
     159    if(window == NULL)
     160    {
     161        dprintf(("Win32Window creation failed!!"));
     162        return 0;
     163    }
     164    if(GetLastError() != 0)
     165    {
     166        dprintf(("Win32Window error found!!"));
     167        delete window;
     168        return 0;
     169    }
     170    return window->getWindowHandle();
    184171}
    185172//******************************************************************************
     
    191178    window = Win32Window::GetWindowFromHandle(hwnd);
    192179    if(!window) {
    193         dprintf(("DestroyWindow, window %x not found", hwnd));
    194         return 0;
     180        dprintf(("DestroyWindow, window %x not found", hwnd));
     181        return 0;
    195182    }
    196183    dprintf(("DestroyWindow %x", hwnd));
     
    205192    window = Win32Window::GetWindowFromHandle(hwnd);
    206193    if(!window) {
    207         dprintf(("SetActiveWindow, window %x not found", hwnd));
    208         return 0;
     194        dprintf(("SetActiveWindow, window %x not found", hwnd));
     195        return 0;
    209196    }
    210197    dprintf(("SetActiveWindow %x", hwnd));
     
    219206    window = Win32Window::GetWindowFromHandle(hwnd);
    220207    if(!window) {
    221         dprintf(("GetParent, window %x not found", hwnd));
    222         return 0;
     208        dprintf(("GetParent, window %x not found", hwnd));
     209        return 0;
    223210    }
    224211    dprintf(("GetParent %x", hwnd));
     
    233220    window = Win32Window::GetWindowFromHandle(hwndChild);
    234221    if(!window) {
    235         dprintf(("SetParent, window %x not found", hwndChild));
    236         return 0;
     222        dprintf(("SetParent, window %x not found", hwndChild));
     223        return 0;
    237224    }
    238225    dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
     
    247234    window = Win32Window::GetWindowFromHandle(hwnd);
    248235    if(!window) {
    249         dprintf(("IsChild, window %x not found", hwnd));
    250         return 0;
     236        dprintf(("IsChild, window %x not found", hwnd));
     237        return 0;
    251238    }
    252239    dprintf(("IsChild %x %x", hwndParent, hwnd));
     
    261248    window = Win32Window::GetWindowFromHandle(hwnd);
    262249    if(!window) {
    263         dprintf(("GetTopWindow, window %x not found", hwnd));
    264         return 0;
     250        dprintf(("GetTopWindow, window %x not found", hwnd));
     251        return 0;
    265252    }
    266253    dprintf(("GetTopWindow %x", hwnd));
     
    275262    window = Win32Window::GetWindowFromHandle(hwnd);
    276263    if(!window) {
    277         dprintf(("UpdateWindow, window %x not found", hwnd));
    278         return 0;
     264        dprintf(("UpdateWindow, window %x not found", hwnd));
     265        return 0;
    279266    }
    280267    dprintf(("UpdateWindow %x", hwnd));
     
    289276    window = Win32Window::GetWindowFromHandle(hwnd);
    290277    if(!window) {
    291         dprintf(("IsIconic, window %x not found", hwnd));
    292         return 0;
     278        dprintf(("IsIconic, window %x not found", hwnd));
     279        return 0;
    293280    }
    294281    dprintf(("IsIconic %x", hwnd));
     
    303290    window = Win32Window::GetWindowFromHandle(hwnd);
    304291    if(!window) {
    305         dprintf(("GetWindow, window %x not found", hwnd));
    306         return 0;
     292        dprintf(("GetWindow, window %x not found", hwnd));
     293        return 0;
    307294    }
    308295    dprintf(("GetWindow %x %d", hwnd, uCmd));
     
    326313    window = Win32Window::GetWindowFromHandle(hwnd);
    327314    if(!window) {
    328         dprintf(("EnableWindow, window %x not found", hwnd));
    329         return 0;
     315        dprintf(("EnableWindow, window %x not found", hwnd));
     316        return 0;
    330317    }
    331318    dprintf(("EnableWindow %x %d", hwnd, fEnable));
     
    340327    window = Win32Window::GetWindowFromHandle(hwnd);
    341328    if(!window) {
    342         dprintf(("BringWindowToTop, window %x not found", hwnd));
    343         return 0;
     329        dprintf(("BringWindowToTop, window %x not found", hwnd));
     330        return 0;
    344331    }
    345332    dprintf(("BringWindowToTop %x", hwnd));
     
    360347    window = Win32Window::GetWindowFromHandle(hwnd);
    361348    if(!window) {
    362         dprintf(("ShowWindow, window %x not found", hwnd));
    363         return 0;
     349        dprintf(("ShowWindow, window %x not found", hwnd));
     350        return 0;
    364351    }
    365352    dprintf(("ShowWindow %x", hwnd));
     
    374361    window = Win32Window::GetWindowFromHandle(hwnd);
    375362    if(!window) {
    376         dprintf(("SetWindowPos, window %x not found", hwnd));
    377         return 0;
     363        dprintf(("SetWindowPos, window %x not found", hwnd));
     364        return 0;
    378365    }
    379366    dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
     
    395382    window = Win32Window::GetWindowFromHandle(hwnd);
    396383    if(!window) {
    397         dprintf(("IsWindow, window %x not found", hwnd));
    398         return FALSE;
     384        dprintf(("IsWindow, window %x not found", hwnd));
     385        return FALSE;
    399386    }
    400387    dprintf(("IsWindow %x", hwnd));
     
    409396    window = Win32Window::GetWindowFromHandle(hwnd);
    410397    if(!window) {
    411         dprintf(("IsWindowEnabled, window %x not found", hwnd));
    412         return 0;
     398        dprintf(("IsWindowEnabled, window %x not found", hwnd));
     399        return 0;
    413400    }
    414401    dprintf(("IsWindowEnabled %x", hwnd));
     
    423410    window = Win32Window::GetWindowFromHandle(hwnd);
    424411    if(!window) {
    425         dprintf(("IsWindowVisible, window %x not found", hwnd));
    426         return 0;
     412        dprintf(("IsWindowVisible, window %x not found", hwnd));
     413        return 0;
    427414    }
    428415    dprintf(("IsWindowVisible %x", hwnd));
     
    469456    if (O32_GetWindowPlacement( hwnd, &wndpl ))
    470457    {
    471         if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
    472         if (ptIcon)  *ptIcon = wndpl.ptMinPosition;
    473         return wndpl.showCmd;
     458        if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
     459        if (ptIcon)  *ptIcon = wndpl.ptMinPosition;
     460        return wndpl.showCmd;
    474461    }
    475462    return 0;
     
    516503    window = Win32Window::GetWindowFromHandle(hwnd);
    517504    if(!window) {
    518         dprintf(("GetWindowRect, window %x not found", hwnd));
    519         return 0;
     505        dprintf(("GetWindowRect, window %x not found", hwnd));
     506        return 0;
    520507    }
    521508    dprintf(("GetWindowRect %x", hwnd));
     
    530517    window = Win32Window::GetWindowFromHandle(hwnd);
    531518    if(!window) {
    532         dprintf(("GetWindowTextLength, window %x not found", hwnd));
    533         return 0;
     519        dprintf(("GetWindowTextLength, window %x not found", hwnd));
     520        return 0;
    534521    }
    535522    dprintf(("GetWindowTextLength %x", hwnd));
     
    544531    window = Win32Window::GetWindowFromHandle(hwnd);
    545532    if(!window) {
    546         dprintf(("GetWindowTextA, window %x not found", hwnd));
    547         return 0;
     533        dprintf(("GetWindowTextA, window %x not found", hwnd));
     534        return 0;
    548535    }
    549536    dprintf(("GetWindowTextA %x", hwnd));
     
    558545    window = Win32Window::GetWindowFromHandle(hwnd);
    559546    if(!window) {
    560         dprintf(("SetWindowTextA, window %x not found", hwnd));
    561         return 0;
     547        dprintf(("SetWindowTextA, window %x not found", hwnd));
     548        return 0;
    562549    }
    563550    dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
     
    716703//******************************************************************************
    717704//******************************************************************************
    718 BOOL WIN32API CloseWindow( HWND arg1)
    719 {
    720 #ifdef DEBUG
    721     WriteLog("USER32:  CloseWindow\n");
    722 #endif
    723     return O32_CloseWindow(arg1);
    724 }
    725 //******************************************************************************
    726 //******************************************************************************
    727 HWND WIN32API WindowFromDC( HDC arg1)
     705BOOL WIN32API CloseWindow(HWND hwnd)
     706{
     707   Win32Window *window;
     708
     709    window = Win32Window::GetWindowFromHandle(hwnd);
     710    if(!window) {
     711        dprintf(("CloseWindow, window %x not found", hwnd));
     712        return 0;
     713    }
     714    dprintf(("CloseWindow %x\n", hwnd));
     715    return window->CloseWindow();
     716}
     717//******************************************************************************
     718//******************************************************************************
     719HWND WIN32API WindowFromDC(HDC hdc)
    728720{
    729721#ifdef DEBUG
    730722    WriteLog("USER32:  WindowFromDC\n");
    731723#endif
    732     return O32_WindowFromDC(arg1);
    733 }
    734 //******************************************************************************
    735 //******************************************************************************
    736 HWND WIN32API WindowFromPoint( POINT arg1)
    737 {
    738 #ifdef DEBUG
    739     WriteLog("USER32:  WindowFromPoint\n");
    740 #endif
    741     return O32_WindowFromPoint(arg1);
     724    return O32_WindowFromDC(hdc);
     725}
     726//******************************************************************************
     727//TODO: Does this return handles of hidden or disabled windows?
     728//******************************************************************************
     729HWND WIN32API WindowFromPoint( POINT point)
     730{
     731 HWND hwnd;
     732
     733    dprintf(("WindowFromPoint (%d,%d)\n", point.x, point.y));
     734    hwnd = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&point);
     735    if(hwnd) {
     736        return Win32Window::OS2ToWin32Handle(hwnd);
     737    }
     738    return 0;
    742739}
    743740//******************************************************************************
     
    745742BOOL WIN32API IsWindowUnicode(HWND hwnd)
    746743{
    747 #ifdef DEBUG
    748   WriteLog("USER32:  IsWindowUnicode, not implemented\n");
    749 #endif
    750   return(FALSE);
     744   Win32Window *window;
     745
     746    window = Win32Window::GetWindowFromHandle(hwnd);
     747    if(!window) {
     748        dprintf(("IsWindowUnicode, window %x not found", hwnd));
     749        return 0;
     750    }
     751    return window->IsUnicode();
    751752}
    752753/*****************************************************************************
     
    863864//******************************************************************************
    864865//******************************************************************************
    865 BOOL WIN32API EnableScrollBar( HWND arg1, INT arg2, UINT  arg3)
    866 {
    867 #ifdef DEBUG
    868     WriteLog("USER32:  EnableScrollBar\n");
    869 #endif
    870     //CB: implement in window class
    871     return O32_EnableScrollBar(arg1, arg2, arg3);
    872 }
    873 //******************************************************************************
    874 //******************************************************************************
    875866UINT WIN32API ArrangeIconicWindows( HWND arg1)
    876867{
Note: See TracChangeset for help on using the changeset viewer.