ReactOS 0.4.15-dev-6057-gd708c79
dialog.c
Go to the documentation of this file.
1/*
2 * ReactOS Standard Dialog Application Template
3 *
4 * dialog.c
5 *
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#define WIN32_LEAN_AND_MEAN
24#include <windows.h>
25#include <commctrl.h>
26#include <tchar.h>
27#include <assert.h>
28#include "resource.h"
29#include "trace.h"
30
31
32#define _USE_MSG_PUMP_
33
34typedef struct tagDialogData {
38
44
45LRESULT CreateMemoryDialog(HINSTANCE, HWND hwndOwner, LPSTR lpszMessage);
49
51
52static BOOL OnCreate(HWND hWnd, LONG lData)
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}
92
94{
95 switch (TabCtrl_GetCurSel(hTabWnd)) {
96 case 0:
102 break;
103 case 1:
109 break;
110 case 2:
116 break;
117 }
118}
119
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}
183
184
186 HINSTANCE hPrevInstance,
187 LPSTR lpCmdLine,
188 int nCmdShow)
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
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:893
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define DLGPROC
Definition: maze.c:62
DLGPROC DlgProc
Definition: desk.c:111
#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:91
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:185
struct tagDialogData DialogData
LRESULT CALLBACK PageWndProc1(HWND, UINT, WPARAM, LPARAM)
Definition: page1.c:151
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 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 hTabWnd
Definition: dialog.c:40
HWND hPage1
Definition: dialog.c:41
#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:4063
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 TCN_SELCHANGE
Definition: commctrl.h:4132
#define TCIF_TEXT
Definition: commctrl.h:3971
#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:35
LONG lData
Definition: dialog.c:36
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
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#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:762
#define DWLP_USER
Definition: winuser.h:866
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5716
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#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 CreateDialog
Definition: winuser.h:5739
#define CreateDialogParam
Definition: winuser.h:5742
#define WM_INITDIALOG
Definition: winuser.h:1729
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:824
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
#define GetMessage
Definition: winuser.h:5780
HWND WINAPI SetFocus(_In_opt_ HWND)
struct tagNMHDR * LPNMHDR
#define SW_SHOW
Definition: winuser.h:769
#define WM_DESTROY
Definition: winuser.h:1599
#define DispatchMessage
Definition: winuser.h:5755
#define TranslateAccelerator
Definition: winuser.h:5850
BOOL WINAPI DestroyWindow(_In_ HWND)
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI BringWindowToTop(_In_ HWND)
#define LoadAccelerators
Definition: winuser.h:5800
#define DialogBox
Definition: winuser.h:5751
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