Ignore:
Timestamp:
Oct 14, 1999, 11:22:43 AM (26 years ago)
Author:
sandervl
Message:

Window creation rewrite + bugfixes. NOT WORKING CORRECTLY YET..

File:
1 edited

Legend:

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

    r1265 r1281  
    1 /* $Id: win32wbase.cpp,v 1.40 1999-10-13 14:24:27 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.41 1999-10-14 09:22:42 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    4040#include "pmframe.h"
    4141#include "win32wdesktop.h"
     42#include <wprocess.h>
    4243
    4344#define HAS_DLGFRAME(style,exStyle) \
     
    9697{
    9798  isUnicode        = FALSE;
    98   fCreated         = FALSE;
    9999  fFirstShow       = TRUE;
    100100  fIsDialog        = FALSE;
    101101  fInternalMsg     = FALSE;
     102  fNoSizeMsg       = FALSE;
    102103
    103104  windowNameA      = NULL;
     
    203204{
    204205 char  buffer[256];
    205  INT   sw = SW_SHOW;
    206206 POINT maxSize, maxPos, minTrack, maxTrack;
    207207
     
    210210#endif
    211211
     212    sw = SW_SHOW;
    212213    SetLastError(0);
    213214
     
    463464  rectClient        = rectWindow;
    464465
    465 //CB: dwOSFrameStyle handled by OSLibWinConvertStyle
    466 //    OSLibWinCreateWindow: perhaps problems
    467 //    shouldn't we always use a frame? -> no problems with scrollbars
    468 
    469466  if(HIWORD(cs->lpszName))
    470467  {
     
    474471  }
    475472
     473  //copy pointer of CREATESTRUCT for usage in MsgCreate method
     474  tmpcs = cs;
     475
     476  //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
     477  THDB *thdb = GetThreadTHDB();
     478
     479  if(thdb == NULL) {
     480        dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
     481        ExitProcess(666);
     482        return FALSE;
     483  }
     484
     485  thdb->newWindow = (ULONG)this;
     486
    476487  OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    477488                                 dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
     
    485496        return FALSE;
    486497  }
     498  SetLastError(0);
     499  return TRUE;
     500}
     501//******************************************************************************
     502//******************************************************************************
     503BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
     504{
     505 POINT maxPos;
     506 CREATESTRUCTA  *cs = tmpcs;  //pointer to CREATESTRUCT used in CreateWindowExA method
     507
     508  OS2Hwnd      = hwndClient;
     509  OS2HwndFrame = hwndFrame;
     510//  if(!isFrameWindow())
     511//        OS2HwndFrame = hwndClient;
    487512
    488513  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
     
    523548#endif
    524549
    525   if (cs->style & WS_HSCROLL)
     550  if (dwStyle & WS_HSCROLL)
    526551  {
    527552        hwndHorzScroll = OSLibWinQueryScrollBarHandle(OS2HwndFrame, OSLIB_HSCROLL);
    528         OSLibWinShowScrollBar(OS2HwndFrame, hwndHorzScroll, OSLIB_HSCROLL, FALSE, TRUE);
    529   }
    530 
    531   if (cs->style & WS_VSCROLL) {
     553//        OSLibWinShowScrollBar(OS2HwndFrame, hwndHorzScroll, OSLIB_HSCROLL, FALSE, TRUE);
     554  }
     555
     556  if (dwStyle & WS_VSCROLL) {
    532557        hwndVertScroll = OSLibWinQueryScrollBarHandle(OS2HwndFrame, OSLIB_VSCROLL);
    533         OSLibWinShowScrollBar(OS2HwndFrame, hwndVertScroll, OSLIB_VSCROLL, FALSE, TRUE);
     558//        OSLibWinShowScrollBar(OS2HwndFrame, hwndVertScroll, OSLIB_VSCROLL, FALSE, TRUE);
    534559  }
    535560
     
    558583  if(windowClass->getIcon())
    559584        SetIcon(windowClass->getIcon());
    560 
    561   if(getParent()) {
    562         SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
    563                      rectClient.right-rectClient.left,
    564                      rectClient.bottom-rectClient.top,
    565                      SWP_NOACTIVATE | SWP_NOZORDER );
    566   }
    567   else {
    568         SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
    569                      rectClient.right-rectClient.left,
    570                      rectClient.bottom-rectClient.top,
    571                      SWP_NOACTIVATE);
    572   }
    573585
    574586  //Subclass frame
     
    580592  }
    581593
    582   //Get the client window rectangle
    583   GetClientRect(Win32Hwnd, &rectClient);
    584 
    585594  /* Send the WM_CREATE message
    586595   * Perhaps we shouldn't allow width/height changes as well.
     
    589598  maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
    590599
     600  fNoSizeMsg = TRUE;
     601  if(getParent()) {
     602        SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
     603                     rectClient.right-rectClient.left,
     604                     rectClient.bottom-rectClient.top,
     605                     SWP_NOACTIVATE | SWP_NOZORDER );
     606  }
     607  else {
     608        SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
     609                     rectClient.right-rectClient.left,
     610                     rectClient.bottom-rectClient.top,
     611                     SWP_NOACTIVATE);
     612  }
     613  fNoSizeMsg = FALSE;
     614
    591615  if(SendMessageA(WM_NCCREATE, 0, (LPARAM)cs) )
    592616  {
    593         fCreated = TRUE; //Allow WM_SIZE messages now
    594617        SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
    595618
     
    604627                SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    605628            }
     629
    606630            if (cs->style & WS_VISIBLE) ShowWindow( sw );
    607631
     
    617641  }
    618642  dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
    619   fCreated = FALSE;
    620   OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
    621   OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
    622   DestroyWindow();
    623643  SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
    624644  return FALSE;
    625 }
    626 //******************************************************************************
    627 //******************************************************************************
    628 ULONG Win32BaseWindow::MsgCreate(HWND hwndOS2, ULONG initParam)
    629 {
    630   OS2Hwnd = hwndOS2;
    631   return SendInternalMessageA(WM_CREATE, 0, initParam);
    632645}
    633646//******************************************************************************
     
    680693{
    681694    dprintf(("MsgPosChanging"));
    682 #if 1
    683     if(fCreated == FALSE) {
     695    if(fNoSizeMsg)
    684696        return 1;
    685     }
    686 #endif
     697
    687698    return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
    688699}
     
    692703{
    693704    dprintf(("MsgPosChanged"));
    694 #if 1
    695     if(fCreated == FALSE) {
     705    if(fNoSizeMsg)
    696706        return 1;
    697     }
    698 #endif
     707
    699708    return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
    700709}
     
    704713{
    705714    dprintf(("MsgMove to (%d,%d)", x, y));
    706     if(fCreated == FALSE) {
     715    if(fNoSizeMsg)
    707716        return 1;
    708     }
    709717
    710718    return SendInternalMessageA(WM_MOVE, 0, MAKELONG((USHORT)x, (USHORT)y));
     
    755763{
    756764 WORD fwSizeType = 0;
    757 
    758     if(fCreated == FALSE) {//Solitaire crashes if it receives a WM_SIZE during CreateWindowEx (normal or our fault?)
    759         return 1;
    760     }
    761765
    762766    if(fMinimize) {
     
    11151119}
    11161120//******************************************************************************
     1121//******************************************************************************
     1122BOOL Win32BaseWindow::isFrameWindow()
     1123{
     1124    if((getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
     1125        return TRUE;
     1126
     1127    return FALSE;
     1128}
     1129//******************************************************************************
    11171130//TODO: Not complete (flags)
    11181131//******************************************************************************
     
    11761189        {
    11771190            infoPtr->Page = info->nPage;
     1191            dprintf(("SetScrollInfo: Set pagesize to %d", info->nPage));
    11781192            OSLibWinSetScrollPageSize(OS2HwndFrame, hwndScroll, info->nPage, infoPtr->MaxVal, fRedraw);
    11791193        }
     
    11861200        {
    11871201            infoPtr->CurVal = info->nPos;
     1202            dprintf(("SetScrollInfo: Set scroll position to %d", info->nPos));
    11881203            OSLibWinSetScrollPos(OS2HwndFrame, hwndScroll, info->nPos, fRedraw);
    11891204        }
     
    12081223                infoPtr->MaxVal = info->nMax;
    12091224
     1225                dprintf(("SetScrollInfo: Set scroll range to (%d,%d)", info->nMin, info->nMax));
    12101226                OSLibWinSetScrollRange(OS2HwndFrame, hwndScroll, info->nMin, info->nMax, fRedraw);
    12111227            }
     
    19842000       {
    19852001           hParent = getParent()->getOS2WindowHandle();
    1986            OSLibWinQueryWindowPos(isFrameWindow() ? OS2HwndFrame:OS2Hwnd, &swpOld);
    19872002       }
    1988        else
    1989            OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
     2003       OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
    19902004   }
    19912005
     
    19942008      return TRUE;
    19952009
    1996    if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
     2010//   if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
     2011   if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
    19972012   {
    1998       Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
    1999       swp.hwndInsertBehind   = wndBehind->getOS2WindowHandle();
     2013        Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
     2014        if(wndBehind) {
     2015            swp.hwndInsertBehind   = wndBehind->getOS2WindowHandle();
     2016        }
     2017        else {
     2018            dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
     2019            swp.hwndInsertBehind = 0;
     2020        }
    20002021   }
     2022#if 0
    20012023   if (isFrameWindow())
    20022024   {
     
    20152037   }
    20162038   else
    2017       swp.hwnd = OS2Hwnd;
     2039#endif
     2040      swp.hwnd = OS2HwndFrame;
    20182041
    20192042   dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
Note: See TracChangeset for help on using the changeset viewer.