ReactOS 0.4.15-dev-7953-g1f49173
memdlg.c
Go to the documentation of this file.
1/*
2 * ReactOS Standard Dialog Application Template
3 *
4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#define WIN32_LEAN_AND_MEAN
22#include <windows.h>
23#include <tchar.h>
24#include "trace.h"
25
26
27extern HINSTANCE hInst;
28
29#define ID_HELP 150
30#define ID_TEXT 200
31
33
35{
36 return 0;
37}
38
40{
41 ULONG_PTR ul;
42
43 ul = (ULONG_PTR)lpIn;
44 ul += 3;
45 ul >>= 2;
46 ul <<= 2;
47 return (LPWORD)ul;
48}
49
51// Create an in memory dialog resource and display.
52// Note: this doesn't work
53//
55{
56 HGLOBAL hgbl;
57 LPDLGTEMPLATE lpdt;
59 LPWORD lpw;
60 LPWSTR lpwsz;
62 int nchar;
63
64 hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
65 if (!hgbl)
66 return -1;
67
68 lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);
69
70 // Define a dialog box.
72 lpdt->cdit = 3; // number of controls
73 lpdt->x = 10; lpdt->y = 10;
74 lpdt->cx = 100; lpdt->cy = 100;
75 lpw = (LPWORD)(lpdt + 1);
76 *lpw++ = 0; // no menu
77 *lpw++ = 0; // predefined dialog box class (by default)
78
79 lpwsz = (LPWSTR)lpw;
80 nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "My Dialog", -1, lpwsz, 50);
81 lpw += nchar;
82
83 //-----------------------
84 // Define an OK button.
85 //-----------------------
86 lpw = lpwAlign(lpw); // align DLGITEMTEMPLATE on DWORD boundary
87 lpdit = (LPDLGITEMTEMPLATE)lpw;
88 lpdit->x = 10; lpdit->y = 70;
89 lpdit->cx = 80; lpdit->cy = 20;
90 lpdit->id = IDOK; // OK button identifier
92
93 lpw = (LPWORD)(lpdit + 1);
94 *lpw++ = 0xFFFF;
95 *lpw++ = 0x0080; // button class
96
97 lpwsz = (LPWSTR)lpw;
98 nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "OK", -1, lpwsz, 50);
99 lpw += nchar;
100 lpw = lpwAlign(lpw); // align creation data on DWORD boundary
101 *lpw++ = 0; // no creation data
102
103 //-----------------------
104 // Define a Help button.
105 //-----------------------
106 lpw = lpwAlign(lpw); // align DLGITEMTEMPLATE on DWORD boundary
107 lpdit = (LPDLGITEMTEMPLATE)lpw;
108 lpdit->x = 55; lpdit->y = 10;
109 lpdit->cx = 40; lpdit->cy = 20;
110 lpdit->id = ID_HELP; // Help button identifier
112
113 lpw = (LPWORD)(lpdit + 1);
114 *lpw++ = 0xFFFF;
115 *lpw++ = 0x0080; // button class atom
116
117 lpwsz = (LPWSTR)lpw;
118 nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "Help", -1, lpwsz, 50);
119 lpw += nchar;
120 lpw = lpwAlign(lpw); // align creation data on DWORD boundary
121 *lpw++ = 0; // no creation data
122
123 //-----------------------
124 // Define a static text control.
125 //-----------------------
126 lpw = lpwAlign(lpw); // align DLGITEMTEMPLATE on DWORD boundary
127 lpdit = (LPDLGITEMTEMPLATE)lpw;
128 lpdit->x = 10; lpdit->y = 10;
129 lpdit->cx = 40; lpdit->cy = 20;
130 lpdit->id = ID_TEXT; // text identifier
131 lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;
132
133 lpw = (LPWORD)(lpdit + 1);
134 *lpw++ = 0xFFFF;
135 *lpw++ = 0x0082; // static class
136
137 for (lpwsz = (LPWSTR)lpw;
138 *lpwsz++ == (WCHAR)*lpszMessage++;
139 );
140 lpw = (LPWORD)lpwsz;
141 lpw = lpwAlign(lpw); // align creation data on DWORD boundary
142 *lpw++ = 0; // no creation data
143
144 GlobalUnlock(hgbl);
146 if (ret == 0) {
147 TRACE(_T("DialogBoxIndirect() failed due to invalid handle to parent window: 0x%08X"), hwndOwner);
148 } else if (ret == -1) {
150 TRACE(_T("DialogBoxIndirect() failed, GetLastError returned 0x%08X"), error);
151 }
152 GlobalFree(hgbl);
153 return ret;
154}
155
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define CP_ACP
Definition: compat.h:109
#define CALLBACK
Definition: compat.h:35
#define MultiByteToWideChar
Definition: compat.h:110
#define ULONG_PTR
Definition: config.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
LPWORD lpwAlign(LPWORD lpIn)
Definition: memdlg.c:39
LRESULT CreateMemoryDialog(HINSTANCE hinst, HWND hwndOwner, LPSTR lpszMessage)
Definition: memdlg.c:54
#define ID_HELP
Definition: memdlg.c:29
HINSTANCE hInst
Definition: dxdiag.c:13
#define ID_TEXT
Definition: memdlg.c:30
INT_PTR CALLBACK DialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: memdlg.c:34
#define error(str)
Definition: mkdosfs.c:1605
static HINSTANCE hinst
Definition: edit.c:551
unsigned int UINT
Definition: ndis.h:50
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_BORDER
Definition: pedump.c:625
#define WS_POPUP
Definition: pedump.c:616
#define WS_VISIBLE
Definition: pedump.c:620
#define SS_LEFT
Definition: pedump.c:692
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
#define TRACE(s)
Definition: solgame.cpp:4
WORD cdit
Definition: winuser.h:3061
short y
Definition: winuser.h:3063
short cy
Definition: winuser.h:3065
DWORD style
Definition: winuser.h:3059
short x
Definition: winuser.h:3062
short cx
Definition: winuser.h:3064
Definition: tftpd.h:60
int32_t INT_PTR
Definition: typedefs.h:64
uint16_t * LPWORD
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define _T(x)
Definition: vfdio.h:22
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GMEM_ZEROINIT
Definition: winbase.h:306
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define DialogBoxIndirect
Definition: winuser.h:5762
#define DS_MODALFRAME
Definition: winuser.h:375
#define IDOK
Definition: winuser.h:830
struct DLGITEMTEMPLATE * LPDLGITEMTEMPLATE
struct DLGTEMPLATE * LPDLGTEMPLATE
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184