ReactOS 0.4.15-dev-5669-g09dde2c
dialog.c File Reference
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <assert.h>
#include "resource.h"
#include "trace.h"
Include dependency graph for dialog.c:

Go to the source code of this file.

Classes

struct  tagDialogData
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#define _USE_MSG_PUMP_
 

Typedefs

typedef struct tagDialogData DialogData
 

Functions

LRESULT CreateMemoryDialog (HINSTANCE, HWND hwndOwner, LPSTR lpszMessage)
 
LRESULT CALLBACK PageWndProc1 (HWND, UINT, WPARAM, LPARAM)
 
LRESULT CALLBACK PageWndProc2 (HWND, UINT, WPARAM, LPARAM)
 
LRESULT CALLBACK PageWndProc3 (HWND, UINT, WPARAM, LPARAM)
 
static BOOL OnCreate (HWND hWnd, LONG lData)
 
void OnTabWndSelChange (void)
 
LRESULT CALLBACK DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 

Variables

HINSTANCE hInst
 
HWND hTabWnd
 
HWND hPage1
 
HWND hPage2
 
HWND hPage3
 

Macro Definition Documentation

◆ _USE_MSG_PUMP_

#define _USE_MSG_PUMP_

Definition at line 32 of file dialog.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 23 of file dialog.c.

Typedef Documentation

◆ DialogData

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;
61 LPWORD lpw;
62 LPWSTR lpwsz;
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
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}
#define DLGPROC
Definition: maze.c:62
#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:41
LRESULT CALLBACK DialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: memdlg.c:36
#define ID_HELP
Definition: memdlg.c:31
#define ID_TEXT
Definition: memdlg.c:32
#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:3051
short y
Definition: winuser.h:3053
short cy
Definition: winuser.h:3055
DWORD style
Definition: winuser.h:3049
short x
Definition: winuser.h:3052
short cx
Definition: winuser.h:3054
uint16_t * LPWORD
Definition: typedefs.h:56
#define _T(x)
Definition: vfdio.h:22
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define GMEM_ZEROINIT
Definition: winbase.h:306
LONG_PTR LRESULT
Definition: windef.h:209
#define DialogBoxIndirect
Definition: winuser.h:5752
#define DS_MODALFRAME
Definition: winuser.h:375
#define IDOK
Definition: winuser.h:824
struct DLGITEMTEMPLATE * LPDLGITEMTEMPLATE
struct DLGTEMPLATE * LPDLGTEMPLATE
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DlgProc().

◆ DlgProc()

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

Definition at line 120 of file dialog.c.

121{
122 int idctrl;
123 LPNMHDR pnmh;
124 LPCREATESTRUCT lpCS;
125 LONG nThisApp = 0;
127 if (pData) nThisApp = pData->lData;
128
129 switch (message) {
130
131 case WM_CREATE:
132 lpCS = (LPCREATESTRUCT)lParam;
133 assert(lpCS);
134 lpCS->style &= ~WS_POPUP;
135 break;
136
137 case WM_INITDIALOG:
140 if (pData) nThisApp = pData->lData;
141 return OnCreate(hDlg, nThisApp);
142
143#ifdef _USE_MSG_PUMP_
144 case WM_DESTROY:
145 if (pData && (pData->hWnd == hDlg)) {
146 pData->hWnd = 0;
148 }
149 break;
150 case WM_COMMAND:
151 switch (LOWORD(wParam)) {
152 case IDOK:
153 //MessageBox(NULL, _T("Good-bye"), _T("dialog"), MB_ICONEXCLAMATION);
154 CreateMemoryDialog(hInst, GetDesktopWindow(), "DisplayMyMessage");
155 case IDCANCEL:
156 if (pData && (pData->hWnd == hDlg)) {
157 DestroyWindow(pData->hWnd);
158 }
159 break;
160 }
161 break;
162#else
163 case WM_COMMAND:
164 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
165 EndDialog(hDlg, LOWORD(wParam));
166 return TRUE;
167 }
168#endif
169
170 case WM_NOTIFY:
171 idctrl = (int)wParam;
172 pnmh = (LPNMHDR)lParam;
173 if ((pnmh->hwndFrom == hTabWnd) &&
174 (pnmh->idFrom == IDC_TAB) &&
175 (pnmh->code == TCN_SELCHANGE))
176 {
178 }
179 break;
180 }
181 return 0;
182}
#define IDC_TAB
Definition: resource.h:12
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define assert(x)
Definition: debug.h:53
HINSTANCE hInst
Definition: dialog.c:39
static BOOL OnCreate(HWND hWnd, LONG lData)
Definition: dialog.c:52
LRESULT CreateMemoryDialog(HINSTANCE, HWND hwndOwner, LPSTR lpszMessage)
Definition: memdlg.c:56
void OnTabWndSelChange(void)
Definition: dialog.c:93
HWND hTabWnd
Definition: dialog.c:40
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
#define TCN_SELCHANGE
Definition: commctrl.h:4132
#define WM_NOTIFY
Definition: richedit.h:61
Definition: tftpd.h:60
UINT_PTR idFrom
Definition: winuser.h:3148
UINT code
Definition: winuser.h:3149
HWND hwndFrom
Definition: winuser.h:3147
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
#define DWLP_USER
Definition: winuser.h:866
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5716
#define IDCANCEL
Definition: winuser.h:825
#define WM_CREATE
Definition: winuser.h:1598
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1730
#define WM_INITDIALOG
Definition: winuser.h:1729
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
struct tagNMHDR * LPNMHDR
#define WM_DESTROY
Definition: winuser.h:1599
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

◆ OnCreate()

static BOOL OnCreate ( HWND  hWnd,
LONG  lData 
)
static

Definition at line 52 of file dialog.c.

53{
54 TCHAR szTemp[256];
56
57 // Initialize the Windows Common Controls DLL
58#ifdef __GNUC__
60#else
63#endif
64
65 // Create tab pages
70
71 // Insert tabs
72 _tcscpy(szTemp, _T("Page One"));
73 memset(&item, 0, sizeof(TCITEM));
74 item.mask = TCIF_TEXT;
75 item.pszText = szTemp;
77 _tcscpy(szTemp, _T("Page Two"));
78 memset(&item, 0, sizeof(TCITEM));
79 item.mask = TCIF_TEXT;
80 item.pszText = szTemp;
82 _tcscpy(szTemp, _T("Page Three"));
83 memset(&item, 0, sizeof(TCITEM));
84 item.mask = TCIF_TEXT;
85 item.pszText = szTemp;
87
89
90 return TRUE;
91}
HWND hWnd
Definition: settings.c:17
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define _tcscpy
Definition: tchar.h:623
LRESULT CALLBACK PageWndProc1(HWND, UINT, WPARAM, LPARAM)
Definition: page1.c:151
HWND hPage2
Definition: dialog.c:42
LRESULT CALLBACK PageWndProc2(HWND, UINT, WPARAM, LPARAM)
Definition: page2.c:37
LRESULT CALLBACK PageWndProc3(HWND, UINT, WPARAM, LPARAM)
Definition: page3.c:37
HWND hPage3
Definition: dialog.c:43
HWND hPage1
Definition: dialog.c:41
#define IDD_PAGE2
Definition: resource.h:7
#define IDD_PAGE3
Definition: resource.h:8
#define IDD_PAGE1
Definition: resource.h:6
static ATOM item
Definition: dde.c:856
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define TCITEM
Definition: commctrl.h:4029
#define ICC_TAB_CLASSES
Definition: commctrl.h:61
#define TabCtrl_InsertItem(hwnd, iItem, pitem)
Definition: commctrl.h:4051
#define TCIF_TEXT
Definition: commctrl.h:3971
#define memset(x, y, z)
Definition: compat.h:39
Definition: comerr.c:44
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CreateDialog
Definition: winuser.h:5739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:769
#define MAKEINTRESOURCE
Definition: winuser.h:591
char TCHAR
Definition: xmlstorage.h:189

Referenced by DlgProc().

◆ OnTabWndSelChange()

void OnTabWndSelChange ( void  )

Definition at line 93 of file dialog.c.

94{
95 switch (TabCtrl_GetCurSel(hTabWnd)) {
96 case 0:
102 break;
103 case 1:
109 break;
110 case 2:
116 break;
117 }
118}
#define TabCtrl_GetCurSel(hwnd)
Definition: commctrl.h:4063
#define SW_HIDE
Definition: winuser.h:762
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI BringWindowToTop(_In_ HWND)

Referenced by DlgProc(), and OnMainCreate().

◆ PageWndProc1()

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

Definition at line 151 of file page1.c.

152{
153 switch (message) {
154 case WM_INITDIALOG:
155 InitListCtrl(hDlg);
156 return TRUE;
157 case WM_SETFONT:
158 OnSetFont(hDlg, wParam, lParam);
159 return TRUE;
160 case WM_MEASUREITEM:
162 return TRUE;
163 case WM_DRAWITEM:
164 OnDrawItem(hDlg, lParam);
165 return TRUE;
166 case WM_COMMAND:
167 switch (LOWORD(wParam)) {
168 case IDOK:
169 case IDCANCEL:
170 break;
171 }
172 break;
173 }
174 return 0;
175}
static void OnDrawItem(HWND hWnd, LPARAM lParam)
Definition: page1.c:71
void OnSetFont(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: page1.c:125
void OnMeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
Definition: page1.c:138
static void InitListCtrl(HWND hDlg)
Definition: page1.c:52
#define WM_DRAWITEM
Definition: winuser.h:1635
#define WM_SETFONT
Definition: winuser.h:1640
#define WM_MEASUREITEM
Definition: winuser.h:1636

Referenced by OnCreate().

◆ PageWndProc2()

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

Definition at line 37 of file page2.c.

38{
39
40 switch (message) {
41 case WM_INITDIALOG:
42 return TRUE;
43 case WM_COMMAND:
44 switch (LOWORD(wParam)) {
45 case IDOK:
46 case IDCANCEL:
47 break;
48 }
49 break;
50 }
51 return 0;
52}

Referenced by OnCreate().

◆ PageWndProc3()

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

Definition at line 37 of file page3.c.

38{
39
40 switch (message) {
41 case WM_INITDIALOG:
42 return TRUE;
43 case WM_COMMAND:
44 switch (LOWORD(wParam)) {
45 case IDOK:
46 case IDCANCEL:
47 break;
48 }
49 break;
50 }
51 return 0;
52}

Referenced by OnCreate().

◆ WinMain()

int APIENTRY WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 185 of file dialog.c.

189{
190#ifdef _USE_MSG_PUMP_
191 MSG msg;
192 HACCEL hAccel;
193 DialogData instData = { NULL, 34 };
194
197 ShowWindow(instData.hWnd, SW_SHOW);
199 while (GetMessage(&msg, NULL, 0, 0)) {
200 if (!TranslateAccelerator(instData.hWnd, hAccel, &msg)) {
203 }
204 }
205#else
208 //CreateMemoryDialog(hInst, GetDesktopWindow(), "CreateMemoryDialog");
209#endif
210 return 0;
211}
#define msg(x)
Definition: auth_time.c:54
HINSTANCE hInstance
Definition: charmap.c:19
DLGPROC DlgProc
Definition: desk.c:111
#define NULL
Definition: types.h:112
#define IDR_ACCELERATOR
Definition: resource.h:91
#define IDD_TABBED_DIALOG
Definition: resource.h:4
HACCEL hAccel
Definition: main.c:47
HWND hWnd
Definition: dialog.c:35
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define CreateDialogParam
Definition: winuser.h:5742
#define GetMessage
Definition: winuser.h:5780
#define DispatchMessage
Definition: winuser.h:5755
#define TranslateAccelerator
Definition: winuser.h:5850
#define LoadAccelerators
Definition: winuser.h:5800
#define DialogBox
Definition: winuser.h:5751
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Variable Documentation

◆ hInst

HINSTANCE hInst

Definition at line 39 of file dialog.c.

Referenced by DIALOG_CreateControls32(), DIALOG_CreateIndirect(), DlgProc(), OnCreate(), and WinMain().

◆ hPage1

HWND hPage1

Definition at line 41 of file dialog.c.

Referenced by OnCreate(), and OnTabWndSelChange().

◆ hPage2

HWND hPage2

Definition at line 42 of file dialog.c.

Referenced by OnCreate(), and OnTabWndSelChange().

◆ hPage3

HWND hPage3

Definition at line 43 of file dialog.c.

Referenced by OnCreate(), and OnTabWndSelChange().

◆ hTabWnd

HWND hTabWnd

Definition at line 40 of file dialog.c.

Referenced by DlgProc(), OnCreate(), and OnTabWndSelChange().