Graying out when checkbox is checked

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1686 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-11-12 17:59:58 +00:00
parent 02604bba1f
commit 973272562b
2 changed files with 30 additions and 34 deletions

View file

@ -29,8 +29,7 @@ void *lpWndProcOld;
BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ParentWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK ParentWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void AddFolderFromReg(char *name, HKEY rootKey); void AddFolderFromReg(HKEY rootKey);
void PopulateListWithDir(char *dir);
void __declspec(dllexport) Select(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) void __declspec(dllexport) Select(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
{ {
@ -97,7 +96,7 @@ void __declspec(dllexport) Select(HWND hwndParent, int string_size, char *variab
lpWndProcOld = (void *) SetWindowLong(hwndParent, GWL_WNDPROC, (long) ParentWndProc); lpWndProcOld = (void *) SetWindowLong(hwndParent, GWL_WNDPROC, (long) ParentWndProc);
} }
LockWindowUpdate(0); //LockWindowUpdate(0);
while (!g_done) while (!g_done)
{ {
@ -208,7 +207,7 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
temp_r.bottom + 2 temp_r.bottom + 2
); );
SendMessage(hwText, WM_SETTEXT, 0, (LPARAM) text); SetWindowText(hwText, text);
GetWindowRect(hwLocation, &temp_r); GetWindowRect(hwLocation, &temp_r);
@ -221,12 +220,13 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (*lastused == '>') if (*lastused == '>')
{ {
SendMessage(hwCheckBox, BM_SETCHECK, BST_CHECKED, 0); CheckDlgButton(hwndDlg, IDC_CHECK, BST_CHECKED);
lstrcpy(buf, lastused); lstrcpy(lastused, lstrcpy(buf, lastused) + 1);
lstrcpy(lastused, buf + 1); EnableWindow(hwDirList, FALSE);
EnableWindow(hwLocation, FALSE);
} }
SendMessage(hwLocation, WM_SETTEXT, 0, (LPARAM) (*lastused ? lastused : progname)); SetWindowText(hwLocation, *lastused ? lastused : progname);
GetWindowRect(hwCheckBox, &temp_r); GetWindowRect(hwCheckBox, &temp_r);
ScreenToClient(hwndDlg, ((LPPOINT) &temp_r)); ScreenToClient(hwndDlg, ((LPPOINT) &temp_r));
@ -249,11 +249,11 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (*checkbox) if (*checkbox)
{ {
ShowWindow(hwCheckBox, SW_SHOWNA); ShowWindow(hwCheckBox, SW_SHOWNA);
SendMessage(hwCheckBox, WM_SETTEXT, 0, (LPARAM) checkbox); SetWindowText(hwCheckBox, checkbox);
} }
AddFolderFromReg("Programs", HKEY_LOCAL_MACHINE); AddFolderFromReg(HKEY_LOCAL_MACHINE);
AddFolderFromReg("Programs", HKEY_CURRENT_USER); AddFolderFromReg(HKEY_CURRENT_USER);
ShowWindow(hwndDlg, SW_SHOWNA); ShowWindow(hwndDlg, SW_SHOWNA);
SetFocus(GetDlgItem(hwParent, IDOK)); SetFocus(GetDlgItem(hwParent, IDOK));
@ -264,11 +264,14 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
SendMessage(hwDirList, LB_GETTEXT, SendMessage(hwDirList, LB_GETCURSEL, 0, 0), (WPARAM)buf); SendMessage(hwDirList, LB_GETTEXT, SendMessage(hwDirList, LB_GETCURSEL, 0, 0), (WPARAM)buf);
if (autoadd) if (autoadd)
{ lstrcat(lstrcat(buf, "\\"), progname);
lstrcat(buf, "\\"); SetWindowText(hwLocation, buf);
lstrcat(buf, progname); }
} else if (LOWORD(wParam) == IDC_CHECK && HIWORD(wParam) == BN_CLICKED)
SendMessage(hwLocation, WM_SETTEXT, 0, (LPARAM) buf); {
BOOL bEnable = IsDlgButtonChecked(hwStartMenuSelect, IDC_CHECK) != BST_CHECKED;
EnableWindow(hwDirList, bEnable);
EnableWindow(hwLocation, bEnable);
} }
break; break;
case WM_USER+666: case WM_USER+666:
@ -277,13 +280,13 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
pushstring("cancel"); pushstring("cancel");
else else
{ {
if (SendMessage(hwCheckBox, BM_GETCHECK, 0, 0) == BST_CHECKED) if (IsDlgButtonChecked(hwStartMenuSelect, IDC_CHECK) == BST_CHECKED)
{ {
buf[0] = '>'; short *sbuf = (short *) buf;
buf[1] = 0; *sbuf = *(short *) ">";
} }
else *buf = 0; else *buf = 0;
SendMessage(hwLocation, WM_GETTEXT, MAX_PATH, (LPARAM) buf + lstrlen(buf)); GetWindowText(hwLocation, buf + (*buf ? 1 : 0), MAX_PATH);
pushstring(buf); pushstring(buf);
} }
break; break;
@ -297,16 +300,18 @@ BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lp
return TRUE; return TRUE;
} }
void AddFolderFromReg(char *name, HKEY rootKey) void AddFolderFromReg(HKEY rootKey)
{ {
DWORD dwResult; DWORD dwResult;
DWORD dwLength = MAX_PATH; DWORD dwLength = MAX_PATH;
DWORD dwType = REG_SZ; DWORD dwType = REG_SZ;
HKEY hKey; HKEY hKey;
char szName[20] = "Common "; //DWORD idx;
WIN32_FIND_DATA FileData;
HANDLE hSearch;
lstrcpy(szName + 7, name); char szName[20] = "Common Programs";
dwResult = RegOpenKeyEx( dwResult = RegOpenKeyEx(
rootKey, rootKey,
@ -329,17 +334,8 @@ void AddFolderFromReg(char *name, HKEY rootKey)
RegCloseKey(hKey); RegCloseKey(hKey);
} }
PopulateListWithDir(buf); lstrcat(buf, "\\*.");
} hSearch = FindFirstFile(buf, &FileData);
void PopulateListWithDir(char *dir)
{
//DWORD idx;
WIN32_FIND_DATA FileData;
HANDLE hSearch;
lstrcat(dir, "\\*.");
hSearch = FindFirstFile(dir, &FileData);
if (hSearch != INVALID_HANDLE_VALUE) do if (hSearch != INVALID_HANDLE_VALUE) do
{ {
if (*(WORD*)FileData.cFileName != *(WORD*)".") if (*(WORD*)FileData.cFileName != *(WORD*)".")

Binary file not shown.