diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-20 09:03:03 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-20 09:03:03 +0000 |
commit | 0e3ebe2dccd658e2f2188c52934e184c570f60f4 (patch) | |
tree | 44ec6459444fef8318bb7bae33b15d20a26c59f2 | |
parent | 1607e029384e76949e0de333f3b043a21dea2313 (diff) |
fix for a crash in ShellExt options
git-svn-id: http://svn.miranda-ng.org/main/trunk@14283 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/ShellExt/src/options.cpp | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/plugins/ShellExt/src/options.cpp b/plugins/ShellExt/src/options.cpp index 3e4ddc83f8..e57194bf68 100644 --- a/plugins/ShellExt/src/options.cpp +++ b/plugins/ShellExt/src/options.cpp @@ -25,63 +25,70 @@ static TCHAR* COM_OKSTR[2] = { LPGENT("Successfully created shell registration.") };
static TCHAR* COM_APPROVEDSTR[2] = { LPGENT("Not Approved"), LPGENT("Approved") };
-static INT_PTR CALLBACK OptDialogProc(HWND hwndDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
+static void InitControls(HWND hwndDlg)
{
- int comReg, iCheck;
+ int comReg = IsCOMRegistered();
+
TCHAR szBuf[MAX_PATH];
+ mir_sntprintf(szBuf, _countof(szBuf), _T("%s (%s)"),
+ TranslateTS(COM_OKSTR[(comReg & COMREG_OK) != 0]),
+ TranslateTS(COM_APPROVEDSTR[(comReg & COMREG_APPROVED) != 0]));
+ SetDlgItemText(hwndDlg, IDC_STATUS, szBuf);
+
+ // auto size the static windows to fit their text
+ // they're rendering in a font not selected into the DC.
+ AutoSize(GetDlgItem(hwndDlg, IDC_CAPMENUS));
+ AutoSize(GetDlgItem(hwndDlg, IDC_CAPSTATUS));
+ AutoSize(GetDlgItem(hwndDlg, IDC_CAPSHLSTATUS));
+
+ // show all the options
+ int iCheck = db_get_b(0, SHLExt_Name, SHLExt_UseGroups, BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_USEGROUPS, iCheck ? BST_CHECKED : BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CLISTGROUPS), iCheck = BST_CHECKED);
+ CheckDlgButton(hwndDlg, IDC_CLISTGROUPS, db_get_b(0, SHLExt_Name, SHLExt_UseCListSetting, BST_UNCHECKED));
+ CheckDlgButton(hwndDlg, IDC_NOPROF, db_get_b(0, SHLExt_Name, SHLExt_ShowNoProfile, BST_UNCHECKED));
+ CheckDlgButton(hwndDlg, IDC_SHOWFULL, db_get_b(0, SHLExt_Name, SHLExt_UseHITContacts, BST_UNCHECKED));
+ CheckDlgButton(hwndDlg, IDC_SHOWINVISIBLES, db_get_b(0, SHLExt_Name, SHLExt_UseHIT2Contacts, BST_UNCHECKED));
+ CheckDlgButton(hwndDlg, IDC_USEOWNERDRAW, db_get_b(0, SHLExt_Name, SHLExt_ShowNoIcons, BST_UNCHECKED));
+ CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, db_get_b(0, SHLExt_Name, SHLExt_ShowNoOffline, BST_UNCHECKED));
+
+ // give the Remove button a Vista icon
+ SendDlgItemMessage(hwndDlg, IDC_REMOVE, BCM_SETSHIELD, 0, 1);
+}
- switch(wMsg) {
+static INT_PTR CALLBACK OptDialogProc(HWND hwndDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (wMsg) {
case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- comReg = IsCOMRegistered();
- mir_sntprintf(szBuf, _countof(szBuf), _T("%s (%s)"),
- TranslateTS(COM_OKSTR[ (comReg & COMREG_OK) != 0 ]),
- TranslateTS(COM_APPROVEDSTR[ (comReg & COMREG_APPROVED) != 0 ]));
- SetDlgItemText(hwndDlg, IDC_STATUS, szBuf);
- // auto size the static windows to fit their text
- // they're rendering in a font not selected into the DC.
- AutoSize(GetDlgItem(hwndDlg, IDC_CAPMENUS));
- AutoSize(GetDlgItem(hwndDlg, IDC_CAPSTATUS));
- AutoSize(GetDlgItem(hwndDlg, IDC_CAPSHLSTATUS));
- // show all the options
- iCheck = db_get_b(0, SHLExt_Name, SHLExt_UseGroups, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_USEGROUPS, iCheck ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CLISTGROUPS), iCheck = BST_CHECKED);
- CheckDlgButton(hwndDlg, IDC_CLISTGROUPS, db_get_b(0, SHLExt_Name, SHLExt_UseCListSetting, BST_UNCHECKED));
- CheckDlgButton(hwndDlg, IDC_NOPROF, db_get_b(0, SHLExt_Name, SHLExt_ShowNoProfile, BST_UNCHECKED));
- CheckDlgButton(hwndDlg, IDC_SHOWFULL, db_get_b(0, SHLExt_Name, SHLExt_UseHITContacts, BST_UNCHECKED));
- CheckDlgButton(hwndDlg, IDC_SHOWINVISIBLES, db_get_b(0, SHLExt_Name, SHLExt_UseHIT2Contacts, BST_UNCHECKED));
- CheckDlgButton(hwndDlg, IDC_USEOWNERDRAW, db_get_b(0, SHLExt_Name, SHLExt_ShowNoIcons, BST_UNCHECKED));
- CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, db_get_b(0, SHLExt_Name, SHLExt_ShowNoOffline, BST_UNCHECKED));
- // give the Remove button a Vista icon
- SendDlgItemMessage(hwndDlg, IDC_REMOVE, BCM_SETSHIELD, 0, 1);
+ TranslateDialogDefault(hwndDlg);
+ InitControls(hwndDlg);
return TRUE;
-
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- db_set_b(0, SHLExt_Name, SHLExt_UseGroups, IsDlgButtonChecked(hwndDlg, IDC_USEGROUPS));
- db_set_b(0, SHLExt_Name, SHLExt_UseCListSetting, IsDlgButtonChecked(hwndDlg, IDC_CLISTGROUPS));
- db_set_b(0, SHLExt_Name, SHLExt_ShowNoProfile, IsDlgButtonChecked(hwndDlg, IDC_NOPROF));
- db_set_b(0, SHLExt_Name, SHLExt_UseHITContacts, IsDlgButtonChecked(hwndDlg, IDC_SHOWFULL));
- db_set_b(0, SHLExt_Name, SHLExt_UseHIT2Contacts, IsDlgButtonChecked(hwndDlg, IDC_SHOWINVISIBLES));
- db_set_b(0, SHLExt_Name, SHLExt_ShowNoIcons, IsDlgButtonChecked(hwndDlg, IDC_USEOWNERDRAW));
- db_set_b(0, SHLExt_Name, SHLExt_ShowNoOffline, IsDlgButtonChecked(hwndDlg, IDC_HIDEOFFLINE));
- }
- break;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ db_set_b(0, SHLExt_Name, SHLExt_UseGroups, IsDlgButtonChecked(hwndDlg, IDC_USEGROUPS));
+ db_set_b(0, SHLExt_Name, SHLExt_UseCListSetting, IsDlgButtonChecked(hwndDlg, IDC_CLISTGROUPS));
+ db_set_b(0, SHLExt_Name, SHLExt_ShowNoProfile, IsDlgButtonChecked(hwndDlg, IDC_NOPROF));
+ db_set_b(0, SHLExt_Name, SHLExt_UseHITContacts, IsDlgButtonChecked(hwndDlg, IDC_SHOWFULL));
+ db_set_b(0, SHLExt_Name, SHLExt_UseHIT2Contacts, IsDlgButtonChecked(hwndDlg, IDC_SHOWINVISIBLES));
+ db_set_b(0, SHLExt_Name, SHLExt_ShowNoIcons, IsDlgButtonChecked(hwndDlg, IDC_USEOWNERDRAW));
+ db_set_b(0, SHLExt_Name, SHLExt_ShowNoOffline, IsDlgButtonChecked(hwndDlg, IDC_HIDEOFFLINE));
+ }
+ break;
case WM_COMMAND:
// don't send the changed message if remove is clicked
- if ( LOWORD(wParam) != IDC_REMOVE)
+ if (LOWORD(wParam) != IDC_REMOVE)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- switch( LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_USEGROUPS:
EnableWindow(GetDlgItem(hwndDlg, IDC_CLISTGROUPS), BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_USEGROUPS));
break;
case IDC_REMOVE:
if (IDYES == MessageBox(0,
- TranslateT("Are you sure? This will remove all the settings stored in your database and all registry entries created for shlext to work with Explorer"),
- TranslateT("Disable/Remove shlext"), MB_YESNO | MB_ICONQUESTION)) {
+ TranslateT("Are you sure? This will remove all the settings stored in your database and all registry entries created for shlext to work with Explorer"),
+ TranslateT("Disable/Remove shlext"), MB_YESNO | MB_ICONQUESTION)) {
db_unset(0, SHLExt_Name, SHLExt_UseGroups);
db_unset(0, SHLExt_Name, SHLExt_UseCListSetting);
db_unset(0, SHLExt_Name, SHLExt_UseHITContacts);
@@ -91,7 +98,7 @@ static INT_PTR CALLBACK OptDialogProc(HWND hwndDlg, UINT wMsg, WPARAM wParam, LP db_unset(0, SHLExt_Name, SHLExt_ShowNoOffline);
CheckUnregisterServer();
- SendMessage(hwndDlg, WM_INITDIALOG, 0, 0);
+ InitControls(hwndDlg);
}
}
break;
|