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:
parent
9396324581
commit
8bf75b3634
5 changed files with 88 additions and 76 deletions
|
@ -175,6 +175,13 @@ int nRectId = 0;
|
|||
int nNumFields = 0;
|
||||
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.
|
||||
|
||||
|
@ -675,23 +682,20 @@ LRESULT WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
|
|||
switch (codeNotify) {
|
||||
case BN_CLICKED:
|
||||
{
|
||||
for (int nIdx = 0; nIdx < nNumFields; nIdx++) {
|
||||
if (id == pFields[nIdx].nControlID) {
|
||||
if (pFields[nIdx].nType == FIELD_BROWSEBUTTON) {
|
||||
int nParentIdx = pFields[nIdx].nParentIdx;
|
||||
switch(pFields[nParentIdx].nType) {
|
||||
case FIELD_FILEREQUEST:
|
||||
BrowseForFile(nParentIdx);
|
||||
break;
|
||||
case FIELD_DIRREQUEST:
|
||||
BrowseForFolder(nParentIdx);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} else if (pFields[nIdx].nType == FIELD_LINK) {
|
||||
ShellExecute(hMainWindow, NULL, pFields[nIdx].pszState, NULL, NULL, SW_SHOWDEFAULT);
|
||||
}
|
||||
int nIdx = FindControlIdx(id);
|
||||
if (pFields[nIdx].nType == FIELD_BROWSEBUTTON) {
|
||||
int nParentIdx = pFields[nIdx].nParentIdx;
|
||||
switch(pFields[nParentIdx].nType) {
|
||||
case FIELD_FILEREQUEST:
|
||||
BrowseForFile(nParentIdx);
|
||||
break;
|
||||
case FIELD_DIRREQUEST:
|
||||
BrowseForFolder(nParentIdx);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} else if (pFields[nIdx].nType == FIELD_LINK) {
|
||||
ShellExecute(hMainWindow, NULL, pFields[nIdx].pszState, NULL, NULL, SW_SHOWDEFAULT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -737,53 +741,48 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg,
|
|||
case WM_DRAWITEM:
|
||||
{
|
||||
DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
|
||||
for (int nIdx = 0; nIdx < nNumFields; nIdx++)
|
||||
{
|
||||
if (pFields[nIdx].nControlID == lpdis->CtlID )
|
||||
{
|
||||
int nIdx = FindControlIdx(lpdis->CtlID);
|
||||
#ifdef IO_LINK_UNDERLINED
|
||||
HFONT OldFont;
|
||||
LOGFONT lf;
|
||||
HFONT OldFont;
|
||||
LOGFONT lf;
|
||||
#endif
|
||||
if ( ( lpdis->itemState & ODS_FOCUS && lpdis->itemAction & ODA_DRAWENTIRE) || (lpdis->itemAction & ODA_FOCUS) ||
|
||||
(lpdis->itemAction & ODA_SELECT))
|
||||
DrawFocusRect(lpdis->hDC, &pFields[nIdx].rect);
|
||||
|
||||
if ( ( lpdis->itemState & ODS_FOCUS && lpdis->itemAction & ODA_DRAWENTIRE) || (lpdis->itemAction & ODA_FOCUS) ||
|
||||
(lpdis->itemAction & ODA_SELECT))
|
||||
DrawFocusRect(lpdis->hDC, &pFields[nIdx].rect);
|
||||
|
||||
#ifdef IO_LINK_UNDERLINED
|
||||
GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf);
|
||||
lf.lfUnderline = TRUE;
|
||||
OldFont = (HFONT)SelectObject(lpdis->hDC, CreateFontIndirect(&lf));
|
||||
GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf);
|
||||
lf.lfUnderline = TRUE;
|
||||
OldFont = (HFONT)SelectObject(lpdis->hDC, CreateFontIndirect(&lf));
|
||||
#endif
|
||||
// Set up tranparent background
|
||||
SetBkMode(lpdis->hDC, TRANSPARENT);
|
||||
|
||||
if ( GetSysColorBrush(COLOR_HOTLIGHT) )
|
||||
SetTextColor(lpdis->hDC, GetSysColor(COLOR_HOTLIGHT));
|
||||
else
|
||||
SetTextColor(lpdis->hDC, RGB(0,0,255)); // Win95/NT4 arrggg!!!
|
||||
|
||||
GetClientRect(lpdis->hwndItem, &pFields[nIdx].rect);
|
||||
// Calculate needed size of the control
|
||||
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.bottom = lpdis->rcItem.bottom;
|
||||
// Resize but don't move
|
||||
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);
|
||||
// Draw the text
|
||||
lpdis->rcItem = pFields[nIdx].rect;
|
||||
// Add little margin to avoid focus rect over text
|
||||
lpdis->rcItem.right += 2; lpdis->rcItem.left += 2;
|
||||
|
||||
if ( lpdis->itemState & ODS_HOTLIGHT )
|
||||
OutputDebugString("Hot");
|
||||
|
||||
DrawText(lpdis->hDC, pFields[nIdx].pszText, -1, &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE );
|
||||
// Set up tranparent background
|
||||
SetBkMode(lpdis->hDC, TRANSPARENT);
|
||||
|
||||
if ( GetSysColorBrush(COLOR_HOTLIGHT) )
|
||||
SetTextColor(lpdis->hDC, GetSysColor(COLOR_HOTLIGHT));
|
||||
else
|
||||
SetTextColor(lpdis->hDC, RGB(0,0,255)); // Win95/NT4 arrggg!!!
|
||||
|
||||
pFields[nIdx].rect = lpdis->rcItem;
|
||||
// Calculate needed size of the control
|
||||
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.bottom = lpdis->rcItem.bottom;
|
||||
// Resize but don't move
|
||||
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);
|
||||
// Draw the text
|
||||
lpdis->rcItem = pFields[nIdx].rect;
|
||||
// Add little margin to avoid focus rect over text
|
||||
lpdis->rcItem.right += 2; lpdis->rcItem.left += 2;
|
||||
|
||||
if ( lpdis->itemState & ODS_HOTLIGHT )
|
||||
OutputDebugString("Hot");
|
||||
|
||||
DrawText(lpdis->hDC, pFields[nIdx].pszText, -1, &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE );
|
||||
#ifdef IO_LINK_UNDERLINED
|
||||
DeleteObject(SelectObject(lpdis->hDC, OldFont));
|
||||
DeleteObject(SelectObject(lpdis->hDC, OldFont));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_CTLCOLORSTATIC:
|
||||
|
@ -807,31 +806,35 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg,
|
|||
// pFields[nIdx].nParentIdx is used to store original windowproc
|
||||
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:
|
||||
return 0;
|
||||
case WM_SETCURSOR:
|
||||
HCURSOR hCur = LoadCursor(NULL, IDC_HAND);
|
||||
if ( hCur )
|
||||
{
|
||||
if ( (HWND)wParam == hWin && LOWORD(lParam) == HTCLIENT )
|
||||
{
|
||||
HCURSOR hCur = LoadCursor(NULL, IDC_HAND);
|
||||
if ( hCur )
|
||||
{
|
||||
SetCursor(hCur);
|
||||
return 1; // halt further processing
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
|
@ -1190,7 +1193,8 @@ void showCfgDlg()
|
|||
{
|
||||
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);
|
||||
SetFocus(hNextButton);
|
||||
|
||||
|
|
|
@ -253,7 +253,8 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
AddFolderFromReg(HKEY_LOCAL_MACHINE);
|
||||
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);
|
||||
SetFocus(GetDlgItem(hwParent, IDOK));
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -453,6 +453,7 @@ nextPage:
|
|||
else {
|
||||
if (g_flags.abort) SetFocus(m_hwndCancel);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -499,6 +500,7 @@ nextPage:
|
|||
|
||||
if (uMsg == WM_NOTIFY_CUSTOM_READY) {
|
||||
DestroyWindow(m_curwnd);
|
||||
m_curwnd = (HWND)wParam;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue