2 * ReactOS Standard Dialog Application Template
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
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.
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.
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.
23 #define WIN32_LEAN_AND_MEAN
32 #define _USE_MSG_PUMP_
34 typedef struct tagDialogData
{
45 LRESULT
CreateMemoryDialog(HINSTANCE
, HWND hwndOwner
, LPSTR lpszMessage
);
46 LRESULT CALLBACK
PageWndProc1(HWND
, UINT
, WPARAM
, LPARAM
);
47 LRESULT CALLBACK
PageWndProc2(HWND
, UINT
, WPARAM
, LPARAM
);
48 LRESULT CALLBACK
PageWndProc3(HWND
, UINT
, WPARAM
, LPARAM
);
50 ////////////////////////////////////////////////////////////////////////////////
52 static BOOL
OnCreate(HWND hWnd
, LONG lData
)
57 // Initialize the Windows Common Controls DLL
61 INITCOMMONCONTROLSEX ex
= { sizeof(INITCOMMONCONTROLSEX
), ICC_TAB_CLASSES
};
62 InitCommonControlsEx(&ex
);
66 hTabWnd
= GetDlgItem(hWnd
, IDC_TAB
);
67 hPage1
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PAGE1
), hWnd
, (DLGPROC
)PageWndProc1
);
68 hPage2
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PAGE2
), hWnd
, (DLGPROC
)PageWndProc2
);
69 hPage3
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PAGE3
), hWnd
, (DLGPROC
)PageWndProc3
);
72 _tcscpy(szTemp
, _T("Page One"));
73 memset(&item
, 0, sizeof(TCITEM
));
74 item
.mask
= TCIF_TEXT
;
75 item
.pszText
= szTemp
;
76 TabCtrl_InsertItem(hTabWnd
, 0, &item
);
77 _tcscpy(szTemp
, _T("Page Two"));
78 memset(&item
, 0, sizeof(TCITEM
));
79 item
.mask
= TCIF_TEXT
;
80 item
.pszText
= szTemp
;
81 TabCtrl_InsertItem(hTabWnd
, 1, &item
);
82 _tcscpy(szTemp
, _T("Page Three"));
83 memset(&item
, 0, sizeof(TCITEM
));
84 item
.mask
= TCIF_TEXT
;
85 item
.pszText
= szTemp
;
86 TabCtrl_InsertItem(hTabWnd
, 2, &item
);
88 ShowWindow(hPage1
, SW_SHOW
);
93 void OnTabWndSelChange(void)
95 switch (TabCtrl_GetCurSel(hTabWnd
)) {
97 ShowWindow(hPage1
, SW_SHOW
);
98 ShowWindow(hPage2
, SW_HIDE
);
99 ShowWindow(hPage3
, SW_HIDE
);
100 BringWindowToTop(hPage1
);
104 ShowWindow(hPage1
, SW_HIDE
);
105 ShowWindow(hPage2
, SW_SHOW
);
106 ShowWindow(hPage3
, SW_HIDE
);
107 BringWindowToTop(hPage2
);
111 ShowWindow(hPage1
, SW_HIDE
);
112 ShowWindow(hPage2
, SW_HIDE
);
113 ShowWindow(hPage3
, SW_SHOW
);
114 BringWindowToTop(hPage3
);
120 LRESULT CALLBACK
DlgProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
126 DialogData
* pData
= (DialogData
*)GetWindowLong(hDlg
, DWL_USER
);
127 if (pData
) nThisApp
= pData
->lData
;
132 lpCS
= (LPCREATESTRUCT
)lParam
;
134 lpCS
->style
&= ~WS_POPUP
;
138 pData
= (DialogData
*)lParam
;
139 SetWindowLong(hDlg
, DWL_USER
, (LONG
)pData
);
140 if (pData
) nThisApp
= pData
->lData
;
141 return OnCreate(hDlg
, nThisApp
);
143 #ifdef _USE_MSG_PUMP_
145 if (pData
&& (pData
->hWnd
== hDlg
)) {
151 switch (LOWORD(wParam
)) {
153 //MessageBox(NULL, _T("Good-bye"), _T("dialog"), MB_ICONEXCLAMATION);
154 CreateMemoryDialog(hInst
, GetDesktopWindow(), "DisplayMyMessage");
156 if (pData
&& (pData
->hWnd
== hDlg
)) {
157 DestroyWindow(pData
->hWnd
);
164 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
) {
165 EndDialog(hDlg
, LOWORD(wParam
));
171 idctrl
= (int)wParam
;
172 pnmh
= (LPNMHDR
)lParam
;
173 if ((pnmh
->hwndFrom
== hTabWnd
) &&
174 (pnmh
->idFrom
== IDC_TAB
) &&
175 (pnmh
->code
== TCN_SELCHANGE
))
185 int APIENTRY
WinMain(HINSTANCE hInstance
,
186 HINSTANCE hPrevInstance
,
190 #ifdef _USE_MSG_PUMP_
193 DialogData instData
= { NULL
, 34 };
196 instData
.hWnd
= CreateDialogParam(hInst
, MAKEINTRESOURCE(IDD_TABBED_DIALOG
), NULL
, (DLGPROC
)DlgProc
, (LPARAM
)&instData
);
197 ShowWindow(instData
.hWnd
, SW_SHOW
);
198 hAccel
= LoadAccelerators(hInst
, (LPCTSTR
)IDR_ACCELERATOR
);
199 while (GetMessage(&msg
, (HWND
)NULL
, 0, 0)) {
200 if (!TranslateAccelerator(msg
.hwnd
, hAccel
, &msg
)) {
201 TranslateMessage(&msg
);
202 DispatchMessage(&msg
);
207 DialogBox(hInst
, (LPCTSTR
)IDD_TABBED_DIALOG
, NULL
, (DLGPROC
)DlgProc
);
208 //CreateMemoryDialog(hInst, GetDesktopWindow(), "CreateMemoryDialog");