ReactOS 0.4.16-dev-311-g9382aa2
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)
 
INT_PTR CALLBACK PageWndProc1 (HWND, UINT, WPARAM, LPARAM)
 
INT_PTR CALLBACK PageWndProc2 (HWND, UINT, WPARAM, LPARAM)
 
INT_PTR CALLBACK PageWndProc3 (HWND, UINT, WPARAM, LPARAM)
 
static BOOL OnCreate (HWND hWnd, LONG lData)
 
void OnTabWndSelChange (void)
 
INT_PTR 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 30 of file dialog.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 21 of file dialog.c.

Typedef Documentation

◆ DialogData

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:3064
short y
Definition: winuser.h:3066
short cy
Definition: winuser.h:3068
DWORD style
Definition: winuser.h:3062
short x
Definition: winuser.h:3065
short cx
Definition: winuser.h:3067
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:332
LONG_PTR LRESULT
Definition: windef.h:209
#define DialogBoxIndirect
Definition: winuser.h:5774
#define DS_MODALFRAME
Definition: winuser.h:375
#define IDOK
Definition: winuser.h:833
struct DLGITEMTEMPLATE * LPDLGITEMTEMPLATE
struct DLGTEMPLATE * LPDLGTEMPLATE
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DlgProc().

◆ DlgProc()

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

Definition at line 118 of file dialog.c.

119{
120 int idctrl;
121 LPNMHDR pnmh;
122 LPCREATESTRUCT lpCS;
123 LONG nThisApp = 0;
125 if (pData) nThisApp = pData->lData;
126
127 switch (message) {
128
129 case WM_CREATE:
130 lpCS = (LPCREATESTRUCT)lParam;
131 assert(lpCS);
132 lpCS->style &= ~WS_POPUP;
133 break;
134
135 case WM_INITDIALOG:
138 if (pData) nThisApp = pData->lData;
139 return OnCreate(hDlg, nThisApp);
140
141#ifdef _USE_MSG_PUMP_
142 case WM_DESTROY:
143 if (pData && (pData->hWnd == hDlg)) {
144 pData->hWnd = 0;
146 }
147 break;
148 case WM_COMMAND:
149 switch (LOWORD(wParam)) {
150 case IDOK:
151 //MessageBox(NULL, _T("Good-bye"), _T("dialog"), MB_ICONEXCLAMATION);
152 CreateMemoryDialog(hInst, GetDesktopWindow(), "DisplayMyMessage");
153 case IDCANCEL:
154 if (pData && (pData->hWnd == hDlg)) {
155 DestroyWindow(pData->hWnd);
156 }
157 break;
158 }
159 break;
160#else
161 case WM_COMMAND:
162 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
163 EndDialog(hDlg, LOWORD(wParam));
164 return TRUE;
165 }
166#endif
167
168 case WM_NOTIFY:
169 idctrl = (int)wParam;
170 pnmh = (LPNMHDR)lParam;
171 if ((pnmh->hwndFrom == hTabWnd) &&
172 (pnmh->idFrom == IDC_TAB) &&
173 (pnmh->code == TCN_SELCHANGE))
174 {
176 }
177 break;
178 }
179 return 0;
180}
#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:37
static BOOL OnCreate(HWND hWnd, LONG lData)
Definition: dialog.c:50
LRESULT CreateMemoryDialog(HINSTANCE, HWND hwndOwner, LPSTR lpszMessage)
Definition: memdlg.c:54
void OnTabWndSelChange(void)
Definition: dialog.c:91
HWND hTabWnd
Definition: dialog.c:38
__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:4137
#define WM_NOTIFY
Definition: richedit.h:61
Definition: tftpd.h:60
UINT_PTR idFrom
Definition: winuser.h:3161
UINT code
Definition: winuser.h:3162
HWND hwndFrom
Definition: winuser.h:3160
#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:875
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5738
#define IDCANCEL
Definition: winuser.h:834
#define WM_CREATE
Definition: winuser.h:1611
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
struct tagNMHDR * LPNMHDR
#define WM_DESTROY
Definition: winuser.h:1612
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 50 of file dialog.c.

51{
52 TCHAR szTemp[256];
54
55 // Initialize the Windows Common Controls DLL
56#ifdef __GNUC__
58#else
61#endif
62
63 // Create tab pages
68
69 // Insert tabs
70 _tcscpy(szTemp, _T("Page One"));
71 memset(&item, 0, sizeof(TCITEM));
72 item.mask = TCIF_TEXT;
73 item.pszText = szTemp;
75 _tcscpy(szTemp, _T("Page Two"));
76 memset(&item, 0, sizeof(TCITEM));
77 item.mask = TCIF_TEXT;
78 item.pszText = szTemp;
80 _tcscpy(szTemp, _T("Page Three"));
81 memset(&item, 0, sizeof(TCITEM));
82 item.mask = TCIF_TEXT;
83 item.pszText = szTemp;
85
87
88 return TRUE;
89}
HWND hWnd
Definition: settings.c:17
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:870
#define _tcscpy
Definition: tchar.h:623
INT_PTR CALLBACK PageWndProc2(HWND, UINT, WPARAM, LPARAM)
Definition: page2.c:37
INT_PTR CALLBACK PageWndProc3(HWND, UINT, WPARAM, LPARAM)
Definition: page3.c:37
HWND hPage2
Definition: dialog.c:40
HWND hPage3
Definition: dialog.c:41
INT_PTR CALLBACK PageWndProc1(HWND, UINT, WPARAM, LPARAM)
Definition: page1.c:151
HWND hPage1
Definition: dialog.c:39
#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:4034
#define ICC_TAB_CLASSES
Definition: commctrl.h:61
#define TabCtrl_InsertItem(hwnd, iItem, pitem)
Definition: commctrl.h:4056
#define TCIF_TEXT
Definition: commctrl.h:3976
#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:5761
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:778
#define MAKEINTRESOURCE
Definition: winuser.h:591
char TCHAR
Definition: xmlstorage.h:189

Referenced by DlgProc().

◆ OnTabWndSelChange()

void OnTabWndSelChange ( void  )

Definition at line 91 of file dialog.c.

92{
93 switch (TabCtrl_GetCurSel(hTabWnd)) {
94 case 0:
100 break;
101 case 1:
107 break;
108 case 2:
114 break;
115 }
116}
#define TabCtrl_GetCurSel(hwnd)
Definition: commctrl.h:4068
#define SW_HIDE
Definition: winuser.h:771
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI BringWindowToTop(_In_ HWND)

Referenced by DlgProc(), and OnMainCreate().

◆ PageWndProc1()

INT_PTR 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:1648
#define WM_SETFONT
Definition: winuser.h:1653
#define WM_MEASUREITEM
Definition: winuser.h:1649

Referenced by OnCreate().

◆ PageWndProc2()

INT_PTR 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()

INT_PTR 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 182 of file dialog.c.

186{
187#ifdef _USE_MSG_PUMP_
188 MSG msg;
189 HACCEL hAccel;
190 DialogData instData = { NULL, 34 };
191
194 ShowWindow(instData.hWnd, SW_SHOW);
196 while (GetMessage(&msg, NULL, 0, 0)) {
197 if (!TranslateAccelerator(instData.hWnd, hAccel, &msg)) {
200 }
201 }
202#else
205 //CreateMemoryDialog(hInst, GetDesktopWindow(), "CreateMemoryDialog");
206#endif
207 return 0;
208}
#define msg(x)
Definition: auth_time.c:54
HINSTANCE hInstance
Definition: charmap.c:19
DLGPROC DlgProc
Definition: desk.c:122
#define NULL
Definition: types.h:112
#define IDR_ACCELERATOR
Definition: resource.h:103
#define IDD_TABBED_DIALOG
Definition: resource.h:4
HACCEL hAccel
Definition: main.c:47
HWND hWnd
Definition: dialog.c:33
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:5764
#define GetMessage
Definition: winuser.h:5802
#define DispatchMessage
Definition: winuser.h:5777
#define TranslateAccelerator
Definition: winuser.h:5872
#define LoadAccelerators
Definition: winuser.h:5822
#define DialogBox
Definition: winuser.h:5773
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Variable Documentation

◆ hInst

HINSTANCE hInst

Definition at line 37 of file dialog.c.

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

◆ hPage1

HWND hPage1

Definition at line 39 of file dialog.c.

Referenced by OnCreate(), and OnTabWndSelChange().

◆ hPage2

HWND hPage2

Definition at line 40 of file dialog.c.

Referenced by OnCreate(), and OnTabWndSelChange().

◆ hPage3

HWND hPage3

Definition at line 41 of file dialog.c.

Referenced by OnCreate(), and OnTabWndSelChange().

◆ hTabWnd

HWND hTabWnd

Definition at line 38 of file dialog.c.

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