From 9447d23bc18e2717ff83ad7b9c3bfae749aa35d4 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sun, 28 Mar 2004 20:32:23 +0000 Subject: [PATCH] option "display version on desktop background" svn path=/trunk/; revision=8908 --- .../system/explorer/dialogs/settings.cpp | 41 ++++++++++++++++--- .../subsys/system/explorer/dialogs/settings.h | 3 ++ .../system/explorer/utility/utility.cpp | 19 +++++++++ .../subsys/system/explorer/utility/utility.h | 3 ++ .../subsys/system/explorer/utility/window.cpp | 15 ++----- .../subsys/system/explorer/utility/window.h | 1 - .../system/explorer/utility/xmlstorage.h | 19 ++++++++- 7 files changed, 80 insertions(+), 21 deletions(-) diff --git a/reactos/subsys/system/explorer/dialogs/settings.cpp b/reactos/subsys/system/explorer/dialogs/settings.cpp index 1d6f80179e0..2260b448661 100644 --- a/reactos/subsys/system/explorer/dialogs/settings.cpp +++ b/reactos/subsys/system/explorer/dialogs/settings.cpp @@ -95,6 +95,9 @@ DesktopSettingsDlg::DesktopSettingsDlg(HWND hwnd) _alignment_cur = SendMessage(g_Globals._hwndShellView, PM_GET_ICON_ALGORITHM, 0, 0); _alignment_tmp = _alignment_cur; + + _display_version_org = SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,0)); + CheckDlgButton(hwnd, ID_DESKTOP_VERSION, _display_version_org? BST_CHECKED: BST_UNCHECKED); } #ifndef PSN_QUERYINITIALFOCUS // currently (as of 18.01.2004) missing in MinGW headers @@ -110,11 +113,13 @@ int DesktopSettingsDlg::Notify(int id, NMHDR* pnmh) case PSN_APPLY: _alignment_cur = _alignment_tmp; + _display_version_org = SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,0)); break; case PSN_RESET: if (_alignment_tmp != _alignment_cur) SendMessage(g_Globals._hwndShellView, PM_SET_ICON_ALGORITHM, _alignment_cur, 0); + SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, _display_version_org, MAKELONG(1,0)); break; default: @@ -140,7 +145,17 @@ int DesktopSettingsDlg::Command(int id, int code) return 0; } - return 1; + switch(id) { + case ID_DESKTOP_VERSION: + SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,1)); // toggle version display flag + PropSheet_Changed(GetParent(_hwnd), _hwnd); + break; + + default: + return 1; + } + + return 0; } @@ -152,6 +167,25 @@ TaskbarSettingsDlg::TaskbarSettingsDlg(HWND hwnd) CheckDlgButton(hwnd, ID_HIDE_INACTIVE_ICONS, XMLBool(g_Globals.get_cfg("notify-icons"), "options", "hide-inactive", true)? BST_CHECKED: BST_UNCHECKED); } +int TaskbarSettingsDlg::Notify(int id, NMHDR* pnmh) +{ + switch(pnmh->code) { + case PSN_APPLY: + _cfg_org = g_Globals._cfg; + break; + + case PSN_RESET: + g_Globals._cfg = _cfg_org; + SendMessage(g_Globals._hwndDesktopBar, PM_REFRESH_CONFIG, 0, 0); + break; + + default: + return super::Notify(id, pnmh); + } + + return 0; +} + int TaskbarSettingsDlg::Command(int id, int code) { switch(id) { @@ -171,11 +205,6 @@ int TaskbarSettingsDlg::Command(int id, int code) PropSheet_Changed(GetParent(_hwnd), _hwnd); break; - case PSN_RESET: - g_Globals._cfg = _cfg_org; - SendMessage(g_Globals._hwndDesktopBar, PM_REFRESH_CONFIG, 0, 0); - break; - default: return 1; } diff --git a/reactos/subsys/system/explorer/dialogs/settings.h b/reactos/subsys/system/explorer/dialogs/settings.h index e555194fd4f..6886fe6d551 100644 --- a/reactos/subsys/system/explorer/dialogs/settings.h +++ b/reactos/subsys/system/explorer/dialogs/settings.h @@ -54,6 +54,8 @@ protected: int _alignment_cur; int _alignment_tmp; + int _display_version_org; + virtual int Command(int id, int code); virtual int Notify(int id, NMHDR* pnmh); }; @@ -67,6 +69,7 @@ struct TaskbarSettingsDlg : public PropSheetPageDlg TaskbarSettingsDlg(HWND hwnd); virtual int Command(int id, int code); + virtual int Notify(int id, NMHDR* pnmh); protected: XMLDoc _cfg_org; diff --git a/reactos/subsys/system/explorer/utility/utility.cpp b/reactos/subsys/system/explorer/utility/utility.cpp index f10b92f5ec0..06fa618bd2d 100644 --- a/reactos/subsys/system/explorer/utility/utility.cpp +++ b/reactos/subsys/system/explorer/utility/utility.cpp @@ -333,3 +333,22 @@ BOOL RecursiveCreateDirectory(LPCTSTR path_in) return TRUE; } + + +DWORD RegGetDWORDValue(HKEY root, LPCTSTR path, LPCTSTR valueName, DWORD def) +{ + HKEY hkey; + DWORD ret; + + if (!RegOpenKey(root, path, &hkey)) { + DWORD len = sizeof(ret); + + if (RegQueryValueEx(hkey, valueName, 0, NULL, (LPBYTE)&ret, &len)) + ret = def; + + RegCloseKey(hkey); + + return ret; + } else + return def; +} diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index d4fd1255222..8ffaafe1da2 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -149,6 +149,9 @@ extern int find_window_class(LPCTSTR classname); // create a directory with all missing parent directories BOOL RecursiveCreateDirectory(LPCTSTR path_in); + // read DWORD value from registry +DWORD RegGetDWORDValue(HKEY root, LPCTSTR path, LPCTSTR valueName, DWORD def); + #ifdef __cplusplus } // extern "C" diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index f1124a99ac4..759d6c8ef45 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -649,11 +649,6 @@ Dialog::~Dialog() unregister_dialog(_hwnd); } -LRESULT Dialog::Init(LPCREATESTRUCT pcs) -{ - return TRUE; // set standard focus -} - int Dialog::DoModal(UINT nid, CREATORFUNC creator, HWND hwndParent) { Lock lock(GetStaticWindowData()._create_crit_sect); // protect access to s_window_creator and s_new_info @@ -685,7 +680,7 @@ INT_PTR CALLBACK Window::DialogProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM if (pThis) { switch(nmsg) { case WM_COMMAND: - SetWindowLong(hwnd, DWL_MSGRESULT, (LPARAM)pThis->Command(LOWORD(wparam), HIWORD(wparam))); + pThis->Command(LOWORD(wparam), HIWORD(wparam)); return TRUE; // message has been processed case WM_NOTIFY: @@ -708,8 +703,6 @@ INT_PTR CALLBACK Window::DialogProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM if (pThis) return pThis->Init(NULL); - - return TRUE; } return FALSE; // message has not been processed @@ -1373,7 +1366,7 @@ INT_PTR CALLBACK PropSheetPageDlg::DialogProc(HWND hwnd, UINT nmsg, WPARAM wpara if (pThis) { switch(nmsg) { case WM_COMMAND: - SetWindowLong(hwnd, DWL_MSGRESULT, (LPARAM)pThis->Command(LOWORD(wparam), HIWORD(wparam))); + pThis->Command(LOWORD(wparam), HIWORD(wparam)); return TRUE; // message has been processed case WM_NOTIFY: @@ -1401,8 +1394,6 @@ INT_PTR CALLBACK PropSheetPageDlg::DialogProc(HWND hwnd, UINT nmsg, WPARAM wpara if (pThis) return pThis->Init(NULL); } - - return TRUE; } return FALSE; // message has not been processed @@ -1412,5 +1403,5 @@ int PropSheetPageDlg::Command(int id, int code) { // override call to EndDialog in Dialog::Command(); - return 1; + return FALSE; } diff --git a/reactos/subsys/system/explorer/utility/window.h b/reactos/subsys/system/explorer/utility/window.h index 19d20e45210..5bd030bd531 100644 --- a/reactos/subsys/system/explorer/utility/window.h +++ b/reactos/subsys/system/explorer/utility/window.h @@ -371,7 +371,6 @@ struct Dialog : public Window static int DoModal(UINT nid, CREATORFUNC_INFO creator, const void* info, HWND hwndParent=0); protected: - LRESULT Init(LPCREATESTRUCT pcs); LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); int Command(int id, int code); }; diff --git a/reactos/subsys/system/explorer/utility/xmlstorage.h b/reactos/subsys/system/explorer/utility/xmlstorage.h index c242e751b47..9ec09ef302a 100644 --- a/reactos/subsys/system/explorer/utility/xmlstorage.h +++ b/reactos/subsys/system/explorer/utility/xmlstorage.h @@ -303,6 +303,21 @@ struct XMLNode : public String } } + XMLNode& operator=(const XMLNode& other) + { + _children.clear(); + + for(Children::const_iterator it=other._children.begin(); it!=other._children.end(); ++it) + _children.push_back(new XMLNode(**it)); + + _attributes = other._attributes; + + _content = other._content; + _trailing = other._trailing; + + return *this; + } + /// add a new child node void add_child(XMLNode* child) { @@ -329,7 +344,7 @@ struct XMLNode : public String /// convenient value access in children node String value(const String& name, const String& attr_name) const { - XMLNode* node = find_first(name); + const XMLNode* node = find_first(name); if (node) return (*node)[attr_name]; @@ -365,7 +380,7 @@ struct XMLNode : public String /// convenient value access in children node String value(const char* name, const char* attr_name) const { - XMLNode* node = find_first(name); + const XMLNode* node = find_first(name); if (node) return (*node)[attr_name];