ReactOS  0.4.15-dev-2956-g61e7ea5
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

LRESULT 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 31 of file memdlg.c.

◆ ID_TEXT

#define ID_TEXT   200

Definition at line 32 of file memdlg.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 23 of file memdlg.c.

Function Documentation

◆ CreateMemoryDialog()

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

Definition at line 56 of file memdlg.c.

57 {
58  HGLOBAL hgbl;
59  LPDLGTEMPLATE lpdt;
60  LPDLGITEMTEMPLATE lpdit;
61  LPWORD lpw;
62  LPWSTR lpwsz;
63  LRESULT ret;
64  int nchar;
65 
66  hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
67  if (!hgbl)
68  return -1;
69 
70  lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl);
71 
72  // Define a dialog box.
74  lpdt->cdit = 3; // number of controls
75  lpdt->x = 10; lpdt->y = 10;
76  lpdt->cx = 100; lpdt->cy = 100;
77  lpw = (LPWORD)(lpdt + 1);
78  *lpw++ = 0; // no menu
79  *lpw++ = 0; // predefined dialog box class (by default)
80 
81  lpwsz = (LPWSTR)lpw;
82  nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "My Dialog", -1, lpwsz, 50);
83  lpw += nchar;
84 
85  //-----------------------
86  // Define an OK button.
87  //-----------------------
88  lpw = lpwAlign(lpw); // align DLGITEMTEMPLATE on DWORD boundary
89  lpdit = (LPDLGITEMTEMPLATE)lpw;
90  lpdit->x = 10; lpdit->y = 70;
91  lpdit->cx = 80; lpdit->cy = 20;
92  lpdit->id = IDOK; // OK button identifier
94 
95  lpw = (LPWORD)(lpdit + 1);
96  *lpw++ = 0xFFFF;
97  *lpw++ = 0x0080; // button class
98 
99  lpwsz = (LPWSTR)lpw;
100  nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "OK", -1, lpwsz, 50);
101  lpw += nchar;
102  lpw = lpwAlign(lpw); // align creation data on DWORD boundary
103  *lpw++ = 0; // no creation data
104 
105  //-----------------------
106  // Define a Help button.
107  //-----------------------
108  lpw = lpwAlign(lpw); // align DLGITEMTEMPLATE on DWORD boundary
109  lpdit = (LPDLGITEMTEMPLATE)lpw;
110  lpdit->x = 55; lpdit->y = 10;
111  lpdit->cx = 40; lpdit->cy = 20;
112  lpdit->id = ID_HELP; // Help button identifier
113  lpdit->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
114 
115  lpw = (LPWORD)(lpdit + 1);
116  *lpw++ = 0xFFFF;
117  *lpw++ = 0x0080; // button class atom
118 
119  lpwsz = (LPWSTR)lpw;
120  nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "Help", -1, lpwsz, 50);
121  lpw += nchar;
122  lpw = lpwAlign(lpw); // align creation data on DWORD boundary
123  *lpw++ = 0; // no creation data
124 
125  //-----------------------
126  // Define a static text control.
127  //-----------------------
128  lpw = lpwAlign(lpw); // align DLGITEMTEMPLATE on DWORD boundary
129  lpdit = (LPDLGITEMTEMPLATE)lpw;
130  lpdit->x = 10; lpdit->y = 10;
131  lpdit->cx = 40; lpdit->cy = 20;
132  lpdit->id = ID_TEXT; // text identifier
133  lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT;
134 
135  lpw = (LPWORD)(lpdit + 1);
136  *lpw++ = 0xFFFF;
137  *lpw++ = 0x0082; // static class
138 
139  for (lpwsz = (LPWSTR)lpw;
140  *lpwsz++ == (WCHAR)*lpszMessage++;
141  );
142  lpw = (LPWORD)lpwsz;
143  lpw = lpwAlign(lpw); // align creation data on DWORD boundary
144  *lpw++ = 0; // no creation data
145 
146  GlobalUnlock(hgbl);
148  if (ret == 0) {
149  TRACE(_T("DialogBoxIndirect() failed due to invalid handle to parent window: 0x%08X"), hwndOwner);
150  } else if (ret == -1) {
152  TRACE(_T("DialogBoxIndirect() failed, GetLastError returned 0x%08X"), error);
153  }
154  GlobalFree(hgbl);
155  return ret;
156 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define IDOK
Definition: winuser.h:824
#define error(str)
Definition: mkdosfs.c:1605
#define CP_ACP
Definition: compat.h:109
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
DWORD style
Definition: winuser.h:3034
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define WS_CHILD
Definition: pedump.c:617
#define DS_MODALFRAME
Definition: winuser.h:375
#define SS_LEFT
Definition: pedump.c:692
struct DLGTEMPLATE * LPDLGTEMPLATE
#define WS_CAPTION
Definition: pedump.c:624
#define _T(x)
Definition: vfdio.h:22
#define DialogBoxIndirect
Definition: winuser.h:5737
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
LPWORD lpwAlign(LPWORD lpIn)
Definition: memdlg.c:41
int ret
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
short x
Definition: winuser.h:3037
short y
Definition: winuser.h:3038
#define BS_PUSHBUTTON
Definition: pedump.c:651
WORD cdit
Definition: winuser.h:3036
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2871
uint16_t * LPWORD
Definition: typedefs.h:56
LRESULT CALLBACK DialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: memdlg.c:36
#define WS_BORDER
Definition: pedump.c:625
#define ID_HELP
Definition: memdlg.c:31
#define WS_POPUP
Definition: pedump.c:616
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
short cy
Definition: winuser.h:3040
#define MultiByteToWideChar
Definition: compat.h:110
struct DLGITEMTEMPLATE * LPDLGITEMTEMPLATE
static HINSTANCE hinst
Definition: edit.c:551
#define ID_TEXT
Definition: memdlg.c:32
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
short cx
Definition: winuser.h:3039
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_SYSMENU
Definition: pedump.c:629
#define GMEM_ZEROINIT
Definition: winbase.h:303

Referenced by DlgProc().

◆ DialogWndProc()

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

Definition at line 36 of file memdlg.c.

37 {
38  return 0;
39 }

Referenced by CreateMemoryDialog().

◆ lpwAlign()

LPWORD lpwAlign ( LPWORD  lpIn)

Definition at line 41 of file memdlg.c.

42 {
43  ULONG_PTR ul;
44 
45  ul = (ULONG_PTR)lpIn;
46  ul += 3;
47  ul >>= 2;
48  ul <<= 2;
49  return (LPWORD)ul;
50 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * LPWORD
Definition: typedefs.h:56
#define ULONG_PTR
Definition: config.h:101

Referenced by CreateMemoryDialog().

Variable Documentation

◆ hInst

HINSTANCE hInst

Definition at line 13 of file dxdiag.c.