property sheet dialogs

svn path=/trunk/; revision=7730
This commit is contained in:
Martin Fuchs 2004-01-18 00:33:53 +00:00
parent 71a41b519c
commit 83ea26e456
10 changed files with 478 additions and 57 deletions

View file

@ -38,6 +38,7 @@
#define ID_ACTIVATE 105
#define IDD_SEARCH_PROGRAM 105
#define IDB_DRIVEBAR 106
#define IDD_DESKBAR_DESKTOP 106
#define IDB_IMAGES 107
#define IDD_EXECUTE 108
#define IDR_MAINFRAME 109
@ -68,6 +69,8 @@
#define IDI_NETWORK 148
#define IDI_COMPUTER 149
#define IDM_DESKTOPBAR 150
#define IDD_DESKBAR_TASKBAR 153
#define IDD_DESKBAR_STARTMENU 154
#define ID_VIEW_NAME 401
#define ID_VIEW_ALL_ATTRIBUTES 402
#define ID_VIEW_SELECTED_ATTRIBUTES 403
@ -108,9 +111,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 151
#define _APS_NEXT_RESOURCE_VALUE 153
#define _APS_NEXT_COMMAND_VALUE 40006
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -72,8 +72,8 @@ BEGIN
EDITTEXT 201,3,29,134,12,ES_AUTOHSCROLL
CONTROL "Ca &Simbol",214,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,
45,71,12
DEFPUSHBUTTON "OK",1,158,6,47,14
PUSHBUTTON "Anulare",2,158,23,47,14
DEFPUSHBUTTON "&OK",1,158,6,47,14
PUSHBUTTON "A&nulare",2,158,23,47,14
PUSHBUTTON "&Ajutor",254,158,43,47,14
END
@ -334,8 +334,8 @@ BEGIN
EDITTEXT 201,3,29,134,12,ES_AUTOHSCROLL
CONTROL "Als &Symbol",214,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
3,45,71,12
DEFPUSHBUTTON "OK",1,158,6,47,14
PUSHBUTTON "Abbrechen",2,158,23,47,14
DEFPUSHBUTTON "&OK",1,158,6,47,14
PUSHBUTTON "A&bbrechen",2,158,23,47,14
PUSHBUTTON "&Hilfe",254,158,43,47,14
END
@ -348,8 +348,8 @@ BEGIN
LTEXT "(c) 2003 Martin Fuchs",IDC_STATIC,90,50,70,8
LTEXT "http://www.sky.franken.de/explorer/",IDC_WWW,21,84,104,
8
CONTROL "OK",IDOK,"Button",BS_OWNERDRAW | BS_FLAT | WS_GROUP,151,
90,38,12
CONTROL "&OK",IDOK,"Button",BS_OWNERDRAW | BS_FLAT | WS_GROUP,
151,90,38,12
END
@ -651,8 +651,8 @@ BEGIN
EDITTEXT 201,3,29,134,12,ES_AUTOHSCROLL
CONTROL "As &Symbol",214,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,
45,71,12
DEFPUSHBUTTON "OK",1,158,6,47,14
PUSHBUTTON "Cancel",2,158,23,47,14
DEFPUSHBUTTON "&OK",1,158,6,47,14
PUSHBUTTON "&Cancel",2,158,23,47,14
PUSHBUTTON "&Help",254,158,43,47,14
END
@ -670,6 +670,30 @@ BEGIN
WS_TABSTOP,7,25,130,33
END
IDD_DESKBAR_DESKTOP DIALOG DISCARDABLE 0, 0, 210, 154
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Desktop Properties"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL 130,IDC_STATIC,"Static",SS_BITMAP,74,20,21,98
END
IDD_DESKBAR_TASKBAR DIALOG DISCARDABLE 0, 0, 210, 154
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Taskbar Properties"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL 129,IDC_STATIC,"Static",SS_BITMAP,129,19,21,98
END
IDD_DESKBAR_STARTMENU DIALOG DISCARDABLE 0, 0, 210, 154
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Startmenu Properties"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL 130,IDC_STATIC,"Static",SS_BITMAP,74,20,21,98
END
/////////////////////////////////////////////////////////////////////////////
//
@ -686,6 +710,30 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 58
END
IDD_DESKBAR_DESKTOP, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 203
TOPMARGIN, 7
BOTTOMMARGIN, 147
END
IDD_DESKBAR_TASKBAR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 203
TOPMARGIN, 7
BOTTOMMARGIN, 147
END
IDD_DESKBAR_STARTMENU, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 203
TOPMARGIN, 7
BOTTOMMARGIN, 147
END
END
#endif // APSTUDIO_INVOKED
@ -796,8 +844,8 @@ BEGIN
EDITTEXT 201,3,29,134,12,ES_AUTOHSCROLL
CONTROL "As &Symbol",214,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,
45,71,12
DEFPUSHBUTTON "OK",1,158,6,47,14
PUSHBUTTON "Cancel",2,158,23,47,14
DEFPUSHBUTTON "&OK",1,158,6,47,14
PUSHBUTTON "&Cancel",2,158,23,47,14
PUSHBUTTON "&Help",254,158,43,47,14
END

View file

@ -230,7 +230,7 @@ int DesktopBar::Command(int id, int code)
break;
case ID_DESKTOPBAR_SETTINGS:
MessageBox(_hwnd, TEXT("Not yet implemented"), ResString(IDS_TITLE), MB_OK);
DoPropertySheet();
break;
default:
@ -272,3 +272,99 @@ LRESULT DesktopBar::ProcessCopyData(COPYDATASTRUCT* pcd)
return 0;
}
void DesktopBar::DoPropertySheet()
{
PropertySheetDialog ps(_hwnd);
ps.dwFlags |= PSH_USEICONID | PSH_PROPTITLE;
ps.pszIcon = MAKEINTRESOURCE(IDI_REACTOS);
ps.pszCaption = TEXT("Explorer");
PropSheetPage psp1(IDD_DESKBAR_DESKTOP, WINDOW_CREATOR(DesktopSettingsDlg));
psp1.dwFlags |= PSP_USETITLE;
psp1.pszTitle = TEXT("Desktop");//MAKEINTRESOURCE(IDS_DESKTOP);
ps.add(psp1);
PropSheetPage psp2(IDD_DESKBAR_TASKBAR, WINDOW_CREATOR(TaskbarSettingsDlg));
psp2.dwFlags |= PSP_USETITLE;
psp2.pszTitle = TEXT("Taskbar");//MAKEINTRESOURCE(IDS_DESKTOP);
ps.add(psp2);
PropSheetPage psp3(IDD_DESKBAR_STARTMENU, WINDOW_CREATOR(StartmenuSettingsDlg));
psp3.dwFlags |= PSP_USETITLE;
psp3.pszTitle = TEXT("Start Menu");//MAKEINTRESOURCE(IDS_DESKTOP);
ps.add(psp3);
ps.DoModal();
}
DesktopSettingsDlg::DesktopSettingsDlg(HWND hwnd)
: super(hwnd)
{
}
LRESULT DesktopSettingsDlg::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
case WM_PAINT:
Paint();
break;
default:
return super::WndProc(nmsg, wparam, lparam);
}
return 0;
}
void DesktopSettingsDlg::Paint()
{
PaintCanvas canvas(_hwnd);
FillRect(canvas, &canvas.rcPaint, GetStockBrush(WHITE_BRUSH));
}
TaskbarSettingsDlg::TaskbarSettingsDlg(HWND hwnd)
: super(hwnd)
{
}
LRESULT TaskbarSettingsDlg::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
case WM_PAINT: {
PaintCanvas canvas(_hwnd);
FillRect(canvas, &canvas.rcPaint, GetStockBrush(GRAY_BRUSH));
break;}
default:
return super::WndProc(nmsg, wparam, lparam);
}
return 0;
}
StartmenuSettingsDlg::StartmenuSettingsDlg(HWND hwnd)
: super(hwnd)
{
}
LRESULT StartmenuSettingsDlg::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
case WM_PAINT: {
PaintCanvas canvas(_hwnd);
FillRect(canvas, &canvas.rcPaint, GetStockBrush(DKGRAY_BRUSH));
break;}
default:
return super::WndProc(nmsg, wparam, lparam);
}
return 0;
}

View file

@ -94,4 +94,41 @@ protected:
WindowHandle _hwndQuickLaunch;
struct StartMenuRoot* _startMenuRoot;
void DoPropertySheet();
};
/// "Desktopbar Settings" Property Sheet Dialog
struct DesktopSettingsDlg : public PropSheetPageDlg
{
typedef PropSheetPageDlg super;
DesktopSettingsDlg(HWND hwnd);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
void Paint();
};
/// "Desktopbar Settings" Property Sheet Dialog
struct TaskbarSettingsDlg : public PropSheetPageDlg
{
typedef PropSheetPageDlg super;
TaskbarSettingsDlg(HWND hwnd);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
};
/// "Startmenu Settings" Property Sheet Dialog
struct StartmenuSettingsDlg : public PropSheetPageDlg
{
typedef PropSheetPageDlg super;
StartmenuSettingsDlg(HWND hwnd);
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
};

View file

@ -91,9 +91,9 @@ BtnWindowClass& StartMenu::GetWndClasss()
}
Window::CREATORFUNC StartMenu::s_def_creator = STARTMENU_CREATOR(StartMenu);
Window::CREATORFUNC_INFO StartMenu::s_def_creator = STARTMENU_CREATOR(StartMenu);
HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndParent, LPCTSTR title, CREATORFUNC creator)
HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndParent, LPCTSTR title, CREATORFUNC_INFO creator)
{
UINT style, ex_style;
int top_height;
@ -948,12 +948,12 @@ bool StartMenu::CloseOtherSubmenus(int id)
}
void StartMenu::CreateSubmenu(int id, LPCTSTR title, CREATORFUNC creator)
void StartMenu::CreateSubmenu(int id, LPCTSTR title, CREATORFUNC_INFO creator)
{
CreateSubmenu(id, StartMenuFolders(), title, creator);
}
void StartMenu::CreateSubmenu(int id, int folder_id, LPCTSTR title, CREATORFUNC creator)
void StartMenu::CreateSubmenu(int id, int folder_id, LPCTSTR title, CREATORFUNC_INFO creator)
{
try {
SpecialFolderPath folder(folder_id, _hwnd);
@ -967,7 +967,7 @@ void StartMenu::CreateSubmenu(int id, int folder_id, LPCTSTR title, CREATORFUNC
}
}
void StartMenu::CreateSubmenu(int id, int folder_id1, int folder_id2, LPCTSTR title, CREATORFUNC creator)
void StartMenu::CreateSubmenu(int id, int folder_id1, int folder_id2, LPCTSTR title, CREATORFUNC_INFO creator)
{
StartMenuFolders new_folders;
@ -985,7 +985,7 @@ void StartMenu::CreateSubmenu(int id, int folder_id1, int folder_id2, LPCTSTR ti
CreateSubmenu(id, new_folders, title, creator);
}
void StartMenu::CreateSubmenu(int id, const StartMenuFolders& new_folders, LPCTSTR title, CREATORFUNC creator)
void StartMenu::CreateSubmenu(int id, const StartMenuFolders& new_folders, LPCTSTR title, CREATORFUNC_INFO creator)
{
// Only open one submenu at a time.
if (!CloseOtherSubmenus(id))

View file

@ -146,7 +146,7 @@ struct StartMenuCreateInfo
StartMenuFolders _folders;
int _border_top;
String _title;
Window::CREATORFUNC _creator;
Window::CREATORFUNC_INFO _creator;
};
#define STARTMENU_CREATOR(WND_CLASS) WINDOW_CREATOR_INFO(WND_CLASS, StartMenuCreateInfo)
@ -216,8 +216,8 @@ struct StartMenu :
StartMenu(HWND hwnd, const StartMenuCreateInfo& create_info);
~StartMenu();
static HWND Create(int x, int y, const StartMenuFolders&, HWND hwndParent, LPCTSTR title, CREATORFUNC creator=s_def_creator);
static CREATORFUNC s_def_creator;
static HWND Create(int x, int y, const StartMenuFolders&, HWND hwndParent, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator);
static CREATORFUNC_INFO s_def_creator;
protected:
// overridden member functions
@ -277,10 +277,10 @@ protected:
bool CloseSubmenus() {return CloseOtherSubmenus();}
bool CloseOtherSubmenus(int id=0);
void CreateSubmenu(int id, LPCTSTR title, CREATORFUNC creator=s_def_creator);
void CreateSubmenu(int id, int folder, LPCTSTR title, CREATORFUNC creator=s_def_creator);
void CreateSubmenu(int id, int folder1, int folder2, LPCTSTR title, CREATORFUNC creator=s_def_creator);
void CreateSubmenu(int id, const StartMenuFolders& new_folders, LPCTSTR title, CREATORFUNC creator=s_def_creator);
void CreateSubmenu(int id, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator);
void CreateSubmenu(int id, int folder, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator);
void CreateSubmenu(int id, int folder1, int folder2, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator);
void CreateSubmenu(int id, const StartMenuFolders& new_folders, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator);
void ActivateEntry(int id, const ShellEntrySet& entries);
virtual void CloseStartMenu(int id=0);

View file

@ -149,6 +149,9 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
case PM_GET_WIDTH:
return _sorted_icons.size()*NOTIFYICON_DIST + NOTIFYAREA_SPACE + _clock_width;
case WM_CONTEXTMENU:
break; // don't let WM_CONTEXTMENU go through to the desktop bar
default:
if (nmsg>=WM_MOUSEFIRST && nmsg<=WM_MOUSELAST) {
// close startup menu and other popup menus

View file

@ -62,6 +62,8 @@ extern "C" {
#define for if (0) {} else for
#define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
#define BUFFER_LEN 1024
@ -169,6 +171,8 @@ using namespace std;
#include <map>
#include <set>
#include <list>
#include <vector>
#if _MSC_VER>=1300 // VS.Net
#define _NO_COMUTIL //@@

View file

@ -104,14 +104,14 @@ HWND Window::Create(CREATORFUNC creator, DWORD dwExStyle,
hwndParent, hMenu, g_Globals._hInstance, 0/*lpParam*/);
}
HWND Window::Create(CREATORFUNC creator, const void* info, DWORD dwExStyle,
HWND Window::Create(CREATORFUNC_INFO creator, const void* info, DWORD dwExStyle,
LPCTSTR lpClassName, LPCTSTR lpWindowName,
DWORD dwStyle, int x, int y, int w, int h,
HWND hwndParent, HMENU hMenu/*, LPVOID lpParam*/)
{
Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
s_window_creator = creator;
s_window_creator = (CREATORFUNC) creator;
s_new_info = info;
return CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle,
@ -120,33 +120,29 @@ HWND Window::Create(CREATORFUNC creator, const void* info, DWORD dwExStyle,
}
static Window* s_new_child_wnd = NULL;
Window* Window::create_mdi_child(HWND hmdiclient, const MDICREATESTRUCT& mcs, CREATORFUNC creator, const void* info)
Window* Window::create_mdi_child(HWND hmdiclient, const MDICREATESTRUCT& mcs, CREATORFUNC_INFO creator, const void* info)
{
Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
s_window_creator = creator;
s_window_creator = (CREATORFUNC) creator;
s_new_info = info;
s_new_child_wnd = NULL;
s_hcbtHook = SetWindowsHookEx(WH_CBT, CBTHookProc, 0, GetCurrentThreadId());
s_hcbtHook = SetWindowsHookEx(WH_CBT, MDICBTHookProc, 0, GetCurrentThreadId());
HWND hwnd = (HWND) SendMessage(hmdiclient, WM_MDICREATE, 0, (LPARAM)&mcs);
UnhookWindowsHookEx(s_hcbtHook);
Window* child = s_new_child_wnd;
Window* child = get_window(hwnd);
s_new_info = NULL;
s_new_child_wnd = NULL;
if (!hwnd || !child || !child->_hwnd)
if (child && (!hwnd || !child->_hwnd))
child = NULL;
return child;
}
LRESULT CALLBACK Window::CBTHookProc(int code, WPARAM wparam, LPARAM lparam)
LRESULT CALLBACK Window::MDICBTHookProc(int code, WPARAM wparam, LPARAM lparam)
{
if (code == HCBT_CREATEWND) {
HWND hwnd = (HWND)wparam;
@ -156,9 +152,46 @@ LRESULT CALLBACK Window::CBTHookProc(int code, WPARAM wparam, LPARAM lparam)
if (!child)
child = create_controller(hwnd);
}
if (child)
s_new_child_wnd = child;
return CallNextHookEx(s_hcbtHook, code, wparam, lparam);
}
/*
Window* Window::create_property_sheet(PropertySheetDialog* ppsd, CREATORFUNC creator, const void* info)
{
Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
s_window_creator = creator;
s_new_info = info;
s_hcbtHook = SetWindowsHookEx(WH_CBT, PropSheetCBTHookProc, 0, GetCurrentThreadId());
HWND hwnd = (HWND) PropertySheet(ppsd);
UnhookWindowsHookEx(s_hcbtHook);
Window* child = get_window(hwnd);
s_new_info = NULL;
if (child && (!hwnd || !child->_hwnd))
child = NULL;
return child;
}
*/
LRESULT CALLBACK Window::PropSheetCBTHookProc(int code, WPARAM wparam, LPARAM lparam)
{
if (code == HCBT_CREATEWND) {
HWND hwnd = (HWND)wparam;
// create Window controller and associate it with the window handle
Window* child = get_window(hwnd);
if (!child)
child = create_controller(hwnd);
}
return CallNextHookEx(s_hcbtHook, code, wparam, lparam);
@ -186,7 +219,7 @@ Window* Window::get_window(HWND hwnd)
Window* Window::create_controller(HWND hwnd)
{
if (s_window_creator) { // protect for recursion
if (s_window_creator) { // protect for recursion and create the window object only for the first window
Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
const void* info = s_new_info;
@ -196,9 +229,9 @@ Window* Window::create_controller(HWND hwnd)
s_window_creator = NULL;
if (info)
return window_creator(hwnd, info);
return CREATORFUNC_INFO(window_creator)(hwnd, info);
else
return CREATORFUNC_NO_INFO(window_creator)(hwnd);
return CREATORFUNC(window_creator)(hwnd);
}
return NULL;
@ -344,7 +377,7 @@ ChildWindow::ChildWindow(HWND hwnd)
}
ChildWindow* ChildWindow::create(HWND hmdiclient, const RECT& rect, CREATORFUNC creator, LPCTSTR classname, LPCTSTR title, const void* info)
ChildWindow* ChildWindow::create(HWND hmdiclient, const RECT& rect, CREATORFUNC_INFO creator, LPCTSTR classname, LPCTSTR title, const void* info)
{
MDICREATESTRUCT mcs;
@ -612,11 +645,11 @@ int Dialog::DoModal(UINT nid, CREATORFUNC creator, HWND hwndParent)
return DialogBoxParam(g_Globals._hInstance, MAKEINTRESOURCE(nid), hwndParent, DialogProc, 0/*lpParam*/);
}
int Dialog::DoModal(UINT nid, CREATORFUNC creator, const void* info, HWND hwndParent)
int Dialog::DoModal(UINT nid, CREATORFUNC_INFO creator, const void* info, HWND hwndParent)
{
Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info
s_window_creator = creator;
s_window_creator = (CREATORFUNC) creator;
s_new_info = NULL;
return DialogBoxParam(g_Globals._hInstance, MAKEINTRESOURCE(nid), hwndParent, DialogProc, 0/*lpParam*/);
@ -1172,3 +1205,141 @@ void ListSort::sort()
ListView_EnsureVisible(_hwnd, idx, FALSE);
}
}
PropSheetPage::PropSheetPage(UINT nid, Window::CREATORFUNC dlg_creator)
: _dlg_creator(dlg_creator)
{
PROPSHEETPAGE::dwSize = sizeof(PROPSHEETPAGE);
PROPSHEETPAGE::dwFlags = 0;
PROPSHEETPAGE::hInstance = g_Globals._hInstance;
PROPSHEETPAGE::pszTemplate = MAKEINTRESOURCE(nid);
PROPSHEETPAGE::pfnDlgProc = PropSheetPageDlg::DialogProc;
PROPSHEETPAGE::lParam = (LPARAM) this;
}
#ifndef PSM_GETRESULT // currently (as of 18.01.2004) missing in MinGW headers
#define PSM_GETRESULT (WM_USER + 135)
#define PropSheet_GetResult(hDlg) SNDMSG(hDlg, PSM_GETRESULT, 0, 0)
#endif
PropertySheetDialog::PropertySheetDialog(HWND owner)
: _hwnd(0)
{
PROPSHEETHEADER::dwSize = sizeof(PROPSHEETHEADER);
PROPSHEETHEADER::dwFlags = PSH_PROPSHEETPAGE | PSH_MODELESS;
PROPSHEETHEADER::hwndParent = owner;
PROPSHEETHEADER::hInstance = g_Globals._hInstance;
}
void PropertySheetDialog::add(PropSheetPage& psp)
{
_pages.push_back(psp);
}
int PropertySheetDialog::DoModal(int start_page)
{
PROPSHEETHEADER::ppsp = (LPCPROPSHEETPAGE) &_pages[0];
PROPSHEETHEADER::nPages = _pages.size();
PROPSHEETHEADER::nStartPage = start_page;
/*
Window* pwnd = Window::create_property_sheet(this, WINDOW_CREATOR(PropertySheetDlg), NULL);
if (!pwnd)
return -1;
HWND hwndPropSheet = *pwnd;
*/
HWND hwndPropSheet = (HWND) PropertySheet(this);
HWND hwndparent = GetParent(hwndPropSheet);
if (hwndparent)
EnableWindow(hwndparent, FALSE);
int ret = 0;
MSG msg;
while(GetMessage(&msg, 0, 0, 0)) {
try {
if (Window::pretranslate_msg(&msg))
continue;
if (PropSheet_IsDialogMessage(hwndPropSheet, &msg))
continue;
if (Window::dispatch_dialog_msg(&msg))
continue;
TranslateMessage(&msg);
try {
DispatchMessage(&msg);
} catch(COMException& e) {
HandleException(e, 0);
}
if (!PropSheet_GetCurrentPageHwnd(hwndPropSheet)) {
ret = PropSheet_GetResult(hwndPropSheet);
break;
}
} catch(COMException& e) {
HandleException(e, 0);
}
}
if (hwndparent)
EnableWindow(hwndparent, TRUE);
DestroyWindow(hwndPropSheet);
return ret;
}
HWND PropertySheetDialog::GetCurrentPage()
{
HWND hdlg = PropSheet_GetCurrentPageHwnd(_hwnd);
return hdlg;
}
PropSheetPageDlg::PropSheetPageDlg(HWND hwnd)
: super(hwnd)
{
}
INT_PTR CALLBACK PropSheetPageDlg::DialogProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
{
PropSheetPageDlg* pThis = GET_WINDOW(PropSheetPageDlg, hwnd);
if (pThis) {
switch(nmsg) {
case WM_COMMAND:
pThis->Command(LOWORD(wparam), HIWORD(wparam));
return TRUE; // message has been processed
case WM_NOTIFY:
pThis->Notify(wparam, (NMHDR*)lparam);
return TRUE; // message has been processed
case WM_NCDESTROY:
delete pThis;
return TRUE; // message has been processed
default:
return pThis->WndProc(nmsg, wparam, lparam);
}
} else if (nmsg == WM_INITDIALOG) {
PROPSHEETPAGE* psp = (PROPSHEETPAGE*) lparam;
PropSheetPage* ppsp = (PropSheetPage*) psp->lParam;
if (ppsp->_dlg_creator) {
pThis = static_cast<PropSheetPageDlg*>(ppsp->_dlg_creator(hwnd));
if (pThis)
return pThis->Init(NULL);
}
}
return FALSE; // message has not been processed
}

View file

@ -53,20 +53,21 @@ struct Window : public WindowHandle
typedef map<HWND,Window*> WindowMap;
typedef Window* (*CREATORFUNC)(HWND, const void*);
typedef Window* (*CREATORFUNC_NO_INFO)(HWND);
typedef Window* (*CREATORFUNC)(HWND);
typedef Window* (*CREATORFUNC_INFO)(HWND, const void*);
static HWND Create(CREATORFUNC creator, DWORD dwExStyle,
LPCTSTR lpClassName, LPCTSTR lpWindowName,
DWORD dwStyle, int x, int y, int w, int h,
HWND hwndParent=0, HMENU hMenu=0/*, LPVOID lpParam=0*/);
static HWND Create(CREATORFUNC creator, const void* info,
static HWND Create(CREATORFUNC_INFO creator, const void* info,
DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
DWORD dwStyle, int x, int y, int w, int h,
HWND hwndParent=0, HMENU hMenu=0/*, LPVOID lpParam=0*/);
static Window* create_mdi_child(HWND hmdiclient, const MDICREATESTRUCT& mcs, CREATORFUNC creator, const void* info=NULL);
static Window* create_mdi_child(HWND hmdiclient, const MDICREATESTRUCT& mcs, CREATORFUNC_INFO creator, const void* info=NULL);
// static Window* create_property_sheet(struct PropertySheetDialog* ppsd, CREATORFUNC creator, const void* info);
static LRESULT CALLBACK WindowWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam);
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam);
@ -120,7 +121,8 @@ protected:
// MDI child creation
static HHOOK s_hcbtHook;
static LRESULT CALLBACK CBTHookProc(int code, WPARAM wparam, LPARAM lparam);
static LRESULT CALLBACK MDICBTHookProc(int code, WPARAM wparam, LPARAM lparam);
static LRESULT CALLBACK PropSheetCBTHookProc(int code, WPARAM wparam, LPARAM lparam);
static WindowSet s_pretranslate_windows;
static WindowSet s_dialogs;
@ -172,7 +174,7 @@ protected:
};
/// template class used in macro WINDOW_CREATOR to the define creater functions for Window objects
/// template class used in macro WINDOW_CREATOR to define the creater functions for Window objects
template<typename WND_CLASS> struct WindowCreator
{
static WND_CLASS* window_creator(HWND hwnd)
@ -182,7 +184,7 @@ template<typename WND_CLASS> struct WindowCreator
};
#define WINDOW_CREATOR(WND_CLASS) \
(Window::CREATORFUNC) WindowCreator<WND_CLASS>::window_creator
((Window::CREATORFUNC) WindowCreator<WND_CLASS>::window_creator)
/// template class used in macro WINDOW_CREATOR_INFO to the define creater functions for Window objects with additional creation information
@ -195,7 +197,7 @@ template<typename WND_CLASS, typename INFO_CLASS> struct WindowCreatorInfo
};
#define WINDOW_CREATOR_INFO(WND_CLASS, INFO_CLASS) \
(Window::CREATORFUNC) WindowCreatorInfo<WND_CLASS, INFO_CLASS>::window_creator
((Window::CREATORFUNC_INFO) WindowCreatorInfo<WND_CLASS, INFO_CLASS>::window_creator)
/**
@ -276,7 +278,7 @@ struct ChildWindow : public Window
ChildWindow(HWND hwnd);
static ChildWindow* create(HWND hmdiclient, const RECT& rect,
CREATORFUNC creator, LPCTSTR classname, LPCTSTR title=NULL, const void* info=NULL);
CREATORFUNC_INFO creator, LPCTSTR classname, LPCTSTR title=NULL, const void* info=NULL);
protected:
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
@ -345,7 +347,7 @@ struct Dialog : public Window
~Dialog();
static int DoModal(UINT nid, CREATORFUNC creator, HWND hwndParent=0);
static int DoModal(UINT nid, CREATORFUNC creator, const void* info, HWND hwndParent=0);
static int DoModal(UINT nid, CREATORFUNC_INFO creator, const void* info, HWND hwndParent=0);
protected:
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
@ -357,6 +359,63 @@ protected:
#define Frame_CalcFrameClient(hwnd, prt) ((BOOL)SNDMSG(hwnd, PM_FRM_CALC_CLIENT, 0, (LPARAM)(PRECT)prt))
struct PropSheetPage : public PROPSHEETPAGE
{
PropSheetPage(UINT nid, Window::CREATORFUNC dlg_creator);
void init(struct PropertySheetDialog*);
protected:
friend struct PropSheetPageDlg;
Window::CREATORFUNC _dlg_creator;
};
/// Property Sheet dialog
struct PropertySheetDialog : public PROPSHEETHEADER
{
PropertySheetDialog(HWND owner);
void add(PropSheetPage& psp);
int DoModal(int start_page=0);
HWND GetCurrentPage();
protected:
typedef vector<PROPSHEETPAGE> Vector;
Vector _pages;
HWND _hwnd;
};
/// Property Sheet Page (inner dialog)
struct PropSheetPageDlg : public Dialog
{
typedef Dialog super;
PropSheetPageDlg(HWND);
protected:
friend struct PropertySheetDialog;
friend struct PropSheetPage;
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam);
};
/*
/// Property Sheet Dialog (outer dialog)
struct PropertySheetDlg : public SubclassedWindow
{
typedef SubclassedWindow super;
PropertySheetDlg(HWND hwnd) : super(hwnd) {}
};
*/
// Layouting of resizable windows
/// Flags to specify how to move and resize controls when resizing their parent window