ReactOS  0.4.14-dev-114-gc8cbd56
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 
34 typedef struct tagDialogData {
37 } DialogData;
38 
44 
45 LRESULT CreateMemoryDialog(HINSTANCE, HWND hwndOwner, LPSTR lpszMessage);
49 
51 
52 static BOOL OnCreate(HWND hWnd, LONG lData)
53 {
54  TCHAR szTemp[256];
55  TCITEM item;
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:
101  SetFocus(hTabWnd);
102  break;
103  case 1:
108  SetFocus(hTabWnd);
109  break;
110  case 2:
115  SetFocus(hTabWnd);
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:
138  pData = (DialogData*)lParam;
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;
147  PostQuitMessage(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 
195  hInst = hInstance;
197  ShowWindow(instData.hWnd, SW_SHOW);
199  while (GetMessage(&msg, NULL, 0, 0)) {
200  if (!TranslateAccelerator(instData.hWnd, hAccel, &msg)) {
203  }
204  }
205 #else
206  hInst = hInstance;
208  //CreateMemoryDialog(hInst, GetDesktopWindow(), "CreateMemoryDialog");
209 #endif
210  return 0;
211 }
#define TranslateAccelerator
Definition: winuser.h:5761
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5666
BOOL WINAPI TranslateMessage(_In_ const MSG *)
Definition: tftpd.h:59
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Definition: dialog.c:185
LRESULT CreateMemoryDialog(HINSTANCE, HWND hwndOwner, LPSTR lpszMessage)
Definition: memdlg.c:56
#define TRUE
Definition: types.h:120
Definition: comerr.c:44
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define IDOK
Definition: winuser.h:824
#define IDC_TAB
Definition: resource.h:12
#define SW_HIDE
Definition: winuser.h:762
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define CALLBACK
Definition: compat.h:27
HWND hWnd
Definition: settings.c:17
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define assert(x)
Definition: debug.h:53
HWND WINAPI SetFocus(_In_opt_ HWND)
#define TabCtrl_GetCurSel(hwnd)
Definition: commctrl.h:4035
UINT_PTR WPARAM
Definition: windef.h:207
#define TCIF_TEXT
Definition: commctrl.h:3943
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
char * LPSTR
Definition: xmlstorage.h:182
CREATESTRUCTA * LPCREATESTRUCT
Definition: winuser.h:5627
#define IDD_PAGE2
Definition: resource.h:7
BOOL WINAPI DestroyWindow(_In_ HWND)
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
void OnTabWndSelChange(void)
Definition: dialog.c:93
#define IDD_TABBED_DIALOG
Definition: resource.h:4
UINT code
Definition: winuser.h:3133
#define IDD_PAGE3
Definition: resource.h:8
#define DialogBox
Definition: winuser.h:5662
#define LoadAccelerators
Definition: winuser.h:5711
HINSTANCE hInstance
Definition: charmap.c:20
HACCEL hAccel
Definition: main.c:47
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static BOOL OnCreate(HWND hWnd, LONG lData)
Definition: dialog.c:52
UINT_PTR idFrom
Definition: winuser.h:3132
BOOL WINAPI BringWindowToTop(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:652
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT CALLBACK PageWndProc3(HWND, UINT, WPARAM, LPARAM)
Definition: page3.c:37
LRESULT CALLBACK PageWndProc1(HWND, UINT, WPARAM, LPARAM)
Definition: page1.c:151
#define SW_SHOW
Definition: winuser.h:769
HWND hPage1
Definition: dialog.c:41
#define WM_DESTROY
Definition: winuser.h:1591
char TCHAR
Definition: xmlstorage.h:189
#define TCN_SELCHANGE
Definition: commctrl.h:4104
#define _T(x)
Definition: vfdio.h:22
HWND hPage2
Definition: dialog.c:42
HWND hWnd
Definition: dialog.c:35
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
INT_PTR APIENTRY DlgProc(IN HWND hDlg, IN UINT Msg, IN WPARAM wParam, IN LPARAM lParam)
Definition: dialog.c:272
HWND hwndFrom
Definition: winuser.h:3131
HWND hTabWnd
Definition: dialog.c:40
#define IDR_ACCELERATOR
Definition: resource.h:5
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2870
static ATOM item
Definition: dde.c:856
BOOL WINAPI EndDialog(HWND hwnd, INT_PTR retval)
Definition: dialog.c:2028
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
#define GetMessage
Definition: winuser.h:5691
struct tagDialogData DialogData
#define msg(x)
Definition: auth_time.c:54
#define TabCtrl_InsertItem(hwnd, iItem, pitem)
Definition: commctrl.h:4023
#define WM_CREATE
Definition: winuser.h:1590
#define IDD_PAGE1
Definition: resource.h:6
HWND WINAPI GetDlgItem(HWND hDlg, int nIDDlgItem)
Definition: dialog.c:2126
LRESULT CALLBACK PageWndProc2(HWND, UINT, WPARAM, LPARAM)
Definition: page2.c:37
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define TCITEM
Definition: commctrl.h:4001
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
LONG_PTR LRESULT
Definition: windef.h:209
#define memset(x, y, z)
Definition: compat.h:39
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_NOTIFY
Definition: richedit.h:61
HWND hPage3
Definition: dialog.c:43
#define APIENTRY
Definition: api.h:79
#define CreateDialog
Definition: winuser.h:5650
LONG lData
Definition: dialog.c:36
HINSTANCE hInst
Definition: dialog.c:39
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define ICC_TAB_CLASSES
Definition: commctrl.h:61
#define CreateDialogParam
Definition: winuser.h:5653