LINK, dirreq, filereq and browse button in dirpage can be opened using ENTER KEY (WM_COMMAND events forward to inner dialogs), fixed problem with focus on Close/Finish button which was generating wierd beeps if user attempted to finish the installer with ENTER key.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2707 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
ramon18 2003-07-10 00:28:05 +00:00
parent 9396324581
commit 8bf75b3634
5 changed files with 88 additions and 76 deletions

View file

@ -175,6 +175,13 @@ int nRectId = 0;
int nNumFields = 0; int nNumFields = 0;
int g_done; int g_done;
int FindControlIdx(UINT id)
{
for (int nIdx = 0; nIdx < nNumFields; nIdx++)
if (id == pFields[nIdx].nControlID)
return nIdx;
return -1;
}
// array of HWNDs and window styles used to make the main NSIS controls invisible while this program runs. // array of HWNDs and window styles used to make the main NSIS controls invisible while this program runs.
@ -675,23 +682,20 @@ LRESULT WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
switch (codeNotify) { switch (codeNotify) {
case BN_CLICKED: case BN_CLICKED:
{ {
for (int nIdx = 0; nIdx < nNumFields; nIdx++) { int nIdx = FindControlIdx(id);
if (id == pFields[nIdx].nControlID) { if (pFields[nIdx].nType == FIELD_BROWSEBUTTON) {
if (pFields[nIdx].nType == FIELD_BROWSEBUTTON) { int nParentIdx = pFields[nIdx].nParentIdx;
int nParentIdx = pFields[nIdx].nParentIdx; switch(pFields[nParentIdx].nType) {
switch(pFields[nParentIdx].nType) { case FIELD_FILEREQUEST:
case FIELD_FILEREQUEST: BrowseForFile(nParentIdx);
BrowseForFile(nParentIdx); break;
break; case FIELD_DIRREQUEST:
case FIELD_DIRREQUEST: BrowseForFolder(nParentIdx);
BrowseForFolder(nParentIdx); break;
break;
}
break;
} else if (pFields[nIdx].nType == FIELD_LINK) {
ShellExecute(hMainWindow, NULL, pFields[nIdx].pszState, NULL, NULL, SW_SHOWDEFAULT);
}
} }
break;
} else if (pFields[nIdx].nType == FIELD_LINK) {
ShellExecute(hMainWindow, NULL, pFields[nIdx].pszState, NULL, NULL, SW_SHOWDEFAULT);
} }
} }
break; break;
@ -737,53 +741,48 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg,
case WM_DRAWITEM: case WM_DRAWITEM:
{ {
DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam; DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
for (int nIdx = 0; nIdx < nNumFields; nIdx++) int nIdx = FindControlIdx(lpdis->CtlID);
{
if (pFields[nIdx].nControlID == lpdis->CtlID )
{
#ifdef IO_LINK_UNDERLINED #ifdef IO_LINK_UNDERLINED
HFONT OldFont; HFONT OldFont;
LOGFONT lf; LOGFONT lf;
#endif #endif
if ( ( lpdis->itemState & ODS_FOCUS && lpdis->itemAction & ODA_DRAWENTIRE) || (lpdis->itemAction & ODA_FOCUS) || if ( ( lpdis->itemState & ODS_FOCUS && lpdis->itemAction & ODA_DRAWENTIRE) || (lpdis->itemAction & ODA_FOCUS) ||
(lpdis->itemAction & ODA_SELECT)) (lpdis->itemAction & ODA_SELECT))
DrawFocusRect(lpdis->hDC, &pFields[nIdx].rect); DrawFocusRect(lpdis->hDC, &pFields[nIdx].rect);
#ifdef IO_LINK_UNDERLINED #ifdef IO_LINK_UNDERLINED
GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf); GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf);
lf.lfUnderline = TRUE; lf.lfUnderline = TRUE;
OldFont = (HFONT)SelectObject(lpdis->hDC, CreateFontIndirect(&lf)); OldFont = (HFONT)SelectObject(lpdis->hDC, CreateFontIndirect(&lf));
#endif #endif
// Set up tranparent background // Set up tranparent background
SetBkMode(lpdis->hDC, TRANSPARENT); SetBkMode(lpdis->hDC, TRANSPARENT);
if ( GetSysColorBrush(COLOR_HOTLIGHT) ) if ( GetSysColorBrush(COLOR_HOTLIGHT) )
SetTextColor(lpdis->hDC, GetSysColor(COLOR_HOTLIGHT)); SetTextColor(lpdis->hDC, GetSysColor(COLOR_HOTLIGHT));
else else
SetTextColor(lpdis->hDC, RGB(0,0,255)); // Win95/NT4 arrggg!!! SetTextColor(lpdis->hDC, RGB(0,0,255)); // Win95/NT4 arrggg!!!
GetClientRect(lpdis->hwndItem, &pFields[nIdx].rect); pFields[nIdx].rect = lpdis->rcItem;
// Calculate needed size of the control // Calculate needed size of the control
DrawText(lpdis->hDC, pFields[nIdx].pszText, -1, &pFields[nIdx].rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); DrawText(lpdis->hDC, pFields[nIdx].pszText, -1, &pFields[nIdx].rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT);
pFields[nIdx].rect.right += 4; pFields[nIdx].rect.right += 4;
pFields[nIdx].rect.bottom = lpdis->rcItem.bottom; pFields[nIdx].rect.bottom = lpdis->rcItem.bottom;
// Resize but don't move // Resize but don't move
SetWindowPos(lpdis->hwndItem, NULL, 0, 0, pFields[nIdx].rect.right - pFields[nIdx].rect.left, SetWindowPos(lpdis->hwndItem, NULL, 0, 0, pFields[nIdx].rect.right - pFields[nIdx].rect.left,
pFields[nIdx].rect.bottom - pFields[nIdx].rect.top, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); pFields[nIdx].rect.bottom - pFields[nIdx].rect.top, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
// Draw the text // Draw the text
lpdis->rcItem = pFields[nIdx].rect; lpdis->rcItem = pFields[nIdx].rect;
// Add little margin to avoid focus rect over text // Add little margin to avoid focus rect over text
lpdis->rcItem.right += 2; lpdis->rcItem.left += 2; lpdis->rcItem.right += 2; lpdis->rcItem.left += 2;
if ( lpdis->itemState & ODS_HOTLIGHT ) if ( lpdis->itemState & ODS_HOTLIGHT )
OutputDebugString("Hot"); OutputDebugString("Hot");
DrawText(lpdis->hDC, pFields[nIdx].pszText, -1, &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE ); DrawText(lpdis->hDC, pFields[nIdx].pszText, -1, &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE );
#ifdef IO_LINK_UNDERLINED #ifdef IO_LINK_UNDERLINED
DeleteObject(SelectObject(lpdis->hDC, OldFont)); DeleteObject(SelectObject(lpdis->hDC, OldFont));
#endif #endif
}
}
break; break;
} }
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
@ -807,31 +806,35 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg,
// pFields[nIdx].nParentIdx is used to store original windowproc // pFields[nIdx].nParentIdx is used to store original windowproc
int WINAPI StaticLINKWindowProc(HWND hWin, UINT uMsg, LPARAM wParam, WPARAM lParam) int WINAPI StaticLINKWindowProc(HWND hWin, UINT uMsg, LPARAM wParam, WPARAM lParam)
{ {
for (int StaticField = 0; StaticField < nNumFields; StaticField++) int StaticField = FindControlIdx(GetDlgCtrlID(hWin));
switch(uMsg)
{ {
if (pFields[StaticField].nType == FIELD_LINK && hWin == pFields[StaticField].hwnd ) case WM_ERASEBKGND:
return 0;
case WM_GETDLGCODE:
return DLGC_BUTTON|DLGC_WANTALLKEYS;
case WM_KEYDOWN:
{ {
switch(uMsg) if ( wParam == VK_RETURN )
WMCommandProc(hMainWindow, pFields[StaticField].nControlID, pFields[StaticField].hwnd, BN_CLICKED);
else if ( wParam == VK_TAB )
SendMessage(hMainWindow, WM_NEXTDLGCTL, GetKeyState(VK_SHIFT) & 0x8000, FALSE);
}
break;
case WM_SETCURSOR:
{
if ( (HWND)wParam == hWin && LOWORD(lParam) == HTCLIENT )
{ {
case WM_ERASEBKGND: HCURSOR hCur = LoadCursor(NULL, IDC_HAND);
return 0; if ( hCur )
case WM_SETCURSOR:
{ {
if ( (HWND)wParam == hWin && LOWORD(lParam) == HTCLIENT ) SetCursor(hCur);
{ return 1; // halt further processing
HCURSOR hCur = LoadCursor(NULL, IDC_HAND);
if ( hCur )
{
SetCursor(hCur);
return 1; // halt further processing
}
}
} }
} }
return CallWindowProc((WNDPROC)pFields[StaticField].nParentIdx, hWin, uMsg, wParam, lParam);
} }
} }
return 0; return CallWindowProc((WNDPROC)pFields[StaticField].nParentIdx, hWin, uMsg, wParam, lParam);
} }
#endif #endif
@ -1190,7 +1193,8 @@ void showCfgDlg()
{ {
lpWndProcOld = (void *) SetWindowLong(hMainWindow,DWL_DLGPROC,(long)ParentWndProc); lpWndProcOld = (void *) SetWindowLong(hMainWindow,DWL_DLGPROC,(long)ParentWndProc);
SendMessage(hMainWindow, WM_NOTIFY_CUSTOM_READY, 0, 0); // Tell NSIS to remove old inner dialog and pass handle of the new inner dialog
SendMessage(hMainWindow, WM_NOTIFY_CUSTOM_READY, (WPARAM)hConfigWindow, 0);
ShowWindow(hConfigWindow, SW_SHOWNA); ShowWindow(hConfigWindow, SW_SHOWNA);
SetFocus(hNextButton); SetFocus(hNextButton);

View file

@ -253,7 +253,8 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
AddFolderFromReg(HKEY_LOCAL_MACHINE); AddFolderFromReg(HKEY_LOCAL_MACHINE);
AddFolderFromReg(HKEY_CURRENT_USER); AddFolderFromReg(HKEY_CURRENT_USER);
SendMessage(hwParent, WM_NOTIFY_CUSTOM_READY, 0, 0); // Tell NSIS to remove old inner dialog and pass handle of the new inner dialog
SendMessage(hwParent, WM_NOTIFY_CUSTOM_READY, (WPARAM)hwndDlg, 0);
ShowWindow(hwndDlg, SW_SHOWNA); ShowWindow(hwndDlg, SW_SHOWNA);
SetFocus(GetDlgItem(hwParent, IDOK)); SetFocus(GetDlgItem(hwParent, IDOK));
} }

Binary file not shown.

Binary file not shown.

View file

@ -453,6 +453,7 @@ nextPage:
else { else {
if (g_flags.abort) SetFocus(m_hwndCancel); if (g_flags.abort) SetFocus(m_hwndCancel);
else if (g_flags.autoclose) goto nextPage; else if (g_flags.autoclose) goto nextPage;
else SetFocus(m_hwndOK); // without focus button, the system Beeps every time user press one key
return 0; return 0;
} }
@ -499,6 +500,7 @@ nextPage:
if (uMsg == WM_NOTIFY_CUSTOM_READY) { if (uMsg == WM_NOTIFY_CUSTOM_READY) {
DestroyWindow(m_curwnd); DestroyWindow(m_curwnd);
m_curwnd = (HWND)wParam;
} }
if (uMsg == WM_CLOSE) if (uMsg == WM_CLOSE)
{ {
@ -541,6 +543,11 @@ nextPage:
} }
} }
} }
else
{
// Forward WM_COMMANDs to inner dialogs, can be custom ones
SendMessage(m_curwnd, uMsg, wParam, lParam);
}
} }
return HandleStaticBkColor(); return HandleStaticBkColor();
} }