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

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

Several updates/bug fixes

File size: 3.7 KB
Line 
1/* $Id: pmtitlebar.cpp,v 1.2 2000-01-09 14:37:10 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 * NOTE: When fOS2Look == TRUE, mouse message & painting is handled by us
10 * (not by the PM titlebar control)
11 *
12 * Project Odin Software License can be found in LICENSE.TXT
13 *
14 */
15
16#define INCL_WIN
17#define INCL_GPI
18
19#include <os2.h> /* PM header file */
20#include <os2wrap.h>
21#include <stdlib.h>
22#include <string.h>
23#include <win32type.h>
24#include <misc.h>
25#include <win32wbase.h>
26#include <wprocess.h>
27#include "pmframe.h"
28#include "oslibutil.h"
29#include "oslibwin.h"
30#include "oslibmsg.h"
31#include "pmtitlebar.h"
32#include "pmwindow.h"
33
34//******************************************************************************
35//******************************************************************************
36MRESULT EXPENTRY Win32TitleBarProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
37{
38 Win32BaseWindow *win32wnd;
39 PFNWP OldTitleBarProc;
40 APIRET rc = 0;
41 THDB *thdb;
42 MSG winMsg, *pWinMsg;
43
44 SetWin32TIB();
45
46 thdb = GetThreadTHDB();
47 win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(WinQueryWindow(hwnd, QW_PARENT));
48
49 if(!thdb || win32wnd == NULL || !win32wnd->getOldTitleBarProc())
50 {
51 dprintf(("Win32TitleBarProc: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
52 goto RunDefWndProc;
53 }
54 OldTitleBarProc = (PFNWP)win32wnd->getOldTitleBarProc();
55
56 if((thdb->msgstate & 1) == 0)
57 {//message that was sent directly to our window proc handler; translate it here
58 QMSG qmsg;
59
60 qmsg.msg = msg;
61 qmsg.hwnd = hwnd;
62 qmsg.mp1 = mp1;
63 qmsg.mp2 = mp2;
64 qmsg.time = WinQueryMsgTime(thdb->hab);
65 WinQueryMsgPos(thdb->hab, &qmsg.ptl);
66 qmsg.reserved = 0;
67
68 if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
69 {//message was not translated
70 memset(&winMsg, 0, sizeof(MSG));
71 }
72 pWinMsg = &winMsg;
73 }
74 else {
75 pWinMsg = &thdb->msg;
76 thdb->msgstate++;
77 }
78 win32wnd->clearDefWndProcCalled();
79
80 switch(pWinMsg->message)
81 {
82 case WINWM_NCPAINT:
83 win32wnd->DispatchMsgA(pWinMsg);
84 goto RunDefWndProc;
85
86 case WINWM_NCACTIVATE:
87 win32wnd->DispatchMsgA(pWinMsg);
88 break;
89
90 case WINWM_NCLBUTTONDOWN:
91 case WINWM_NCLBUTTONUP:
92 case WINWM_NCLBUTTONDBLCLK:
93 case WINWM_NCMBUTTONDOWN:
94 case WINWM_NCMBUTTONUP:
95 case WINWM_NCMBUTTONDBLCLK:
96 case WINWM_NCRBUTTONDOWN:
97 case WINWM_NCRBUTTONUP:
98 case WINWM_NCRBUTTONDBLCLK:
99 win32wnd->MsgButton(pWinMsg);
100 rc = TRUE;
101 break;
102
103 case WINWM_NCMOUSEMOVE:
104 {
105 win32wnd->MsgMouseMove(pWinMsg);
106 break;
107 }
108
109 default:
110 goto RunDefTitleBarProc;
111 }
112
113 RestoreOS2TIB();
114 return (MRESULT)rc;
115
116RunDefTitleBarProc:
117 RestoreOS2TIB();
118 return OldTitleBarProc(hwnd,msg,mp1,mp2);
119
120RunDefWndProc:
121 RestoreOS2TIB();
122 return WinDefWindowProc(hwnd,msg,mp1,mp2);
123}
124//******************************************************************************
125//******************************************************************************
126BOOL FrameSubclassTitleBar(Win32BaseWindow *window)
127{
128 HWND hwndTitleBar;
129
130 hwndTitleBar = WinWindowFromID(window->getOS2FrameWindowHandle(), FID_TITLEBAR);
131 if(hwndTitleBar) {
132 window->setOldTitleBarProc(WinSubclassWindow(hwndTitleBar, PFNWP(Win32TitleBarProc)));
133 }
134 return FALSE;
135}
136//******************************************************************************
137//******************************************************************************
Note: See TracBrowser for help on using the repository browser.