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;
|
||||
}
|
||||
|
||||
|
||||
LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
|
||||
switch (codeNotify) {
|
||||
case BN_CLICKED: // The user pressed a button
|
||||
case LBN_SELCHANGE: // The user changed the selection in a ListBox control
|
||||
// case CBN_SELCHANGE: // The user changed the selection in a DropList control (same value as LBN_SELCHANGE)
|
||||
{
|
||||
char szBrowsePath[MAX_PATH];
|
||||
int nIdx = FindControlIdx(id);
|
||||
// Ignore if the dialog is in the process of being created
|
||||
if (g_done || nIdx < 0)
|
||||
int nIdx = FindControlIdx(id);
|
||||
// Ignore if the dialog is in the process of being created
|
||||
if (g_done || nIdx < 0)
|
||||
return 0;
|
||||
|
||||
FieldType *pField = pFields + nIdx;
|
||||
|
||||
switch (pField->nType)
|
||||
{
|
||||
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;
|
||||
if (pFields[nIdx].nType == FIELD_BROWSEBUTTON)
|
||||
--nIdx;
|
||||
FieldType *pField = pFields + nIdx;
|
||||
switch (pField->nType) {
|
||||
case FIELD_FILEREQUEST: {
|
||||
OPENFILENAME ofn={0,};
|
||||
}
|
||||
else if (szBrowsePath[0] && CommDlgExtendedError() == FNERR_INVALIDFILENAME) {
|
||||
szBrowsePath[0] = '\0';
|
||||
goto tryagain;
|
||||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
||||
GetWindowText(pField->hwnd, szBrowsePath, sizeof(szBrowsePath));
|
||||
case FIELD_DIRREQUEST: {
|
||||
BROWSEINFO bi;
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
bi.hwndOwner = hConfigWindow;
|
||||
bi.pidlRoot = NULL;
|
||||
bi.pszDisplayName = szBrowsePath;
|
||||
bi.lpszTitle = pField->pszText;
|
||||
#ifndef BIF_NEWDIALOGSTYLE
|
||||
#define BIF_NEWDIALOGSTYLE 0x0040
|
||||
#endif
|
||||
bi.ulFlags = BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
||||
bi.lpfn = BrowseCallbackProc;
|
||||
bi.lParam = nIdx;
|
||||
bi.iImage = 0;
|
||||
bi.ulFlags = BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
||||
bi.lpfn = BrowseCallbackProc;
|
||||
bi.lParam = nIdx;
|
||||
bi.iImage = 0;
|
||||
|
||||
if (pField->pszRoot) {
|
||||
LPSHELLFOLDER sf;
|
||||
ULONG eaten;
|
||||
LPITEMIDLIST root;
|
||||
int ccRoot = (lstrlen(pField->pszRoot) * 2) + 2;
|
||||
LPWSTR pwszRoot = (LPWSTR) MALLOC(ccRoot);
|
||||
MultiByteToWideChar(CP_ACP, 0, pField->pszRoot, -1, pwszRoot, ccRoot);
|
||||
SHGetDesktopFolder(&sf);
|
||||
sf->ParseDisplayName(hConfigWindow, NULL, pwszRoot, &eaten, &root, NULL);
|
||||
bi.pidlRoot = root;
|
||||
sf->Release();
|
||||
FREE(pwszRoot);
|
||||
}
|
||||
// CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
LPITEMIDLIST pResult = SHBrowseForFolder(&bi);
|
||||
if (!pResult)
|
||||
break;
|
||||
if (pField->pszRoot) {
|
||||
LPSHELLFOLDER sf;
|
||||
ULONG eaten;
|
||||
LPITEMIDLIST root;
|
||||
int ccRoot = (lstrlen(pField->pszRoot) * 2) + 2;
|
||||
LPWSTR pwszRoot = (LPWSTR) MALLOC(ccRoot);
|
||||
MultiByteToWideChar(CP_ACP, 0, pField->pszRoot, -1, pwszRoot, ccRoot);
|
||||
SHGetDesktopFolder(&sf);
|
||||
sf->ParseDisplayName(hConfigWindow, NULL, pwszRoot, &eaten, &root, NULL);
|
||||
bi.pidlRoot = root;
|
||||
sf->Release();
|
||||
FREE(pwszRoot);
|
||||
}
|
||||
//CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
LPITEMIDLIST pResult = SHBrowseForFolder(&bi);
|
||||
if (!pResult)
|
||||
break;
|
||||
|
||||
if (SHGetPathFromIDList(pResult, 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 (SHGetPathFromIDList(pResult, szBrowsePath)) {
|
||||
mySetWindowText(pField->hwnd, szBrowsePath);
|
||||
}
|
||||
|
||||
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);
|
||||
LPMALLOC pMalloc;
|
||||
if (!SHGetMalloc(&pMalloc)) {
|
||||
pMalloc->Free(pResult);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue