ReactOS 0.4.16-dev-197-g92996da
dialog.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 <commctrl.h>
24#include <tchar.h>
25#include <assert.h>
26#include "resource.h"
27#include "trace.h"
28
29
30#define _USE_MSG_PUMP_
31
32typedef struct tagDialogData {
36
42
43LRESULT CreateMemoryDialog(HINSTANCE, HWND hwndOwner, LPSTR lpszMessage);
47
49
50static BOOL OnCreate(HWND hWnd, LONG lData)
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}
90
92{
93 switch (TabCtrl_GetCurSel(hTabWnd)) {
94 case 0:
100 break;
101 case 1:
107 break;
108 case 2:
114 break;
115 }
116}
117
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}
181
183 HINSTANCE hPrevInstance,
184 LPSTR lpCmdLine,
185 int nCmdShow)
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
HWND hWnd
Definition: settings.c:17
#define IDC_TAB
Definition: resource.h:12
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:870
DLGPROC DlgProc
Definition: desk.c:122
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define APIENTRY
Definition: api.h:79
#define CALLBACK
Definition: compat.h:35
#define IDR_ACCELERATOR
Definition: resource.h:103
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define assert(x)
Definition: debug.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _tcscpy
Definition: tchar.h:623
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Definition: dialog.c:182
INT_PTR CALLBACK PageWndProc2(HWND, UINT, WPARAM, LPARAM)
Definition: page2.c:37
struct tagDialogData DialogData
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
INT_PTR CALLBACK PageWndProc3(HWND, UINT, WPARAM, LPARAM)
Definition: page3.c:37
void OnTabWndSelChange(void)
Definition: dialog.c:91
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 hTabWnd
Definition: dialog.c:38
HWND hPage1
Definition: dialog.c:39
#define IDD_PAGE2
Definition: resource.h:7
#define IDD_PAGE3
Definition: resource.h:8
#define IDD_TABBED_DIALOG
Definition: resource.h:4
#define IDD_PAGE1
Definition: resource.h:6
HACCEL hAccel
Definition: main.c:47
static ATOM item
Definition: dde.c:856
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
#define TabCtrl_GetCurSel(hwnd)
Definition: commctrl.h:4068
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 TCN_SELCHANGE
Definition: commctrl.h:4137
#define TCIF_TEXT
Definition: commctrl.h:3976
#define WM_NOTIFY
Definition: richedit.h:61
#define memset(x, y, z)
Definition: compat.h:39
Definition: comerr.c:44
Definition: tftpd.h:60
HWND hWnd
Definition: dialog.c:33
LONG lData
Definition: dialog.c:34
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
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int32_t INT_PTR
Definition: typedefs.h:64
#define _T(x)
Definition: vfdio.h:22
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define SW_HIDE
Definition: winuser.h:771
#define DWLP_USER
Definition: winuser.h:875
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5738
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#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 CreateDialog
Definition: winuser.h:5761
#define CreateDialogParam
Definition: winuser.h:5764
#define WM_INITDIALOG
Definition: winuser.h:1742
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:833
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
#define GetMessage
Definition: winuser.h:5802
HWND WINAPI SetFocus(_In_opt_ HWND)
struct tagNMHDR * LPNMHDR
#define SW_SHOW
Definition: winuser.h:778
#define WM_DESTROY
Definition: winuser.h:1612
#define DispatchMessage
Definition: winuser.h:5777
#define TranslateAccelerator
Definition: winuser.h:5872
BOOL WINAPI DestroyWindow(_In_ HWND)
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI BringWindowToTop(_In_ HWND)
#define LoadAccelerators
Definition: winuser.h:5822
#define DialogBox
Definition: winuser.h:5773
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
char TCHAR
Definition: xmlstorage.h:189
char * LPSTR
Definition: xmlstorage.h:182
const CHAR * LPCTSTR
Definition: xmlstorage.h:193