ReactOS 0.4.15-dev-8096-ga0eec98
memdlg.c File Reference
#include <windows.h>
#include <tchar.h>
#include "trace.h"
Include dependency graph for memdlg.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 
#define ID_HELP   150
 
#define ID_TEXT   200
 

Functions

INT_PTR CALLBACK DialogWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
LPWORD lpwAlign (LPWORD lpIn)
 
LRESULT CreateMemoryDialog (HINSTANCE hinst, HWND hwndOwner, LPSTR lpszMessage)
 

Variables

HINSTANCE hInst
 

Macro Definition Documentation

◆ ID_HELP

#define ID_HELP   150

Definition at line 29 of file memdlg.c.

◆ ID_TEXT

#define ID_TEXT   200

Definition at line 30 of file memdlg.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 21 of file memdlg.c.

Function Documentation

◆ CreateMemoryDialog()

LRESULT CreateMemoryDialog ( HINSTANCE  hinst,
HWND  hwndOwner,
LPSTR  lpszMessage 
)

Definition at line 54 of file memdlg.c.

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}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
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
#define ID_HELP
Definition: memdlg.c:29
#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
#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
uint16_t * LPWORD
Definition: typedefs.h:56
#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 LRESULT
Definition: windef.h:209
#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
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DlgProc().

◆ DialogWndProc()

INT_PTR CALLBACK DialogWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 34 of file memdlg.c.

35{
36 return 0;
37}

Referenced by CreateMemoryDialog().

◆ lpwAlign()

LPWORD lpwAlign ( LPWORD  lpIn)

Definition at line 39 of file memdlg.c.

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}
#define ULONG_PTR
Definition: config.h:101
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by CreateMemoryDialog().

Variable Documentation

◆ hInst

HINSTANCE hInst
extern

Definition at line 13 of file dxdiag.c.