1 | /* $Id: win32wdesktop.cpp,v 1.21 2004-01-11 12:03:21 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 Desktop Window for OS/2
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #include <os2win.h>
|
---|
13 | #include <misc.h>
|
---|
14 | #include "win32wbase.h"
|
---|
15 | #include "win32wdesktop.h"
|
---|
16 | #include "oslibwin.h"
|
---|
17 | #include "win32wndhandle.h"
|
---|
18 |
|
---|
19 | #define DBG_LOCALLOG DBG_win32wdesktop
|
---|
20 | #include "dbglocal.h"
|
---|
21 |
|
---|
22 | Win32Desktop *windowDesktop = 0;
|
---|
23 |
|
---|
24 | //******************************************************************************
|
---|
25 | //******************************************************************************
|
---|
26 | BOOL CreateWin32Desktop()
|
---|
27 | {
|
---|
28 | windowDesktop = new Win32Desktop();
|
---|
29 | if(windowDesktop == NULL) {
|
---|
30 | dprintf(("Unable to create desktop window!!!"));
|
---|
31 | return FALSE;
|
---|
32 | }
|
---|
33 | return TRUE;
|
---|
34 | }
|
---|
35 | //******************************************************************************
|
---|
36 | //******************************************************************************
|
---|
37 | void DestroyDesktopWindow()
|
---|
38 | {
|
---|
39 | if(windowDesktop) {
|
---|
40 | delete windowDesktop;
|
---|
41 | windowDesktop = 0;
|
---|
42 | }
|
---|
43 | }
|
---|
44 | //******************************************************************************
|
---|
45 | //******************************************************************************
|
---|
46 | Win32Desktop::Win32Desktop() : Win32BaseWindow()
|
---|
47 | {
|
---|
48 | rectWindow.left = 0;
|
---|
49 | rectWindow.top = 0;
|
---|
50 | rectWindow.right = OSLibQueryScreenWidth();
|
---|
51 | rectWindow.bottom = OSLibQueryScreenHeight();
|
---|
52 |
|
---|
53 | OS2Hwnd = OSLIB_HWND_DESKTOP;
|
---|
54 | OS2HwndFrame = OSLIB_HWND_DESKTOP;
|
---|
55 | rectClient = rectWindow;
|
---|
56 |
|
---|
57 | dprintf(("Desktop window %x", Win32Hwnd));
|
---|
58 |
|
---|
59 | /* Find the window class */
|
---|
60 | windowClass = Win32WndClass::FindClass(0, (LPSTR)DESKTOP_CLASS_ATOM);
|
---|
61 |
|
---|
62 | setWindowProc(windowClass->getWindowProc(WNDPROC_ASCII));
|
---|
63 |
|
---|
64 | dwStyle |= WS_VISIBLE;
|
---|
65 | }
|
---|
66 | //******************************************************************************
|
---|
67 | //******************************************************************************
|
---|
68 | Win32Desktop::~Win32Desktop()
|
---|
69 | {
|
---|
70 | }
|
---|
71 | //******************************************************************************
|
---|
72 | //******************************************************************************
|
---|
73 | BOOL Win32Desktop::isDesktopWindow()
|
---|
74 | {
|
---|
75 | return TRUE;
|
---|
76 | }
|
---|
77 | //******************************************************************************
|
---|
78 | //Disabling the desktop is not a good idea (mouse no longer responds)
|
---|
79 | //******************************************************************************
|
---|
80 | BOOL Win32Desktop::EnableWindow(BOOL fEnable)
|
---|
81 | {
|
---|
82 | return TRUE; //of course we succeeded
|
---|
83 | }
|
---|
84 | //******************************************************************************
|
---|
85 | //******************************************************************************
|
---|
86 | BOOL Win32Desktop::DestroyWindow()
|
---|
87 | {
|
---|
88 | dprintf(("WARNING: can't destroy desktop window!!"));
|
---|
89 | return FALSE;
|
---|
90 | }
|
---|
91 | //******************************************************************************
|
---|
92 | //******************************************************************************
|
---|
93 | HWND Win32Desktop::GetWindow(UINT uCmd)
|
---|
94 | {
|
---|
95 | HWND hwndRelated = 0;
|
---|
96 | Win32BaseWindow *window;
|
---|
97 |
|
---|
98 | switch(uCmd)
|
---|
99 | {
|
---|
100 | case GW_CHILD:
|
---|
101 | //special case for the desktop window. we need to find the first Odin
|
---|
102 | //window in the z-order
|
---|
103 | hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
|
---|
104 | while(hwndRelated)
|
---|
105 | {
|
---|
106 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
---|
107 | if(window) {
|
---|
108 | hwndRelated = window->getWindowHandle();
|
---|
109 | RELEASE_WNDOBJ(window);
|
---|
110 | break;
|
---|
111 | }
|
---|
112 | hwndRelated = OSLibWinQueryWindow(hwndRelated, QWOS_NEXT);
|
---|
113 | }
|
---|
114 | break;
|
---|
115 |
|
---|
116 | default:
|
---|
117 | return Win32BaseWindow::GetWindow(uCmd);
|
---|
118 | }
|
---|
119 | end:
|
---|
120 | dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
|
---|
121 | return hwndRelated;
|
---|
122 | }
|
---|
123 | //******************************************************************************
|
---|
124 | //Dummy window procedure. Does nothing.
|
---|
125 | //******************************************************************************
|
---|
126 | LRESULT WIN32API DesktopWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
---|
127 | {
|
---|
128 | switch (message)
|
---|
129 | {
|
---|
130 | case WM_GETTEXT:
|
---|
131 | if (!lParam || !wParam) return 0;
|
---|
132 | ((LPSTR)lParam)[0] = 0;
|
---|
133 | return 0;
|
---|
134 | }
|
---|
135 |
|
---|
136 | return 0;
|
---|
137 | }
|
---|
138 | //******************************************************************************
|
---|
139 | //******************************************************************************
|
---|
140 | BOOL WIN32API SetDeskWallPaper(LPCSTR filename)
|
---|
141 | {
|
---|
142 | dprintf(("USER32: SetDeskWallPaper - empty stub!"));
|
---|
143 |
|
---|
144 | return TRUE;
|
---|
145 | }
|
---|
146 | //******************************************************************************
|
---|
147 | //******************************************************************************
|
---|
148 | BOOL DESKTOP_Register()
|
---|
149 | {
|
---|
150 | WNDCLASSA wndClass;
|
---|
151 |
|
---|
152 | ZeroMemory(&wndClass,sizeof(WNDCLASSA));
|
---|
153 | wndClass.style = CS_GLOBALCLASS;
|
---|
154 | wndClass.lpfnWndProc = (WNDPROC)DesktopWndProc;
|
---|
155 | wndClass.cbClsExtra = 0;
|
---|
156 | wndClass.cbWndExtra = 0;
|
---|
157 | wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
|
---|
158 | wndClass.hbrBackground = 0;
|
---|
159 | wndClass.lpszClassName = DESKTOP_CLASS_NAMEA;
|
---|
160 |
|
---|
161 | return RegisterClassA(&wndClass);
|
---|
162 | }
|
---|
163 | //******************************************************************************
|
---|
164 | //******************************************************************************
|
---|
165 | BOOL DESKTOP_Unregister()
|
---|
166 | {
|
---|
167 | if (GlobalFindAtomA(DESKTOP_CLASS_NAMEA))
|
---|
168 | return UnregisterClassA(DESKTOP_CLASS_NAMEA,(HINSTANCE)NULL);
|
---|
169 | else return FALSE;
|
---|
170 | }
|
---|
171 | //******************************************************************************
|
---|
172 | //******************************************************************************
|
---|