- made NSIS ignore WM_COMMAND from disabled controls

- made NSISdl set the cancel button as the default button


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3330 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-12-29 15:12:41 +00:00
parent 8a85e1c0dd
commit 466e93ea11
5 changed files with 47 additions and 39 deletions

View file

@ -644,7 +644,11 @@ LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify)
if (pField->nFlags & FLAG_NOTIFY) { if (pField->nFlags & FLAG_NOTIFY) {
// Remember which control was activated then pretend the user clicked Next // Remember which control was activated then pretend the user clicked Next
g_NotifyField = nIdx + 1; g_NotifyField = nIdx + 1;
// the next button must be enabled or nsis will ignore WM_COMMAND
BOOL bWasDisabled = EnableWindow(hNextButton, TRUE);
FORWARD_WM_COMMAND(hMainWindow, IDOK, hNextButton, codeNotify, mySendMessage); FORWARD_WM_COMMAND(hMainWindow, IDOK, hNextButton, codeNotify, mySendMessage);
if (bWasDisabled)
EnableWindow(hNextButton, FALSE);
} }
} }
break; break;

View file

@ -233,8 +233,6 @@ __declspec(dllexport) void download (HWND parent,
if (IsWindowVisible(hwndB)) ShowWindow(hwndB,SW_HIDE); if (IsWindowVisible(hwndB)) ShowWindow(hwndB,SW_HIDE);
else hwndB=NULL; else hwndB=NULL;
wasen=EnableWindow(GetDlgItem(parent,IDCANCEL),1);
lpWndProcOld = (void *)SetWindowLong(parent,GWL_WNDPROC,(long)ParentWndProc); lpWndProcOld = (void *)SetWindowLong(parent,GWL_WNDPROC,(long)ParentWndProc);
dlg = CreateDialog((HINSTANCE)hModule, dlg = CreateDialog((HINSTANCE)hModule,
@ -307,6 +305,13 @@ __declspec(dllexport) void download (HWND parent,
SendDlgItemMessage(dlg, pbid, WM_SETFONT, hFont, 0); SendDlgItemMessage(dlg, pbid, WM_SETFONT, hFont, 0);
SendDlgItemMessage(dlg, IDC_STATIC2, WM_SETFONT, hFont, 0); SendDlgItemMessage(dlg, IDC_STATIC2, WM_SETFONT, hFont, 0);
} }
// enable the cancel button
wasen=EnableWindow(GetDlgItem(parent,IDCANCEL),TRUE);
SendMessage(parent, DM_SETDEFID, IDCANCEL, 0);
// remove the BS_DEFPUSHBUTTON style from IDOK
SendMessage(GetDlgItem(parent, IDOK), BM_SETSTYLE, BS_PUSHBUTTON, TRUE);
SetFocus(GetDlgItem(parent,IDCANCEL));
} }
{ {
WSADATA wsaData; WSADATA wsaData;
@ -385,7 +390,7 @@ __declspec(dllexport) void download (HWND parent,
SetWindowPos(childwnd,0,0,0,orig_childRc.right-orig_childRc.left,orig_childRc.bottom-orig_childRc.top,SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE); SetWindowPos(childwnd,0,0,0,orig_childRc.right-orig_childRc.left,orig_childRc.bottom-orig_childRc.top,SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE);
if (wasen) EnableWindow(GetDlgItem(parent,IDCANCEL),0); if (wasen) EnableWindow(GetDlgItem(parent,IDCANCEL),FALSE);
} }
if ( !error ) if ( !error )
error = "cancel"; error = "cancel";

Binary file not shown.

Binary file not shown.

View file

@ -96,12 +96,9 @@ static BOOL NSISCALL SetDlgItemTextFromLang_(HWND dlg, int id, int lid) {
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT #ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
#define HandleStaticBkColor() _HandleStaticBkColor(uMsg, wParam, lParam) #define HandleStaticBkColor() _HandleStaticBkColor(uMsg, wParam, lParam)
static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lParam) { static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lParam)
switch (uMsg) { {
case WM_CTLCOLORSTATIC: if ((uMsg - WM_CTLCOLOREDIT) <= (WM_CTLCOLORSTATIC - WM_CTLCOLOREDIT))
case WM_CTLCOLOREDIT:
case WM_CTLCOLORDLG:
case WM_CTLCOLORBTN:
{ {
ctlcolors *c = (ctlcolors *)GetWindowLong((HWND)lParam, GWL_USERDATA); ctlcolors *c = (ctlcolors *)GetWindowLong((HWND)lParam, GWL_USERDATA);
@ -134,7 +131,6 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara
return (BOOL)c->bkb; return (BOOL)c->bkb;
} }
} }
}
return 0; return 0;
} }
#else #else
@ -553,7 +549,7 @@ skipPage:
} }
if (uMsg == WM_CLOSE && m_page == g_blocks[NB_PAGES].num - 1) if (uMsg == WM_CLOSE && m_page == g_blocks[NB_PAGES].num - 1)
{ {
if (!IsWindowEnabled(m_hwndCancel) && IsWindowEnabled(m_hwndOK)) if (!IsWindowEnabled(m_hwndCancel))
{ {
uMsg = WM_COMMAND; uMsg = WM_COMMAND;
wParam = IDOK; wParam = IDOK;
@ -562,6 +558,9 @@ skipPage:
if (uMsg == WM_COMMAND) if (uMsg == WM_COMMAND)
{ {
int id = LOWORD(wParam); int id = LOWORD(wParam);
HWND hCtl = GetDlgItem(hwndDlg, id);
if (hCtl && !IsWindowEnabled(hCtl))
return 0;
if (id == IDOK) if (id == IDOK)
{ {
@ -596,7 +595,7 @@ skipPage:
{ {
// Forward WM_COMMANDs to inner dialogs, can be custom ones. // Forward WM_COMMANDs to inner dialogs, can be custom ones.
// Without this, enter on buttons in inner dialogs won't work. // Without this, enter on buttons in inner dialogs won't work.
SendMessage(m_curwnd, uMsg, wParam, lParam); SendMessage(m_curwnd, WM_COMMAND, wParam, lParam);
} }
} }
return HandleStaticBkColor(); return HandleStaticBkColor();
@ -700,8 +699,8 @@ static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
{ {
if (msgfilter->msg==WM_KEYDOWN) if (msgfilter->msg==WM_KEYDOWN)
{ {
if (msgfilter->wParam==VK_RETURN && IsWindowEnabled(m_hwndOK)) { if (msgfilter->wParam==VK_RETURN) {
outernotify(1); SendMessage(g_hwnd, WM_COMMAND, IDOK, 0);
} }
if (msgfilter->wParam==VK_ESCAPE) { if (msgfilter->wParam==VK_ESCAPE) {
SendMessage(g_hwnd, WM_CLOSE, 0, 0); SendMessage(g_hwnd, WM_CLOSE, 0, 0);