Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
floaterdialog.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : Max2W3d *
24 * *
25 * $Archive:: /Commando/Code/Tools/max2w3d/floaterdialog.cpp $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Greg_h $*
30 * *
31 * $Modtime:: 10/30/00 2:58p $*
32 * *
33 * $Revision:: 2 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * FloaterDialogClass::FloaterDialogClass -- Constructor *
38 * FloaterDialogClass::~FloaterDialogClass -- Destructor *
39 * FloaterDialogClass::Is_Created -- test whether the floater has already been created *
40 * FloaterDialogClass::Create -- create the window *
41 * FloaterDialogClass::Dialog_Proc -- Dialog Proc for the floater *
42 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
43
44#include "floaterdialog.h"
45#include "dllmain.h"
46#include "resource.h"
47#include <Max.h>
48
49
50/**********************************************************************************************
51**
52** FloaterDialogClass Implementation
53**
54**********************************************************************************************/
55
56BOOL CALLBACK _floater_dialog_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
57{
58 if (message == WM_INITDIALOG) {
59 FloaterDialogClass * floater = (FloaterDialogClass *)lParam;
60 ::SetProp(hwnd,"FloaterDialogClass",(HANDLE)floater);
61 }
62
63 FloaterDialogClass * floater = (FloaterDialogClass *)::GetProp(hwnd,"FloaterDialogClass");
64
65 if (message == WM_DESTROY) {
66 ::RemoveProp(hwnd,"FloaterDialogClass");
67 }
68
69
70 if (floater) {
71 return floater->Dialog_Proc(hwnd,message,wParam,lParam);
72 } else {
73 return FALSE;
74 }
75}
76
77
78/***********************************************************************************************
79 * FloaterDialogClass::FloaterDialogClass -- Constructor *
80 * *
81 * INPUT: *
82 * *
83 * OUTPUT: *
84 * *
85 * WARNINGS: *
86 * *
87 * HISTORY: *
88 *=============================================================================================*/
90 Hwnd(NULL),
91 ChildDialogTemplateID(-1),
92 ChildDialogProc(NULL)
93{
94}
95
96
97/***********************************************************************************************
98 * FloaterDialogClass::~FloaterDialogClass -- Destructor *
99 * *
100 * INPUT: *
101 * *
102 * OUTPUT: *
103 * *
104 * WARNINGS: *
105 * *
106 * HISTORY: *
107 *=============================================================================================*/
109{
110 if (Hwnd != NULL) {
111 ::DestroyWindow(Hwnd);
112 }
113}
114
115
116/***********************************************************************************************
117 * FloaterDialogClass::Is_Created -- test whether the floater has already been created *
118 * *
119 * INPUT: *
120 * *
121 * OUTPUT: *
122 * *
123 * WARNINGS: *
124 * *
125 * HISTORY: *
126 * 10/11/2000 gth : Created. *
127 *=============================================================================================*/
129{
130 return (Hwnd != NULL);
131}
132
133
134/***********************************************************************************************
135 * FloaterDialogClass::Create -- create the window *
136 * *
137 * This function will return automatically if the floater has been created already. *
138 * *
139 * INPUT: *
140 * *
141 * OUTPUT: *
142 * *
143 * WARNINGS: *
144 * *
145 * HISTORY: *
146 * 10/11/2000 gth : Created. *
147 *=============================================================================================*/
148void FloaterDialogClass::Create(Interface * ip, int child_dlg_id, DLGPROC child_dlg_proc)
149{
150 /*
151 ** Don't create multiple ones
152 */
153 if (Is_Created()) {
154 return;
155 }
156
157 /*
158 ** Copy down the data needed to create the child window later
159 */
160 ChildDialogTemplateID = child_dlg_id;
161 ChildDialogProc = child_dlg_proc;
162
163
164 /*
165 ** Create the dialog box
166 */
167 Hwnd = CreateDialogParam(
169 MAKEINTRESOURCE(IDD_W3DUTILITY_FLOATER_DIALOG),
170 ::GetCOREInterface()->GetMAXHWnd(),
171 (DLGPROC) _floater_dialog_proc,
172 (LPARAM) this
173 );
174 ::GetCOREInterface()->RegisterDlgWnd(Hwnd);
175}
176
177
178
179/***********************************************************************************************
180 * FloaterDialogClass::Dialog_Proc -- Dialog Proc for the floater *
181 * *
182 * The only thing we need to do here is to create the child dialog and resize ourselves to *
183 * contain it. *
184 * *
185 * INPUT: *
186 * *
187 * OUTPUT: *
188 * *
189 * WARNINGS: *
190 * *
191 * HISTORY: *
192 * 10/11/2000 gth : Created. *
193 *=============================================================================================*/
194bool FloaterDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM)
195{
196 switch (message ) {
197
198 case WM_INITDIALOG:
199 {
200 HWND childhwnd = CreateDialogParam(
202 MAKEINTRESOURCE(ChildDialogTemplateID),
203 hWnd,
204 ChildDialogProc,
205 0
206 );
207 if (childhwnd!= NULL) {
208 RECT rect;
209 LONG style = ::GetWindowLong(hWnd,GWL_STYLE);
210 ::GetWindowRect(childhwnd,&rect);
211 ::AdjustWindowRect(&rect,style,FALSE);
212 ::SetWindowPos(hWnd,NULL,0,0,rect.right - rect.left,rect.bottom - rect.top,SWP_NOZORDER|SWP_NOMOVE);
213 ::SetWindowPos(childhwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_SHOWWINDOW);
214 }
215 }
216 return 1;
217
218 case WM_COMMAND:
219 switch (LOWORD(wParam))
220 {
221 case IDCANCEL:
222 DestroyWindow(Hwnd);
223 break;
224 }
225 return 1;
226
227 case WM_DESTROY:
228 ::GetCOREInterface()->UnRegisterDlgWnd(Hwnd);
229 Hwnd = NULL;
230 break;
231 }
232 return 0;
233}
#define NULL
Definition BaseType.h:92
#define FALSE
Definition BaseType.h:113
unsigned int UINT
Definition bittype.h:63
#define IDD_W3DUTILITY_FLOATER_DIALOG
Definition resource.h:99
#define BOOL
Definition Wnd_File.h:57
bool Dialog_Proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM)
void Create(Interface *ip, int child_dialog_id, DLGPROC child_dlg_proc)
HINSTANCE AppInstance
Definition dllmain.cpp:67
BOOL CALLBACK _floater_dialog_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)