fixed bug #1606716 - InstallOptions might send irrelevant NOTIFY for radiobuttons
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4854 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b4a00a8ede
commit
88572123e5
1 changed files with 106 additions and 91 deletions
|
@ -581,112 +581,127 @@ int WINAPI ReadSettings(void) {
|
||||||
return nNumFields;
|
return nNumFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
|
LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
|
||||||
switch (codeNotify) {
|
int nIdx = FindControlIdx(id);
|
||||||
case BN_CLICKED: // The user pressed a button
|
// Ignore if the dialog is in the process of being created
|
||||||
case LBN_SELCHANGE: // The user changed the selection in a ListBox control
|
if (g_done || nIdx < 0)
|
||||||
// case CBN_SELCHANGE: // The user changed the selection in a DropList control (same value as LBN_SELCHANGE)
|
return 0;
|
||||||
{
|
|
||||||
char szBrowsePath[MAX_PATH];
|
FieldType *pField = pFields + nIdx;
|
||||||
int nIdx = FindControlIdx(id);
|
|
||||||
// Ignore if the dialog is in the process of being created
|
switch (pField->nType)
|
||||||
if (g_done || nIdx < 0)
|
{
|
||||||
|
case FIELD_BROWSEBUTTON:
|
||||||
|
case FIELD_LINK:
|
||||||
|
case FIELD_BUTTON:
|
||||||
|
case FIELD_CHECKBOX:
|
||||||
|
case FIELD_RADIOBUTTON:
|
||||||
|
if (codeNotify != BN_CLICKED)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case FIELD_COMBOBOX:
|
||||||
|
case FIELD_LISTBOX:
|
||||||
|
if (codeNotify != LBN_SELCHANGE) // LBN_SELCHANGE == CBN_SELCHANGE
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pFields[nIdx].nType == FIELD_BROWSEBUTTON)
|
||||||
|
--nIdx;
|
||||||
|
|
||||||
|
char szBrowsePath[MAX_PATH];
|
||||||
|
|
||||||
|
switch (pField->nType) {
|
||||||
|
case FIELD_FILEREQUEST: {
|
||||||
|
OPENFILENAME ofn={0,};
|
||||||
|
|
||||||
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
ofn.hwndOwner = hConfigWindow;
|
||||||
|
ofn.lpstrFilter = pField->pszFilter;
|
||||||
|
ofn.lpstrFile = szBrowsePath;
|
||||||
|
ofn.nMaxFile = sizeof(szBrowsePath);
|
||||||
|
ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER);
|
||||||
|
|
||||||
|
GetWindowText(pField->hwnd, szBrowsePath, sizeof(szBrowsePath));
|
||||||
|
|
||||||
|
tryagain:
|
||||||
|
GetCurrentDirectory(BUFFER_SIZE, szResult); // save working dir
|
||||||
|
if ((pField->nFlags & FLAG_SAVEAS) ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn)) {
|
||||||
|
mySetWindowText(pField->hwnd, szBrowsePath);
|
||||||
|
SetCurrentDirectory(szResult); // restore working dir
|
||||||
|
// OFN_NOCHANGEDIR doesn't always work (see MSDN)
|
||||||
break;
|
break;
|
||||||
if (pFields[nIdx].nType == FIELD_BROWSEBUTTON)
|
}
|
||||||
--nIdx;
|
else if (szBrowsePath[0] && CommDlgExtendedError() == FNERR_INVALIDFILENAME) {
|
||||||
FieldType *pField = pFields + nIdx;
|
szBrowsePath[0] = '\0';
|
||||||
switch (pField->nType) {
|
goto tryagain;
|
||||||
case FIELD_FILEREQUEST: {
|
}
|
||||||
OPENFILENAME ofn={0,};
|
|
||||||
|
|
||||||
ofn.lStructSize = sizeof(ofn);
|
break;
|
||||||
ofn.hwndOwner = hConfigWindow;
|
}
|
||||||
ofn.lpstrFilter = pField->pszFilter;
|
|
||||||
ofn.lpstrFile = szBrowsePath;
|
|
||||||
ofn.nMaxFile = sizeof(szBrowsePath);
|
|
||||||
ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER);
|
|
||||||
|
|
||||||
GetWindowText(pField->hwnd, szBrowsePath, sizeof(szBrowsePath));
|
case FIELD_DIRREQUEST: {
|
||||||
|
BROWSEINFO bi;
|
||||||
|
|
||||||
tryagain:
|
bi.hwndOwner = hConfigWindow;
|
||||||
GetCurrentDirectory(BUFFER_SIZE, szResult); // save working dir
|
bi.pidlRoot = NULL;
|
||||||
if ((pField->nFlags & FLAG_SAVEAS) ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn)) {
|
bi.pszDisplayName = szBrowsePath;
|
||||||
mySetWindowText(pField->hwnd, szBrowsePath);
|
bi.lpszTitle = pField->pszText;
|
||||||
SetCurrentDirectory(szResult); // restore working dir
|
|
||||||
// OFN_NOCHANGEDIR doesn't always work (see MSDN)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (szBrowsePath[0] && CommDlgExtendedError() == FNERR_INVALIDFILENAME) {
|
|
||||||
szBrowsePath[0] = '\0';
|
|
||||||
goto tryagain;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case FIELD_DIRREQUEST: {
|
|
||||||
BROWSEINFO bi;
|
|
||||||
|
|
||||||
bi.hwndOwner = hConfigWindow;
|
|
||||||
bi.pidlRoot = NULL;
|
|
||||||
bi.pszDisplayName = szBrowsePath;
|
|
||||||
bi.lpszTitle = pField->pszText;
|
|
||||||
#ifndef BIF_NEWDIALOGSTYLE
|
#ifndef BIF_NEWDIALOGSTYLE
|
||||||
#define BIF_NEWDIALOGSTYLE 0x0040
|
#define BIF_NEWDIALOGSTYLE 0x0040
|
||||||
#endif
|
#endif
|
||||||
bi.ulFlags = BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
bi.ulFlags = BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
||||||
bi.lpfn = BrowseCallbackProc;
|
bi.lpfn = BrowseCallbackProc;
|
||||||
bi.lParam = nIdx;
|
bi.lParam = nIdx;
|
||||||
bi.iImage = 0;
|
bi.iImage = 0;
|
||||||
|
|
||||||
if (pField->pszRoot) {
|
if (pField->pszRoot) {
|
||||||
LPSHELLFOLDER sf;
|
LPSHELLFOLDER sf;
|
||||||
ULONG eaten;
|
ULONG eaten;
|
||||||
LPITEMIDLIST root;
|
LPITEMIDLIST root;
|
||||||
int ccRoot = (lstrlen(pField->pszRoot) * 2) + 2;
|
int ccRoot = (lstrlen(pField->pszRoot) * 2) + 2;
|
||||||
LPWSTR pwszRoot = (LPWSTR) MALLOC(ccRoot);
|
LPWSTR pwszRoot = (LPWSTR) MALLOC(ccRoot);
|
||||||
MultiByteToWideChar(CP_ACP, 0, pField->pszRoot, -1, pwszRoot, ccRoot);
|
MultiByteToWideChar(CP_ACP, 0, pField->pszRoot, -1, pwszRoot, ccRoot);
|
||||||
SHGetDesktopFolder(&sf);
|
SHGetDesktopFolder(&sf);
|
||||||
sf->ParseDisplayName(hConfigWindow, NULL, pwszRoot, &eaten, &root, NULL);
|
sf->ParseDisplayName(hConfigWindow, NULL, pwszRoot, &eaten, &root, NULL);
|
||||||
bi.pidlRoot = root;
|
bi.pidlRoot = root;
|
||||||
sf->Release();
|
sf->Release();
|
||||||
FREE(pwszRoot);
|
FREE(pwszRoot);
|
||||||
}
|
}
|
||||||
// CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
//CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
LPITEMIDLIST pResult = SHBrowseForFolder(&bi);
|
LPITEMIDLIST pResult = SHBrowseForFolder(&bi);
|
||||||
if (!pResult)
|
if (!pResult)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (SHGetPathFromIDList(pResult, szBrowsePath)) {
|
if (SHGetPathFromIDList(pResult, szBrowsePath)) {
|
||||||
mySetWindowText(pField->hwnd, szBrowsePath);
|
mySetWindowText(pField->hwnd, szBrowsePath);
|
||||||
}
|
|
||||||
|
|
||||||
LPMALLOC pMalloc;
|
|
||||||
if (!SHGetMalloc(&pMalloc)) {
|
|
||||||
pMalloc->Free(pResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case FIELD_LINK:
|
|
||||||
case FIELD_BUTTON:
|
|
||||||
// Allow the state to be empty - this might be useful in conjunction
|
|
||||||
// with the NOTIFY flag
|
|
||||||
if (*pField->pszState)
|
|
||||||
ShellExecute(hMainWindow, NULL, pField->pszState, NULL, NULL, SW_SHOWDEFAULT);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pField->nFlags & LBS_NOTIFY) {
|
LPMALLOC pMalloc;
|
||||||
// Remember which control was activated then pretend the user clicked Next
|
if (!SHGetMalloc(&pMalloc)) {
|
||||||
g_NotifyField = nIdx + 1;
|
pMalloc->Free(pResult);
|
||||||
mySendMessage(hMainWindow, WM_NOTIFY_OUTER_NEXT, 1, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
case FIELD_LINK:
|
||||||
|
case FIELD_BUTTON:
|
||||||
|
// Allow the state to be empty - this might be useful in conjunction
|
||||||
|
// with the NOTIFY flag
|
||||||
|
if (*pField->pszState)
|
||||||
|
ShellExecute(hMainWindow, NULL, pField->pszState, NULL, NULL, SW_SHOWDEFAULT);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pField->nFlags & LBS_NOTIFY) {
|
||||||
|
// Remember which control was activated then pretend the user clicked Next
|
||||||
|
g_NotifyField = nIdx + 1;
|
||||||
|
mySendMessage(hMainWindow, WM_NOTIFY_OUTER_NEXT, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue