2 * ReactOS Standard Dialog Application Template
4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
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.
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.
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.
21 #define WIN32_LEAN_AND_MEAN
30 #define _USE_MSG_PUMP_
32 typedef struct tagDialogData
{
43 LRESULT
CreateMemoryDialog(HINSTANCE
, HWND hwndOwner
, LPSTR lpszMessage
);
44 INT_PTR CALLBACK
PageWndProc1(HWND
, UINT
, WPARAM
, LPARAM
);
45 INT_PTR CALLBACK
PageWndProc2(HWND
, UINT
, WPARAM
, LPARAM
);
46 INT_PTR CALLBACK
PageWndProc3(HWND
, UINT
, WPARAM
, LPARAM
);
48 ////////////////////////////////////////////////////////////////////////////////
50 static BOOL
OnCreate(HWND hWnd
, LONG lData
)
55 // Initialize the Windows Common Controls DLL
59 INITCOMMONCONTROLSEX ex
= { sizeof(INITCOMMONCONTROLSEX
), ICC_TAB_CLASSES
};
60 InitCommonControlsEx(&ex
);
64 hTabWnd
= GetDlgItem(hWnd
, IDC_TAB
);
65 hPage1
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PAGE1
), hWnd
, PageWndProc1
);
66 hPage2
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PAGE2
), hWnd
, PageWndProc2
);
67 hPage3
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PAGE3
), hWnd
, PageWndProc3
);
70 _tcscpy(szTemp
, _T("Page One"));
71 memset(&item
, 0, sizeof(TCITEM
));
72 item
.mask
= TCIF_TEXT
;
73 item
.pszText
= szTemp
;
74 TabCtrl_InsertItem(hTabWnd
, 0, &item
);
75 _tcscpy(szTemp
, _T("Page Two"));
76 memset(&item
, 0, sizeof(TCITEM
));
77 item
.mask
= TCIF_TEXT
;
78 item
.pszText
= szTemp
;
79 TabCtrl_InsertItem(hTabWnd
, 1, &item
);
80 _tcscpy(szTemp
, _T("Page Three"));
81 memset(&item
, 0, sizeof(TCITEM
));
82 item
.mask
= TCIF_TEXT
;
83 item
.pszText
= szTemp
;
84 TabCtrl_InsertItem(hTabWnd
, 2, &item
);
86 ShowWindow(hPage1
, SW_SHOW
);
91 void OnTabWndSelChange(void)
93 switch (TabCtrl_GetCurSel(hTabWnd
)) {
95 ShowWindow(hPage1
, SW_SHOW
);
96 ShowWindow(hPage2
, SW_HIDE
);
97 ShowWindow(hPage3
, SW_HIDE
);
98 BringWindowToTop(hPage1
);
102 ShowWindow(hPage1
, SW_HIDE
);
103 ShowWindow(hPage2
, SW_SHOW
);
104 ShowWindow(hPage3
, SW_HIDE
);
105 BringWindowToTop(hPage2
);
109 ShowWindow(hPage1
, SW_HIDE
);
110 ShowWindow(hPage2
, SW_HIDE
);
111 ShowWindow(hPage3
, SW_SHOW
);
112 BringWindowToTop(hPage3
);
118 INT_PTR CALLBACK
DlgProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
124 DialogData
* pData
= (DialogData
*)GetWindowLongPtr(hDlg
, DWLP_USER
);
125 if (pData
) nThisApp
= pData
->lData
;
130 lpCS
= (LPCREATESTRUCT
)lParam
;
132 lpCS
->style
&= ~WS_POPUP
;
136 pData
= (DialogData
*)lParam
;
137 SetWindowLongPtr(hDlg
, DWLP_USER
, (LONG_PTR
)pData
);
138 if (pData
) nThisApp
= pData
->lData
;
139 return OnCreate(hDlg
, nThisApp
);
141 #ifdef _USE_MSG_PUMP_
143 if (pData
&& (pData
->hWnd
== hDlg
)) {
149 switch (LOWORD(wParam
)) {
151 //MessageBox(NULL, _T("Good-bye"), _T("dialog"), MB_ICONEXCLAMATION);
152 CreateMemoryDialog(hInst
, GetDesktopWindow(), "DisplayMyMessage");
154 if (pData
&& (pData
->hWnd
== hDlg
)) {
155 DestroyWindow(pData
->hWnd
);
162 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
) {
163 EndDialog(hDlg
, LOWORD(wParam
));
169 idctrl
= (int)wParam
;
170 pnmh
= (LPNMHDR
)lParam
;
171 if ((pnmh
->hwndFrom
== hTabWnd
) &&
172 (pnmh
->idFrom
== IDC_TAB
) &&
173 (pnmh
->code
== TCN_SELCHANGE
))
182 int APIENTRY
WinMain(HINSTANCE hInstance
,
183 HINSTANCE hPrevInstance
,
187 #ifdef _USE_MSG_PUMP_
190 DialogData instData
= { NULL
, 34 };
193 instData
.hWnd
= CreateDialogParam(hInst
, MAKEINTRESOURCE(IDD_TABBED_DIALOG
), NULL
, DlgProc
, (LPARAM
)&instData
);
194 ShowWindow(instData
.hWnd
, SW_SHOW
);
195 hAccel
= LoadAccelerators(hInst
, (LPCTSTR
)IDR_ACCELERATOR
);
196 while (GetMessage(&msg
, NULL
, 0, 0)) {
197 if (!TranslateAccelerator(instData
.hWnd
, hAccel
, &msg
)) {
198 TranslateMessage(&msg
);
199 DispatchMessage(&msg
);
204 DialogBox(hInst
, (LPCTSTR
)IDD_TABBED_DIALOG
, NULL
, DlgProc
);
205 //CreateMemoryDialog(hInst, GetDesktopWindow(), "CreateMemoryDialog");