1 /* $NetBSD: layout.c,v 1.1.1.1 1999/09/16 12:23:30 takemura Exp $ */
4 * Copyright (c) 1999 Shin Takemura.
7 * This software is part of the PocketBSD.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the PocketBSD project
20 * and its contributors.
21 * 4. Neither the name of the project nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 #include <res/resource.h>
44 CreateMainWindow(HINSTANCE hInstance
, HWND hWnd
, LPCTSTR name
, int cmdbar_height
)
54 res
= FindResource(hInstance
, name
, RT_DIALOG
);
56 debug_printf(TEXT("error=%d\n"), GetLastError());
58 mem
= (unsigned char*)LockResource(LoadResource(NULL
, res
));
61 * DLGTEMPLATE structure
63 dlg
= *(DLGTEMPLATE
*)mem
;
64 mem
+= sizeof(DLGTEMPLATE
);
66 GetClientRect(hWnd
, &rect
);
67 rect
.top
+= cmdbar_height
; /* get client rect w/o command bar */
68 ratio_x
= (rect
.right
- rect
.left
) * 100 / dlg
.cx
;
69 ratio_y
= (rect
.bottom
- rect
.top
) * 100 / dlg
.cy
;
74 if (*(WORD
*)mem
== 0xffff) {
77 debug_printf(TEXT("Dlg: menu=%04x\n"), *(WORD
*)mem
);
80 if (*(WORD
*)mem
== 0x0000) {
83 debug_printf(TEXT("Dlg: menu=none\n"));
85 /* menu resource name */
86 debug_printf(TEXT("Dlg: menu=%s\n"), (TCHAR
*)mem
);
87 while (*(WORD
*)mem
) { /* zero terminated */
96 if (*(WORD
*)mem
== 0xffff) {
97 /* predefined class */
99 debug_printf(TEXT("Dlg: class=%04x\n"), *(WORD
*)mem
);
102 if (*(WORD
*)mem
== 0x0000) {
105 debug_printf(TEXT("Dlg: class=none\n"));
108 debug_printf(TEXT("Dlg: class=%s\n"), (TCHAR
*)mem
);
109 while (*(WORD
*)mem
) { /* zero terminated */
118 debug_printf(TEXT("Dlg: title=%s\n"), (TCHAR
*)mem
);
119 while (*(WORD
*)mem
) { /* zero terminated */
124 if (dlg
.style
& DS_SETFONT
) {
126 debug_printf(TEXT("Dlg: font size=%d\n"), *(WORD
*)mem
);
129 debug_printf(TEXT("Dlg: font name=%s ("), (TCHAR
*)mem
);
130 while (*(WORD
*)mem
) { /* zero terminated */
131 debug_printf(TEXT("%04x"), *(WORD
*)mem
);
134 debug_printf(TEXT(")\n"));
141 for (i
= 0; i
< dlg
.cdit
; i
++) {
142 TCHAR
*class_name
= NULL
;
143 TCHAR
*window_text
= NULL
;
145 /* DWORD alignment */
146 if ((long)mem
% sizeof(DWORD
)) {
147 mem
= (unsigned char*)(((long)mem
/ sizeof(DWORD
) + 1) * sizeof(DWORD
));
151 * DLGITEMTEMPLATE structure
153 item
= *(DLGITEMTEMPLATE
*)mem
;
154 mem
+= sizeof(DLGITEMTEMPLATE
);
159 if (*(WORD
*)mem
== 0xffff) {
160 /* predefined system class */
162 switch (*(WORD
*)mem
) {
163 case 0x0080: class_name
= TEXT("BUTTON"); break;
164 case 0x0081: class_name
= TEXT("EDIT"); break;
165 case 0x0082: class_name
= TEXT("STATIC"); break;
166 case 0x0083: class_name
= TEXT("LISTBOX"); break;
167 case 0x0084: class_name
= TEXT("SCROLLBAR"); break;
168 case 0x0085: class_name
= TEXT("COMBOBOX"); break;
170 debug_printf(TEXT("class=%04x "), *(WORD
*)mem
);
176 class_name
= (TCHAR
*)mem
;
177 while (*(WORD
*)mem
) { /* zero terminated */
186 if (*(WORD
*)mem
== 0xffff) {
189 debug_printf(TEXT("contents=%04x "), *(WORD
*)mem
);
193 window_text
= (TCHAR
*)mem
;
194 while (*(WORD
*)mem
) { /* zero terminated */
199 if (item
.id
== 0xffff) {
204 debug_printf(TEXT("Control: %04x "), item
.id
);
205 debug_printf(TEXT("class=%s "), class_name
);
206 debug_printf(TEXT("contents=%s "),
207 window_text
? window_text
: TEXT(""));
210 item
.dwExtendedStyle
,
212 window_text
, // Title
214 item
.x
* ratio_x
/ 100,
215 item
.y
* ratio_y
/ 100 + cmdbar_height
,
216 item
.cx
* ratio_x
/ 100,
217 item
.cy
* ratio_y
/ 100,
218 hWnd
, // Parent handle
219 (HMENU
)item
.id
, // Control ID
220 hInstance
, // Instance handle
225 /* DWORD alignment */
226 if ((long)mem
% sizeof(DWORD
)) {
227 //mem = (unsigned char*)(((long)mem / sizeof(DWORD) + 1) * sizeof(DWORD));
234 debug_printf(TEXT("data=0x%x bytes\n"), *(WORD
*)mem
);