source: trunk/src/user32/win32wfake.cpp@ 10010

Last change on this file since 10010 was 9941, checked in by sandervl, 22 years ago

Don't change focus when processing mouse button message if the top parent is a fake window

File size: 4.6 KB
Line 
1/* $Id: win32wfake.cpp,v 1.2 2003-03-27 10:42:42 sandervl Exp $ */
2/*
3 * Win32 Fake Window Class for OS/2
4 *
5 *
6 * Copyright 2002 Sander van Leeuwen (sandervl@innotek.de)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#include <os2win.h>
13#include <stdlib.h>
14#include <string.h>
15#include <dbglog.h>
16#include <win\winproc.h>
17#include <win32wbase.h>
18#include <win32wfake.h>
19#include "oslibwin.h"
20#include "win32wndhandle.h"
21#include "pmwindow.h"
22
23#define DBG_LOCALLOG DBG_win32wfake
24#include "dbglocal.h"
25
26//******************************************************************************
27//******************************************************************************
28HWND WIN32API CreateFakeWindowEx(HWND hwndOS2, ATOM classAtom)
29{
30 Win32FakeWindow *window;
31
32 window = new Win32FakeWindow(hwndOS2, classAtom);
33 if(window == NULL)
34 {
35 dprintf(("Win32FakeWindow creation failed!!"));
36 return 0;
37 }
38 HWND hwnd = window->getWindowHandle();
39
40 // set myself as last active popup / window
41 window->setLastActive( hwnd );
42
43 RELEASE_WNDOBJ(window);
44 return hwnd;
45}
46//******************************************************************************
47//******************************************************************************
48BOOL WIN32API DestroyFakeWindow(HWND hwnd)
49{
50 Win32BaseWindow *window;
51
52 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
53 if(!window) {
54 dprintf(("DestroyFakeWindow, window %x not found", hwnd));
55 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
56 return 0;
57 }
58 delete window;
59 return TRUE;
60}
61//******************************************************************************
62//******************************************************************************
63Win32FakeWindow::Win32FakeWindow(HWND hwndOS2, ATOM classAtom)
64 : Win32BaseWindow()
65{
66 OS2Hwnd = OS2HwndFrame = hwndOS2;
67
68 /* Find the window class */
69 windowClass = Win32WndClass::FindClass(NULL, (LPSTR)classAtom);
70 if (!windowClass)
71 {
72 char buffer[32];
73 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
74 dprintf(("Bad class '%s'", buffer ));
75 DebugInt3();
76 }
77
78 //Allocate window words
79 nrUserWindowBytes = windowClass->getExtraWndBytes();
80 if(nrUserWindowBytes) {
81 userWindowBytes = (char *)_smalloc(nrUserWindowBytes);
82 memset(userWindowBytes, 0, nrUserWindowBytes);
83 }
84
85 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc((isUnicode) ? WNDPROC_UNICODE : WNDPROC_ASCII), WINPROC_GetProcType(windowClass->getWindowProc((isUnicode) ? WNDPROC_UNICODE : WNDPROC_ASCII)), WIN_PROC_WINDOW);
86 hInstance = NULL;
87 dwStyle = WS_VISIBLE;
88 dwOldStyle = dwStyle;
89 dwExStyle = 0;
90
91 //We pretend this window has no parent and its position is in screen coordinates
92 OSLibWinQueryWindowClientRect(OS2Hwnd, &rectClient);
93 OSLibQueryWindowRectAbsolute (OS2Hwnd, &rectWindow);
94
95 setOldPMWindowProc(PMWinSubclassFakeWindow(OS2Hwnd));
96}
97//******************************************************************************
98//******************************************************************************
99Win32FakeWindow::~Win32FakeWindow()
100{
101
102}
103//******************************************************************************
104//******************************************************************************
105PRECT Win32FakeWindow::getWindowRect()
106{
107 //the coordinates can change without us being notified, so recheck every time
108 OSLibQueryWindowRectAbsolute (OS2Hwnd, &rectWindow);
109 return &rectWindow;
110}
111//******************************************************************************
112//******************************************************************************
113BOOL Win32FakeWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx,
114 int cy, UINT fuFlags, BOOL fShowWindow)
115{
116 dprintf(("Win32FakeWindow::SetWindowPos; don't change window position, just update internal position"));
117
118 //We pretend this window has no parent and its position is in screen coordinates
119 OSLibWinQueryWindowClientRect(OS2Hwnd, &rectClient);
120 OSLibQueryWindowRectAbsolute (OS2Hwnd, &rectWindow);
121
122 return TRUE;
123}
124//******************************************************************************
125//******************************************************************************
126BOOL Win32FakeWindow::isFakeWindow()
127{
128 return TRUE;
129}
130//******************************************************************************
131//******************************************************************************
Note: See TracBrowser for help on using the repository browser.