Ignore:
Timestamp:
Aug 28, 1999, 9:33:04 PM (26 years ago)
Author:
sandervl
Message:

Window handle changes (now allocated in shared array) + postmessage changes + fixes

File:
1 edited

Legend:

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

    r728 r729  
    1 /* $Id: win32wnd.cpp,v 1.33 1999-08-28 17:24:45 dengert Exp $ */
     1/* $Id: win32wnd.cpp,v 1.34 1999-08-28 19:32:47 sandervl Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    2323#include <assert.h>
    2424#include <misc.h>
    25 #include <handlemanager.h>
    2625#include <heapstring.h>
    2726#include <win32wnd.h>
     
    3332#include <oslibgdi.h>
    3433#include <oslibres.h>
     34#include "oslibdos.h"
    3535#include <winres.h>
    3636#include "syscolor.h"
     37#include "win32wndhandle.h"
     38#include "heapshared.h"
    3739
    3840#define HAS_DLGFRAME(style,exStyle) \
     
    8688  Win32Hwnd        = 0;
    8789
    88   if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0)
     90  if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
    8991  {
    90         dprintf(("Win32Window::Init HMHandleAllocate failed!!"));
     92        dprintf(("Win32Window::Init HwAllocateWindowHandle failed!!"));
    9193        DebugInt3();
    9294  }
    93   Win32Hwnd       &= 0xFFFF;
    94   Win32Hwnd       |= 0x68000000;
    9595
    9696  posx = posy      = 0;
     
    124124
    125125  if(Win32Hwnd)
    126         HMHandleFree(Win32Hwnd & 0xFFFF);
     126        HwFreeWindowHandle(Win32Hwnd);
     127
    127128  if(userWindowLong)
    128129        free(userWindowLong);
     
    269270        if(owner == NULL)
    270271        {
    271             dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
     272            dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
    272273            return FALSE;
    273274        }
     
    283284            if(owner == NULL)
    284285            {
    285                 dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
     286                dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
    286287                return FALSE;
    287288            }
     
    403404        return FALSE;
    404405  }
     406  //SvL: Need to store the shared memory base, or else other apps can map it into their memory space
     407  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) {
     408        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
     409        return FALSE;
     410  }
    405411#if 0
    406412  if(OS2Hwnd != OS2HwndFrame) {
     
    410416    }
    411417    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
     418            dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
     419            return FALSE;
     420    }
     421    //SvL: Need to store the shared memory base, or else other apps can map it into their memory space
     422    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) {
    412423            dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
    413424            return FALSE;
     
    13341345BOOL Win32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
    13351346{
    1336  POSTMSG_PACKET *postmsg;
    1337 
    1338   postmsg = (POSTMSG_PACKET *)malloc(sizeof(POSTMSG_PACKET));
    1339   if(postmsg == NULL) {
    1340     dprintf(("Win32Window::PostMessageA: malloc returned NULL!!"));
    1341     return 0;
    1342   }
    1343   postmsg->Msg    = msg;
    1344   postmsg->wParam = wParam;
    1345   postmsg->lParam = lParam;
    1346   return OSLibPostMessage(OS2Hwnd, WM_WIN32_POSTMESSAGEA, (ULONG)postmsg, 0);
     1347  return OSLibPostMessage(OS2Hwnd, WIN32APP_USERMSGBASE+msg, wParam, lParam);
    13471348}
    13481349//******************************************************************************
     
    13501351BOOL Win32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
    13511352{
    1352  POSTMSG_PACKET *postmsg;
    1353 
    1354   postmsg = (POSTMSG_PACKET *)malloc(sizeof(POSTMSG_PACKET));
    1355   if(postmsg == NULL) {
    1356     dprintf(("Win32Window::PostMessageW: malloc returned NULL!!"));
    1357     return 0;
    1358   }
    1359   postmsg->Msg    = msg;
    1360   postmsg->wParam = wParam;
    1361   postmsg->lParam = lParam;
    1362   return OSLibPostMessage(OS2Hwnd, WM_WIN32_POSTMESSAGEW, (ULONG)postmsg, 0);
     1353  return OSLibPostMessage(OS2Hwnd, WIN32APP_USERMSGBASE+msg, wParam, lParam);
    13631354}
    13641355//******************************************************************************
     
    17431734        while(hwnd)
    17441735        {
    1745             HWND hwndClient;
    1746 
    17471736            wnd = GetWindowFromOS2Handle(hwnd);
    17481737            if(wnd == NULL) {
    1749                 hwndClient = OSLibWinQueryClientWindow(hwnd);
    1750                 if(hwndClient)  wnd = GetWindowFromOS2Handle(hwndClient);
     1738                hwnd = OSLibWinQueryClientWindow(hwnd);
     1739                if(hwnd)  wnd = GetWindowFromOS2Handle(hwnd);
    17511740            }
    17521741
    1753             if(wnd && wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
    1754                (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
    1755             {
    1756                 OSLibWinEndEnumWindows(henum);
    1757                 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
    1758                 return wnd->getWindowHandle();
     1742            if(wnd) {
     1743                LPVOID sharedmembase = (LPVOID)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_SHAREDMEM);
     1744
     1745                if(OSLibDosGetSharedMem(sharedmembase, MAX_HEAPSIZE, OSLIB_PAG_READ) != 0) {
     1746                    dprintf(("OSLibDosGetSharedMem returned error for %x", wnd));
     1747                    break;
     1748                }
     1749                if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
     1750                   (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
     1751                {
     1752                    OSLibWinEndEnumWindows(henum);
     1753                    dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
     1754                    return wnd->getWindowHandle();
     1755                }
    17591756            }
    17601757            hwnd = OSLibWinGetNextWindow(henum);
     
    20332030 Win32Window *window;
    20342031
    2035    if(HIWORD(hwnd) != 0x6800) {
    2036         return NULL;
    2037    }
    2038 
    2039    if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) {
     2032   if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
    20402033        return window;
    20412034   }
Note: See TracChangeset for help on using the changeset viewer.