Ignore:
Timestamp:
Dec 16, 1999, 1:11:49 AM (26 years ago)
Author:
sandervl
Message:

sendmessage + hook updates + misc fixes

File:
1 edited

Legend:

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

    r2076 r2084  
    1 /* $Id: win32wbase.cpp,v 1.110 1999-12-14 19:13:19 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.111 1999-12-16 00:11:46 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    1111 *
    1212 * TODO: Not thread/process safe
    13  * TODO: Calling window handler directly from SendMessageA/W can cause problems
    14  *       for GetMessageTime/Pos & InSendMessage
    1513 *
    1614 * Project Odin Software License can be found in LICENSE.TXT
     
    2826#include <winres.h>
    2927#include "wndmsg.h"
    30 #include "hooks.h"
    3128#include "oslibwin.h"
    3229#include "oslibutil.h"
     
    4441#include <wprocess.h>
    4542#include "winmouse.h"
     43#include <win\hook.h>
    4644
    4745#define HAS_DLGFRAME(style,exStyle) \
     
    8179
    8280static fDestroyAll = FALSE;
     81//For quick lookup of current process id
     82static ULONG currentProcessId = -1;
    8383
    8484//******************************************************************************
     
    145145  fNoSizeMsg       = FALSE;
    146146  fIsDestroyed     = FALSE;
     147  fDestroyWindowCalled = FALSE;
    147148  fCreated         = FALSE;
    148149  fTaskList        = FALSE;
     
    203204
    204205  ownDC              = 0;
     206
     207  if(currentProcessId == -1)
     208  {
     209        currentProcessId = GetCurrentProcessId();
     210  }
     211  dwThreadId         = GetCurrentThreadId();
     212  dwProcessId        = currentProcessId;
    205213}
    206214//******************************************************************************
     
    461469  windowClass->IncreaseWindowCount();
    462470
     471  if (HOOK_IsHooked( WH_CBT ))
     472  {
     473        CBT_CREATEWNDA cbtc;
     474        LRESULT ret;
     475
     476        cbtc.lpcs = cs;
     477        cbtc.hwndInsertAfter = hwndLinkAfter;
     478        ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
     479        if(ret)
     480        {
     481            dprintf(("CBT-hook returned 0!!"));
     482            SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
     483            return FALSE;
     484        }
     485  }
     486
    463487  /* Correct the window style */
    464488  if (!(cs->style & WS_CHILD))
     
    510534  }
    511535
    512   if(((cs->style & 0xC0000000) == WS_OVERLAPPED) && ((cs->style & WS_CAPTION) == WS_CAPTION) && owner == NULL)
     536  if(((dwStyle & 0xC0000000) == WS_OVERLAPPED) && ((dwStyle & WS_CAPTION) == WS_CAPTION) && owner == NULL
     537     && dwStyle & WS_SYSMENU)
    513538  {
    514             fTaskList = TRUE;
     539        fTaskList = TRUE;
    515540  }
    516541
     
    697722  fNoSizeMsg = FALSE;
    698723
    699   if(SendMessageA(WM_NCCREATE, 0, (LPARAM)cs) )
     724  if(SendInternalMessageA(WM_NCCREATE, 0, (LPARAM)cs) )
    700725  {
    701726        fCreated = TRUE;
     
    704729
    705730//        OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
    706         if( (SendMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
     731        if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
    707732        {
    708733            if(!(flags & WIN_NEED_SIZE)) {
    709                 SendMessageA(WM_SIZE, SIZE_RESTORED,
     734                SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
    710735                                MAKELONG(rectClient.right-rectClient.left,
    711736                                         rectClient.bottom-rectClient.top));
    712                 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     737                SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    713738            }
    714739
     740            if( getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
     741            {
     742                /* Notify the parent window only */
     743                SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
     744                if(!::IsWindow(getWindowHandle()))
     745                {
     746                    dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
     747                    goto end;
     748                }
     749            }
     750
    715751            if (cs->style & WS_VISIBLE) ShowWindow( sw );
    716752
    717 #if 0
    718753            /* Call WH_SHELL hook */
    719 
    720             if (!(dwStyle & WS_CHILD) && !owner)
    721                 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
    722 #endif
     754            if (!(getStyle() & WS_CHILD) && !owner)
     755                HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 );
     756
    723757            SetLastError(0);
    724758            return TRUE;
     
    727761  dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
    728762  SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
     763end:
    729764  return FALSE;
    730765}
     
    755790
    756791    fIsDestroyed = TRUE;
    757     //According to the SDK, WM_PARENTNOTIFY messages are sent to the parent (this window)
    758     //before any window destruction has begun
    759     child = (Win32BaseWindow *)getFirstChild();
    760     while(child) {
    761         child->NotifyParent(WM_DESTROY, 0, 0);
    762 
    763         child = (Win32BaseWindow *)child->getNextChild();
     792
     793    if(fDestroyWindowCalled == FALSE)
     794    {//this window was destroyed because DestroyWindow was called for it's parent
     795     //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
     796        if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
     797        {
     798            if(getParent())
     799            {
     800                    /* Notify the parent window only */
     801                    getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
     802            }
     803            else    DebugInt3();
     804        }
    764805    }
    765806    SendInternalMessageA(WM_DESTROY, 0, 0);
     807    SendInternalMessageA(WM_NCDESTROY, 0, 0);
    766808
    767809    if (hwndHorzScroll && OSLibWinQueryWindow(hwndHorzScroll,QWOS_PARENT) == OSLibWinQueryObjectWindow()) OSLibWinDestroyWindow(hwndHorzScroll);
     
    828870    return SendInternalMessageA(WM_MOVE, 0, MAKELONG((USHORT)x, (USHORT)y));
    829871}
     872//******************************************************************************
     873//******************************************************************************
     874#if 0
     875ULONG Win32BaseWindow::MsgMinMax()
     876{
     877
     878}
     879#endif
    830880//******************************************************************************
    831881//******************************************************************************
     
    901951{
    902952 ULONG rc, curprocid, procidhwnd = -1, threadidhwnd = 0;
     953
    903954
    904955    //According to SDK docs, if app returns FALSE & window is being deactivated,
     
    11511202
    11521203        /* Activate the window if needed */
    1153     if(isSubclassedOS2Wnd()) {
    1154         Win32BaseWindow *parentwnd = GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT));
    1155         if(parentwnd) {
    1156             hwndTop = (parentwnd->GetTopParent()) ? parentwnd->GetTopParent()->getWindowHandle() : 0;
    1157         }
    1158         else    hwndTop = 0;
    1159     }
    1160     else    hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;
     1204        if(isSubclassedOS2Wnd()) {
     1205                Win32BaseWindow *parentwnd = GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT));
     1206                if(parentwnd) {
     1207                        hwndTop = (parentwnd->GetTopParent()) ? parentwnd->GetTopParent()->getWindowHandle() : 0;
     1208                }
     1209                else    hwndTop = 0;
     1210        }
     1211        else    hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;
    11611212
    11621213        if (hwndTop && getWindowHandle() != GetActiveWindow())
    11631214        {
    1164                 LONG ret = SendMessageA(WM_MOUSEACTIVATE, hwndTop,
    1165                                         MAKELONG( HTCLIENT, win32msg ) );
     1215                LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop,
     1216                                                MAKELONG( HTCLIENT, win32msg ) );
    11661217
    11671218#if 0
     
    14471498
    14481499    case SC_CLOSE:
    1449         return SendMessageA(WM_CLOSE, 0, 0);
     1500        return SendInternalMessageA(WM_CLOSE, 0, 0);
    14501501
    14511502#if 0
     
    16271678        {
    16281679            if(getParent()) {
    1629                 LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
     1680                LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam );
    16301681                if(rc)  return rc;
    16311682            }
     
    16391690        {
    16401691            if(getParent()) {
    1641                 LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
     1692                LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam);
    16421693                if(rc)  return rc;
    16431694            }
     
    16651716
    16661717        if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
    1667             SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
     1718            SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
    16681719
    16691720        if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
     
    16721723            else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
    16731724
    1674             SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right  - rectClient.left,
     1725            SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right  - rectClient.left,
    16751726                                               rectClient.bottom - rectClient.top));
    16761727        }
     
    17791830          // key matches siblings mnemonic, send mouseclick
    17801831          if (mnemonic == (char) wParam) {
    1781             siblingWindow->SendMessageA (BM_CLICK, 0, 0);
     1832            siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0);
    17821833          }
    17831834
     
    18731924LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
    18741925{
     1926 POSTMSG_PACKET *packet;
     1927
     1928    //if the destination window is created by this process & thread, call window proc directly
     1929    if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
     1930        return SendInternalMessageA(Msg, wParam, lParam);
     1931    }
     1932    //otherwise use WinSendMsg to send it to the right process/thread
     1933    packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
     1934    packet->Msg = Msg;
     1935    packet->wParam = wParam;
     1936    packet->lParam = lParam;
     1937    packet->fUnicode = FALSE;
     1938    return OSLibSendMessage(getOS2WindowHandle(), WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet);
     1939}
     1940//******************************************************************************
     1941//******************************************************************************
     1942LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
     1943{
     1944 POSTMSG_PACKET *packet;
     1945
     1946    //if the destination window is created by this process & thread, call window proc directly
     1947    if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
     1948        return SendInternalMessageA(Msg, wParam, lParam);
     1949    }
     1950    //otherwise use WinSendMsg to send it to the right process/thread
     1951    packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
     1952    packet->Msg = Msg;
     1953    packet->wParam = wParam;
     1954    packet->lParam = lParam;
     1955    packet->fUnicode = TRUE;
     1956    return OSLibSendMessage(getOS2WindowHandle(), WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet);
     1957}
     1958//******************************************************************************
     1959//Called as a result of an OS/2 message or called from a class method
     1960//******************************************************************************
     1961LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
     1962{
    18751963 LRESULT rc;
    18761964 BOOL    fInternalMsgBackup = fInternalMsg;
    18771965
    1878   //SvL: Some Wine controls send WM_COMMAND messages when they receive the focus -> apps don't like to
    1879   //     receive those before they get their WM_CREATE message
    1880   //NOTE: May need to refuse more messages
    1881   if(fCreated == FALSE && Msg == WM_COMMAND) {
    1882         dprintf(("SendMessageA BEFORE creation! %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    1883         return 0;
    1884   }
    1885 
    1886   DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, FALSE);
    1887 
    1888   if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1889         return(0);
    1890   }
    1891   fInternalMsg = FALSE;
     1966  DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
     1967
     1968  CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE);
     1969
     1970  fInternalMsg = TRUE;
    18921971  switch(Msg)
    18931972  {
     
    18991978                        break;
    19001979                }
    1901                 NotifyParent(Msg, wParam, lParam);
    1902 
    19031980                rc = 0;
    19041981                break;
    19051982        }
    1906         case WM_SETTEXT:
    1907                 rc = CallWindowProcA(win32wndproc, getWindowHandle(), WM_SETTEXT, wParam, lParam);
    1908                 break;
    1909 
    19101983        case WM_LBUTTONDOWN:
    19111984        case WM_MBUTTONDOWN:
     
    19161989
    19171990        case WM_DESTROY:
    1918                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    19191991                rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    19201992                break;
     
    19282000}
    19292001//******************************************************************************
    1930 //******************************************************************************
    1931 LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
     2002//Called as a result of an OS/2 message or called from a class method
     2003//******************************************************************************
     2004LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
    19322005{
    19332006 LRESULT rc;
    19342007 BOOL    fInternalMsgBackup = fInternalMsg;
    19352008
    1936   //SvL: Some Wine controls send WM_COMMAND messages when they receive the focus -> apps don't like to
    1937   //     receive those before they get their WM_CREATE message
    1938   //NOTE: May need to refuse more messages
    1939   if(fCreated == FALSE && Msg == WM_COMMAND) {
    1940         dprintf(("SendMessageA BEFORE creation! %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    1941         return 0;
    1942   }
    1943 
    1944   DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, FALSE);
    1945 
    1946   if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1947         return(0);
    1948   }
    1949   fInternalMsg = FALSE;
     2009  DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
     2010
     2011  CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE);
     2012
     2013  fInternalMsg = TRUE;
    19502014  switch(Msg)
    19512015  {
     
    19572021                        break;
    19582022                }
    1959                 NotifyParent(Msg, wParam, lParam);
    1960 
    19612023                rc = 0;
    19622024                break;
    19632025        }
    1964         case WM_SETTEXT:
    1965                 rc = CallWindowProcW(win32wndproc, getWindowHandle(), WM_SETTEXT, wParam, lParam);
    1966                 break;
    1967 
    19682026        case WM_LBUTTONDOWN:
    19692027        case WM_MBUTTONDOWN:
     
    19742032
    19752033        case WM_DESTROY:
    1976                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1977                 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1978                 break;
    1979 
    1980         default:
    1981                 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
    1982                 break;
    1983   }
    1984   fInternalMsg = fInternalMsgBackup;
    1985   return rc;
    1986 }
    1987 //******************************************************************************
    1988 //Called as a result of an OS/2 message
    1989 //******************************************************************************
    1990 LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
    1991 {
    1992  LRESULT rc;
    1993  BOOL    fInternalMsgBackup = fInternalMsg;
    1994 
    1995   DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
    1996 
    1997   if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1998         return(0);
    1999   }
    2000   fInternalMsg = TRUE;
    2001   switch(Msg)
    2002   {
    2003         case WM_CREATE:
    2004         {
    2005                 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
    2006                         dprintf(("WM_CREATE returned -1\n"));
    2007                         rc = -1; //don't create window
    2008                         break;
    2009                 }
    2010                 NotifyParent(Msg, wParam, lParam);
    2011                 rc = 0;
    2012                 break;
    2013         }
    2014         case WM_LBUTTONDOWN:
    2015         case WM_MBUTTONDOWN:
    2016         case WM_RBUTTONDOWN:
    2017                 NotifyParent(Msg, wParam, lParam);
    2018                 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    2019                 break;
    2020 
    2021         case WM_DESTROY:
    2022                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    2023                 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    2024                 break;
    2025 
    2026         default:
    2027                 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
    2028                 break;
    2029   }
    2030   fInternalMsg = fInternalMsgBackup;
    2031   return rc;
    2032 }
    2033 //******************************************************************************
    2034 //Called as a result of an OS/2 message
    2035 //todo, unicode msgs (WM_SETTEXT etc)
    2036 //******************************************************************************
    2037 LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
    2038 {
    2039  LRESULT rc;
    2040  BOOL    fInternalMsgBackup = fInternalMsg;
    2041 
    2042   DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
    2043 
    2044   if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    2045         return(0);
    2046   }
    2047   fInternalMsg = TRUE;
    2048   switch(Msg)
    2049   {
    2050         case WM_CREATE:
    2051         {
    2052                 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
    2053                         dprintf(("WM_CREATE returned -1\n"));
    2054                         rc = -1; //don't create window
    2055                         break;
    2056                 }
    2057                 NotifyParent(Msg, wParam, lParam);
    2058                 rc = 0;
    2059                 break;
    2060         }
    2061         case WM_LBUTTONDOWN:
    2062         case WM_MBUTTONDOWN:
    2063         case WM_RBUTTONDOWN:
    2064                 NotifyParent(Msg, wParam, lParam);
    2065                 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    2066                 break;
    2067 
    2068         case WM_DESTROY:
    2069                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    20702034                rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    20712035                break;
     
    20792043//******************************************************************************
    20802044//******************************************************************************
     2045void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
     2046{
     2047 CWPSTRUCT cwp;
     2048
     2049    cwp.lParam  = lParam;
     2050    cwp.wParam  = wParam;
     2051    cwp.message = Msg;
     2052    cwp.hwnd    = getWindowHandle();
     2053
     2054    switch(hooktype) {
     2055    case WH_CALLWNDPROC:
     2056        if(fUnicode) {
     2057             HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
     2058        }
     2059        else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
     2060        break;
     2061    }
     2062}
     2063//******************************************************************************
     2064//******************************************************************************
    20812065BOOL Win32BaseWindow::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
    20822066{
     
    21272111//******************************************************************************
    21282112//******************************************************************************
    2129 void Win32BaseWindow::PostMessage(POSTMSG_PACKET *packet)
    2130 {
     2113ULONG Win32BaseWindow::PostMessage(POSTMSG_PACKET *packet)
     2114{
     2115 ULONG rc;
     2116
    21312117    if(packet == NULL)
    2132         return;
     2118        return 0;
    21332119
    21342120    if(packet->fUnicode) {
    2135             SendMessageW(packet->Msg, packet->wParam, packet->lParam);
    2136     }
    2137     else    SendMessageA(packet->Msg, packet->wParam, packet->lParam);
     2121            rc = SendInternalMessageW(packet->Msg, packet->wParam, packet->lParam);
     2122    }
     2123    else    rc = SendInternalMessageA(packet->Msg, packet->wParam, packet->lParam);
    21382124
    21392125    free(packet);
    2140 }
    2141 //******************************************************************************
    2142 //Send message to window of another process
    2143 //******************************************************************************
    2144 LRESULT Win32BaseWindow::SendMessageToProcess(UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
    2145 {
    2146  POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
    2147 
    2148     dprintf(("SendMessageToProcess %x %x %x %x", getOS2WindowHandle(), msg, wParam, lParam));
    2149     packet->Msg = msg;
    2150     packet->wParam = wParam;
    2151     packet->lParam = lParam;
    2152     packet->fUnicode = fUnicode;
    2153     return OSLibSendMessage(getOS2WindowHandle(), WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet);
     2126    return rc;
    21542127}
    21552128//******************************************************************************
     
    21602133 Win32BaseWindow *window;
    21612134 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
    2162  DWORD processid, myprocessid;
    21632135
    21642136    dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS()));
    2165     myprocessid = GetCurrentProcessId();
    21662137
    21672138    for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
     
    21722143
    21732144                if(type == BROADCAST_SEND) {
    2174                         GetWindowThreadProcessId(hwnd, &processid);
    2175                         if(processid == myprocessid) {
    2176                             window->SendMessageA(msg, wParam, lParam);
    2177                         }
    2178                         else {
    2179                             window->SendMessageToProcess(msg, wParam, lParam, FALSE);
    2180                         }
     2145                        window->SendInternalMessageA(msg, wParam, lParam);
    21812146                }
    21822147                else    window->PostMessageA(msg, wParam, lParam);
     
    21932158 Win32BaseWindow *window;
    21942159 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
    2195  DWORD processid, myprocessid;
    21962160
    21972161
    21982162    dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam));
    2199     myprocessid = GetCurrentProcessId();
    22002163
    22012164    for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
     
    22062169
    22072170                if(type == BROADCAST_SEND) {
    2208                         GetWindowThreadProcessId(hwnd, &processid);
    2209                         if(processid == myprocessid) {
    2210                             window->SendMessageW(msg, wParam, lParam);
    2211                         }
    2212                         else {
    2213                             window->SendMessageToProcess(msg, wParam, lParam, TRUE);
    2214                         }
     2171                        window->SendInternalMessageW(msg, wParam, lParam);
    22152172                }
    22162173                else    window->PostMessageW(msg, wParam, lParam);
     
    22212178}
    22222179//******************************************************************************
    2223 //TODO: do we need to inform the parent of the parent (etc) of the child window?
    22242180//******************************************************************************
    22252181void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
     
    22352191                parentwindow = window->getParent();
    22362192                if(parentwindow) {
    2237                         if(Msg == WM_CREATE || Msg == WM_DESTROY) {
    2238                                 parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), (LPARAM)getWindowHandle());
    2239                         }
    2240                         else    parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
     2193                        parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
    22412194                }
    22422195        }
     
    22832236    if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
    22842237//TODO: Wine does't send these. Correct?
    2285 //        SendMessageA(WM_SETICON, ICON_BIG, hIcon);
     2238//        SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon);
    22862239        return TRUE;
    22872240    }
     
    23092262            wParam = SIZE_MINIMIZED;
    23102263
    2311         SendMessageA(WM_SIZE, wParam,
     2264        SendInternalMessageA(WM_SIZE, wParam,
    23122265                     MAKELONG(rectClient.right-rectClient.left,
    23132266                              rectClient.bottom-rectClient.top));
    2314         SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     2267        SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    23152268    }
    23162269#else
    23172270    if(fFirstShow) {
    23182271        if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) {
    2319                 SendMessageA(WM_SIZE, SIZE_RESTORED,
     2272                SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
    23202273                                MAKELONG(rectClient.right-rectClient.left,
    23212274                                         rectClient.bottom-rectClient.top));
    2322                 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     2275                SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    23232276
    23242277        }
     
    24912444}
    24922445//******************************************************************************
    2493 //Also destroys all the child windows (destroy parent, destroy children)
     2446//Also destroys all the child windows (destroy children first, parent last)
    24942447//******************************************************************************
    24952448BOOL Win32BaseWindow::DestroyWindow()
    24962449{
     2450    /* Call hooks */
     2451    if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
     2452    {
     2453        return FALSE;
     2454    }
     2455
     2456    if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
     2457    {
     2458        HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
     2459        /* FIXME: clean up palette - see "Internals" p.352 */
     2460    }
     2461
     2462    if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
     2463    {
     2464        if(getParent())
     2465        {
     2466             /* Notify the parent window only */
     2467             getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
     2468             if( !::IsWindow(getWindowHandle()) )
     2469             {
     2470                return TRUE;
     2471             }
     2472        }
     2473        else DebugInt3();
     2474    }
     2475    fDestroyWindowCalled = TRUE;
    24972476    return OSLibWinDestroyWindow(OS2HwndFrame);
    24982477}
     
    25902569        if (isIcon)
    25912570        {
    2592             SendMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
    2593             SendMessageA(WM_PAINTICON, 0, 0);
    2594         } else
    2595         {
    2596             SendMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
    2597             SendMessageA(WM_PAINT, 0, 0);
     2571            SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
     2572            SendInternalMessageA(WM_PAINTICON, 0, 0);
     2573        }
     2574        else
     2575        {
     2576            SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
     2577            SendInternalMessageA(WM_PAINT, 0, 0);
    25982578        }
    25992579        O32_ReleaseDC(OS2Hwnd, hdc);
     
    29992979                ss.styleNew = value;
    30002980                dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
    3001                 SendMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
     2981                SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
    30022982                setExStyle(ss.styleNew);
    30032983                updateWindowStyle(ss.styleOld,getStyle());
    3004                 SendMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
     2984                SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
    30052985                return ss.styleOld;
    30062986        }
     
    30162996                        ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD));
    30172997                dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), getStyle(), value));
    3018                 SendMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
     2998                SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
    30192999                setStyle(ss.styleNew);
    30203000                updateWindowStyle(dwExStyle,ss.styleOld);
    3021                 SendMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
     3001                SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
    30223002#ifdef DEBUG
    30233003                PrintWindowStyle(ss.styleNew, 0);
     
    30273007        case GWL_WNDPROC:
    30283008                oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
    3029                 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW);
     3009                //WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW);
     3010                WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW);
    30303011                return oldval;
    30313012        case GWL_HINSTANCE:
Note: See TracChangeset for help on using the changeset viewer.