Windows: Solve issue of some dialogs not showing up and that was caused by wrong handling of WM_NOTIFY messages. This behavior appeared after switching to Windows visual styles.

This commit is contained in:
Mounir IDRASSI 2014-12-22 00:29:35 +01:00
parent 9267450346
commit e1157ea935
2 changed files with 125 additions and 123 deletions

View File

@ -3256,7 +3256,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
return 1; return 1;
} }
if (lw == IDCANCEL) if ((msg == WM_COMMAND) && (lw == IDCANCEL))
{ {
NormalCursor (); NormalCursor ();
EndDialog (hwndDlg, IDCANCEL); EndDialog (hwndDlg, IDCANCEL);
@ -4750,7 +4750,6 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break; break;
case WM_COMMAND: case WM_COMMAND:
case WM_NOTIFY:
switch (lw) switch (lw)
{ {
@ -9581,6 +9580,8 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
return 1; return 1;
} }
if (msg == WM_COMMAND)
{
switch (lw) switch (lw)
{ {
case IDCANCEL: case IDCANCEL:
@ -9715,7 +9716,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
return 1; return 1;
} }
} }
}
return 0; return 0;
} }
return 0; return 0;

View File

@ -271,24 +271,18 @@ static void DisplayHotkeyList (HWND hwndDlg)
BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
HWND hList = GetDlgItem (hwndDlg, IDC_HOTKEY_LIST);
HWND hwndMainDlg = hwndDlg;
WORD lw = LOWORD (wParam); WORD lw = LOWORD (wParam);
WORD hw = HIWORD (wParam); WORD hw = HIWORD (wParam);
static BOOL bKeyScanOn; static BOOL bKeyScanOn;
static BOOL bTPlaySoundOnSuccessfulHkDismount; static BOOL bTPlaySoundOnSuccessfulHkDismount;
static BOOL bTDisplayBalloonOnSuccessfulHkDismount; static BOOL bTDisplayBalloonOnSuccessfulHkDismount;
while (GetParent (hwndMainDlg) != NULL)
{
hwndMainDlg = GetParent (hwndMainDlg);
}
switch (msg) switch (msg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
LVCOLUMNW col; LVCOLUMNW col;
HWND hList = GetDlgItem (hwndDlg, IDC_HOTKEY_LIST);
bKeyScanOn = FALSE; bKeyScanOn = FALSE;
nSelectedHotkeyId = -1; nSelectedHotkeyId = -1;
@ -354,16 +348,8 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
return 1; return 1;
} }
case WM_COMMAND:
case WM_NOTIFY: case WM_NOTIFY:
if (wParam == IDC_HOTKEY_LIST)
if (lw == IDC_HOTKEY_KEY && hw == EN_CHANGE)
{
if (!bKeyScanOn && nSelectedHotkeyId < 0 && GetWindowTextLengthW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY)))
SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), L"");
}
if (msg == WM_NOTIFY && wParam == IDC_HOTKEY_LIST)
{ {
if (((LPNMHDR) lParam)->code == LVN_ITEMACTIVATE if (((LPNMHDR) lParam)->code == LVN_ITEMACTIVATE
|| ((LPNMHDR) lParam)->code == LVN_ITEMCHANGED && (((LPNMLISTVIEW) lParam)->uNewState & LVIS_FOCUSED)) || ((LPNMHDR) lParam)->code == LVN_ITEMCHANGED && (((LPNMLISTVIEW) lParam)->uNewState & LVIS_FOCUSED))
@ -381,6 +367,15 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
} }
} }
return 0;
case WM_COMMAND:
if (lw == IDC_HOTKEY_KEY && hw == EN_CHANGE)
{
if (!bKeyScanOn && nSelectedHotkeyId < 0 && GetWindowTextLengthW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY)))
SetWindowTextW (GetDlgItem (hwndDlg, IDC_HOTKEY_KEY), L"");
}
if (lw == IDC_HOTKEY_ASSIGN) if (lw == IDC_HOTKEY_ASSIGN)
{ {
BOOL bOwnActiveShortcut = FALSE; BOOL bOwnActiveShortcut = FALSE;
@ -502,6 +497,12 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
if (lw == IDOK) if (lw == IDOK)
{ {
HWND hwndMainDlg = hwndDlg;
while (GetParent (hwndMainDlg) != NULL)
{
hwndMainDlg = GetParent (hwndMainDlg);
}
UnregisterAllHotkeys (hwndMainDlg, Hotkeys); UnregisterAllHotkeys (hwndMainDlg, Hotkeys);
memcpy (Hotkeys, tmpHotkeys, sizeof(Hotkeys)); memcpy (Hotkeys, tmpHotkeys, sizeof(Hotkeys));
RegisterAllHotkeys (hwndMainDlg, Hotkeys); RegisterAllHotkeys (hwndMainDlg, Hotkeys);