forked from maccasoft/lora3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcwinapp.cpp
More file actions
162 lines (131 loc) · 4.13 KB
/
Copy pathcwinapp.cpp
File metadata and controls
162 lines (131 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// ----------------------------------------------------------------------
// Common Presentation Classes - Version 1.00.1
// Copyright (c) 1996 by Marco Maccaferri. All rights reserved.
//
// History:
// 10/08/96 - Initial coding.
// ----------------------------------------------------------------------
#include "_ldefs.h"
#include "cpc.h"
#if defined(__OS2__)
MRESULT EXPENTRY CWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
#elif defined(__NT__)
LRESULT CALLBACK CWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
#endif
{
int i;
class CWnd *wndClass;
CPC_MSGMAP_ENTRY *msgMap = NULL;
#if defined(__OS2__)
wndClass = (class CWnd *)WinQueryWindowULong (hwnd, QWL_USER);
#elif defined(__NT__)
wndClass = (class CWnd *)GetWindowLong (hwnd, GWL_USERDATA);
#endif
if (wndClass != NULL)
msgMap = wndClass->GetMessageMap ();
switch (msg) {
case WM_CREATE:
break;
#if defined(__OS2__)
case WM_ERASEBACKGROUND:
return ((MRESULT)TRUE);
#endif
case WM_COMMAND:
for (i = 0; msgMap[i].pfn != NULL; i++) {
#if defined(__OS2__)
if (msgMap[i].nMessage == msg) {
if (msgMap[i].nID >= SHORT1FROMMP (mp1) && msgMap[i].nLastID <= SHORT1FROMMP (mp1)) {
#elif defined(__NT__)
if (msgMap[i].nMessage == msg && msgMap[i].nCode == HIWORD (wParam)) {
if (msgMap[i].nID >= LOWORD (wParam) && msgMap[i].nLastID <= LOWORD (wParam)) {
#endif
(wndClass->*msgMap[i].pfnw) ();
break;
}
}
}
return (0);
}
#if defined(__OS2__)
return (WinDefWindowProc (hwnd, msg, mp1, mp2));
#elif defined(__NT__)
return (DefWindowProc (hwnd, msg, wParam, lParam));
#endif
}
BEGIN_MESSAGE_MAP (CWnd, CWnd)
END_MESSAGE_MAP ()
CWnd::CWnd ()
{
}
CWnd::~CWnd ()
{
}
USHORT CWnd::OnCreate ()
{
return (TRUE);
}
// ----------------------------------------------------------------------
CFrameWnd::CFrameWnd ()
{
int x, y, dx, dy;
ULONG flFrame;
#if defined(__OS2__)
dy = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) / 2;
dx = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) / 2;
y = (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) - dy) / 2;
x = (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) - dx) / 2;
#elif defined(__NT__)
dy = GetSystemMetrics (SM_CYSCREEN) / 2;
dx = GetSystemMetrics (SM_CXSCREEN) / 2;
y = (GetSystemMetrics (SM_CYSCREEN) - dy) / 2;
x = (GetSystemMetrics (SM_CXSCREEN) - dx) / 2;
#endif
cWnd.cbSize = sizeof (CWND_DATA);
cWnd.Wnd = this;
flFrame = (FCF_TASKLIST|FCF_TITLEBAR|FCF_SYSMENU|FCF_MINMAX|FCF_SIZEBORDER|FCF_NOBYTEALIGN);
if ((hwndMainFrame = WinCreateStdWindow (HWND_DESKTOP, 0, &flFrame, "CWINAPP_WINDOW", NULL, 0, NULLHANDLE, 256, &hwndMainClient)) != NULLHANDLE) {
WinSetWindowULong (hwndMainClient, QWL_USER, (ULONG)this);
WinSetWindowText (hwndMainFrame, "Common Presentation Classes Window");
if (OnCreate () == TRUE)
WinSetWindowPos (hwndMainFrame, NULLHANDLE, x, y, dx, dy, SWP_SIZE|SWP_MOVE|SWP_SHOW|SWP_ACTIVATE);
else {
WinDestroyWindow (hwndMainFrame);
hwndMainFrame = NULL;
}
}
}
CFrameWnd::~CFrameWnd ()
{
if (hwndMainFrame != NULLHANDLE)
WinDestroyWindow (hwndMainFrame);
}
// ----------------------------------------------------------------------
CWinApp::CWinApp ()
{
m_pMainWnd = NULL;
if ((hab = WinInitialize (0)) != 0) {
if ((hmq = WinCreateMsgQueue (hab, 0)) != 0)
WinRegisterClass (hab, "CWINAPP_WINDOW", CWndProc, CS_CLIPCHILDREN|CS_SIZEREDRAW|CS_MOVENOTIFY, 0);
}
}
CWinApp::~CWinApp ()
{
if (m_pMainWnd != NULL)
delete m_pMainWnd;
if (hab != 0) {
if (hmq != 0)
WinDestroyMsgQueue (hmq);
WinTerminate (hab);
}
}
USHORT CWinApp::InitInstance ()
{
m_pMainWnd = new CFrameWnd;
return (TRUE);
}
VOID CWinApp::Run ()
{
InitInstance ();
while (WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0))
WinDispatchMsg (hab, &qmsg);
}