source: trunk/src/user32/pmtitlebar.cpp@ 2371

Last change on this file since 2371 was 2371, checked in by sandervl, 26 years ago

OSLibGetMsg bugfix + WM_QUIT translation fix

File size: 4.4 KB
Line 
1/* $Id: pmtitlebar.cpp,v 1.1 2000-01-08 14:15:38 sandervl Exp $ */
2/*
3 * Win32 Titlebar Managment Code for OS/2
4 *
5 * Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 2000 by Christoph Bratschi (cbratschi@datacomm.ch)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12
13#define INCL_WIN
14#define INCL_GPI
15
16#include <os2.h> /* PM header file */
17#include <os2wrap.h>
18#include <stdlib.h>
19#include <string.h>
20#include <win32type.h>
21#include <misc.h>
22#include <win32wbase.h>
23#include <wprocess.h>
24#include "pmframe.h"
25#include "oslibutil.h"
26#include "oslibwin.h"
27#include "oslibmsg.h"
28#include "pmtitlebar.h"
29
30//******************************************************************************
31//******************************************************************************
32MRESULT EXPENTRY Win32TitleBarProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
33{
34 Win32BaseWindow *win32wnd;
35 PFNWP OldTitleBarProc;
36 APIRET rc = 0;
37 THDB *thdb;
38 MSG winMsg, *pWinMsg;
39
40 SetWin32TIB();
41
42 thdb = GetThreadTHDB();
43 win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(WinQueryWindow(hwnd, QW_PARENT));
44
45 if(!thdb || win32wnd == NULL || !win32wnd->getOldTitleBarProc())
46 {
47 dprintf(("Win32TitleBarProc: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
48 goto RunDefWndProc;
49 }
50 OldTitleBarProc = (PFNWP)win32wnd->getOldTitleBarProc();
51
52 if(msg == WM_MOUSEMOVE) {
53 rc = 0;
54 }
55 if((thdb->msgstate & 1) == 0)
56 {//message that was sent directly to our window proc handler; translate it here
57 QMSG qmsg;
58
59 qmsg.msg = msg;
60 qmsg.hwnd = hwnd;
61 qmsg.mp1 = mp1;
62 qmsg.mp2 = mp2;
63 qmsg.time = WinQueryMsgTime(thdb->hab);
64 WinQueryMsgPos(thdb->hab, &qmsg.ptl);
65 qmsg.reserved = 0;
66
67 if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
68 {//message was not translated
69 memset(&winMsg, 0, sizeof(MSG));
70 }
71 pWinMsg = &winMsg;
72 }
73 else {
74 pWinMsg = &thdb->msg;
75 thdb->msgstate++;
76 }
77 win32wnd->clearDefWndProcCalled();
78
79 switch(pWinMsg->message)
80 {
81 case WINWM_NCHITTEST:
82 {
83 DWORD res;
84
85 // Only send this message if the window is enabled
86 if (!WinIsWindowEnabled(hwnd))
87 res = HT_ERROR;
88 else if (win32wnd->getIgnoreHitTest())
89 res = HT_NORMAL;
90 else
91 {
92 dprintf(("USER32: WM_HITTEST %x (%d,%d)",hwnd,(*(POINTS *)&mp1).x,(*(POINTS *)&mp1).y));
93
94 //CB: WinWindowFromPoint: PM sends WM_HITTEST -> loop -> stack overflow
95 win32wnd->setIgnoreHitTest(TRUE);
96 res = win32wnd->MsgHitTest(pWinMsg);
97 win32wnd->setIgnoreHitTest(FALSE);
98 }
99 RestoreOS2TIB();
100 return (MRESULT)res;
101 }
102 case WINWM_NCPAINT:
103 win32wnd->DispatchMsgA(pWinMsg);
104 if(win32wnd->getDefWndProcCalled())
105 goto RunDefTitleBarProc;
106 goto RunDefWndProc;
107
108 case WINWM_NCLBUTTONDOWN:
109 case WINWM_NCLBUTTONUP:
110 case WINWM_NCLBUTTONDBLCLK:
111 case WINWM_NCMBUTTONDOWN:
112 case WINWM_NCMBUTTONUP:
113 case WINWM_NCMBUTTONDBLCLK:
114 case WINWM_NCRBUTTONDOWN:
115 case WINWM_NCRBUTTONUP:
116 case WINWM_NCRBUTTONDBLCLK:
117 win32wnd->MsgButton(pWinMsg);
118 if(win32wnd->getDefWndProcCalled())
119 goto RunDefTitleBarProc;
120
121 rc = TRUE;
122 break;
123
124 case WINWM_NCMOUSEMOVE:
125 {
126 //OS/2 Window coordinates -> Win32 Window coordinates
127 win32wnd->MsgMouseMove(pWinMsg);
128 if(win32wnd->getDefWndProcCalled())
129 goto RunDefTitleBarProc;
130 break;
131 }
132
133 default:
134 goto RunDefTitleBarProc;
135 }
136
137 RestoreOS2TIB();
138 return (MRESULT)rc;
139
140RunDefTitleBarProc:
141 RestoreOS2TIB();
142 return OldTitleBarProc(hwnd,msg,mp1,mp2);
143
144RunDefWndProc:
145 RestoreOS2TIB();
146 return WinDefWindowProc(hwnd,msg,mp1,mp2);
147}
148//******************************************************************************
149//******************************************************************************
150BOOL FrameSubclassTitleBar(Win32BaseWindow *window)
151{
152 HWND hwndTitleBar;
153
154 hwndTitleBar = WinWindowFromID(window->getOS2FrameWindowHandle(), FID_TITLEBAR);
155 if(hwndTitleBar) {
156 window->setOldTitleBarProc(WinSubclassWindow(hwndTitleBar, PFNWP(Win32TitleBarProc)));
157 }
158 return FALSE;
159}
160//******************************************************************************
161//******************************************************************************
Note: See TracBrowser for help on using the repository browser.