| 1 |
/* |
| 2 |
* Ui.c |
| 3 |
* |
| 4 |
* This file is a part of NSIS. |
| 5 |
* |
| 6 |
* Copyright (C) 1999-2026 Nullsoft, Jeff Doozan and Contributors |
| 7 |
* |
| 8 |
* Licensed under the zlib/libpng license (the "License"); |
| 9 |
* you may not use this file except in compliance with the License. |
| 10 |
* |
| 11 |
* Licence details can be found in the file COPYING. |
| 12 |
* |
| 13 |
* This software is provided 'as-is', without any express or implied |
| 14 |
* warranty. |
| 15 |
* |
| 16 |
* Unicode support by Jim Park -- 08/10/2007 |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "../Platform.h" |
| 20 |
#include <windowsx.h> |
| 21 |
#include <shlobj.h> |
| 22 |
#include <shellapi.h> |
| 23 |
#include <shlwapi.h> |
| 24 |
|
| 25 |
#include "resource.h" |
| 26 |
|
| 27 |
#include "fileform.h" |
| 28 |
#include "state.h" |
| 29 |
#include "util.h" |
| 30 |
#include "ui.h" |
| 31 |
#include "exec.h" |
| 32 |
#include "plugin.h" |
| 33 |
#include "lang.h" |
| 34 |
#include "components.h" |
| 35 |
#include "api.h" |
| 36 |
|
| 37 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 38 |
HICON g_hIcon; |
| 39 |
#endif |
| 40 |
|
| 41 |
int dlg_offset; |
| 42 |
int ui_dlg_visible=0; // At start main window is not visible |
| 43 |
int g_quit_flag; // set when Quit has been called (meaning bail out ASAP) |
| 44 |
|
| 45 |
#if NSIS_MAX_INST_TYPES > 32 || NSIS_MAX_INST_TYPES < 1 |
| 46 |
#error invalid value for NSIS_MAX_INST_TYPES |
| 47 |
#endif |
| 48 |
|
| 49 |
int progress_bar_pos, progress_bar_len; |
| 50 |
|
| 51 |
#if NSIS_MAX_STRLEN < 1024 |
| 52 |
static TCHAR g_tmp[4096]; |
| 53 |
#else |
| 54 |
static TCHAR g_tmp[NSIS_MAX_STRLEN * 4]; |
| 55 |
#endif |
| 56 |
|
| 57 |
static int m_page=-1,m_retcode,m_delta; |
| 58 |
static page *g_this_page; |
| 59 |
|
| 60 |
static void NSISCALL outernotify(int delta) { |
| 61 |
if (delta==NOTIFY_BYE_BYE) |
| 62 |
g_quit_flag++; |
| 63 |
SendMessage(g_hwnd,WM_NOTIFY_OUTER_NEXT,(WPARAM)delta,0); |
| 64 |
} |
| 65 |
|
| 66 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 67 |
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 68 |
static int CALLBACK WINAPI BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); |
| 69 |
#ifdef NSIS_CONFIG_LICENSEPAGE |
| 70 |
static INT_PTR CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 71 |
#endif |
| 72 |
static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 73 |
static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 74 |
static INT_PTR CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 75 |
static INT_PTR CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 76 |
#endif//NSIS_CONFIG_VISIBLE_SUPPORT |
| 77 |
|
| 78 |
static DWORD WINAPI install_thread(LPVOID p); |
| 79 |
|
| 80 |
void NSISCALL CleanUp(); |
| 81 |
|
| 82 |
HWND insthwnd, insthwnd2, insthwndbutton; |
| 83 |
|
| 84 |
HWND m_curwnd; |
| 85 |
static HWND m_bgwnd, m_hwndOK, m_hwndCancel; |
| 86 |
|
| 87 |
static BOOL NSISCALL SetDlgItemTextFromLang_(HWND dlg, int id, int lid) { |
| 88 |
return my_SetDialogItemText(dlg,id+1000,GetNSISStringTT(lid)); |
| 89 |
} |
| 90 |
|
| 91 |
static void NSISCALL SetNextDef() |
| 92 |
{ |
| 93 |
SendMessage(g_exec_flags.abort ? m_hwndCancel : m_hwndOK, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE); |
| 94 |
} |
| 95 |
|
| 96 |
static void NSISCALL EnableNext(BOOL e) |
| 97 |
{ |
| 98 |
EnableWindow(m_hwndOK, e); |
| 99 |
} |
| 100 |
|
| 101 |
static void NSISCALL SetActiveCtl(HWND hCtl) |
| 102 |
{ |
| 103 |
SendMessage(g_hwnd, WM_NEXTDLGCTL, (WPARAM) hCtl, TRUE); |
| 104 |
} |
| 105 |
|
| 106 |
static BOOL NSISCALL LaunchURL(HWND hOwner, LPCTSTR URL, int ShowMode) |
| 107 |
{ |
| 108 |
SHELLEXECUTEINFO sei; |
| 109 |
sei.fMask = SEE_MASK_FLAG_NO_UI|SEE_MASK_FLAG_DDEWAIT; |
| 110 |
sei.hwnd = hOwner, sei.nShow = SW_SHOWNORMAL; |
| 111 |
sei.lpVerb = _T("open"), sei.lpFile = URL, sei.lpParameters=NULL, sei.lpDirectory = NULL; |
| 112 |
return myShellExecuteEx(&sei); |
| 113 |
} |
| 114 |
|
| 115 |
static void NSISCALL NotifyCurWnd(UINT uNotifyCode) |
| 116 |
{ |
| 117 |
if (m_curwnd) |
| 118 |
SendMessage(m_curwnd, uNotifyCode, 0, 0); |
| 119 |
} |
| 120 |
|
| 121 |
#define SetDlgItemTextFromLang(dlg,id,lid) SetDlgItemTextFromLang_(dlg,(id)-1000,lid) |
| 122 |
|
| 123 |
#define SetUITextFromLang(it,la) SetDlgItemTextFromLang_(hwndDlg,(it)-1000,la) |
| 124 |
#define SetUITextNT(it,text) my_SetDialogItemText(hwndDlg,it,text) |
| 125 |
#define GetUIText(it,s) my_GetDialogItemText(it,s) |
| 126 |
#define GetUIItem(it) GetDlgItem(hwndDlg,it) |
| 127 |
|
| 128 |
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 129 |
// "Link Window"/"SysLink" stores a pointer in GWLP_USERDATA on 2000/XP/2003 and it crashes if we clobber it (forums.winamp.com/showthread.php?t=333379). |
| 130 |
// Checking for ROLE_SYSTEM_LINK is probably more reliable but requires more code. |
| 131 |
#define IsNSISCtlColor(p) ( ( ((p)->lbStyle) <= 1 ) /* BS_SOLID||BS_HOLLOW */ \ |
| 132 |
&& ( (UINT)((p)->bkmode) <= 2 ) /* TRANSPARENT||OPAQUE */ \ |
| 133 |
&& ( ((p)->flags >> CC_FLAGSSHIFTFORZERO) == 0 ) /* CC_* flags */ \ |
| 134 |
) |
| 135 |
|
| 136 |
#define HandleStaticBkColor() _HandleStaticBkColor(uMsg, wParam, lParam) |
| 137 |
static INT_PTR NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 138 |
{ |
| 139 |
if ((uMsg - WM_CTLCOLOREDIT) <= (WM_CTLCOLORSTATIC - WM_CTLCOLOREDIT)) |
| 140 |
{ |
| 141 |
ctlcolors *c = (ctlcolors *)GetWindowLongPtr((HWND)lParam, GWLP_USERDATA); |
| 142 |
|
| 143 |
if (c && IsNSISCtlColor(c)) { |
| 144 |
COLORREF text; |
| 145 |
LOGBRUSH lh; |
| 146 |
|
| 147 |
text = c->text; |
| 148 |
if (c->flags & CC_TEXT_SYS) |
| 149 |
text = GetSysColor(text); |
| 150 |
if (c->flags & CC_TEXT) |
| 151 |
SetTextColor((HDC)wParam, text); |
| 152 |
|
| 153 |
SetBkMode((HDC)wParam, c->bkmode); |
| 154 |
|
| 155 |
lh.lbColor = c->bkc; |
| 156 |
if (c->flags & CC_BK_SYS) |
| 157 |
lh.lbColor = GetSysColor(lh.lbColor); |
| 158 |
if (c->flags & CC_BK) |
| 159 |
SetBkColor((HDC)wParam, lh.lbColor); |
| 160 |
|
| 161 |
if (c->flags & CC_BKB) |
| 162 |
{ |
| 163 |
lh.lbStyle = c->lbStyle; |
| 164 |
if (c->bkb) |
| 165 |
DeleteObject(c->bkb); |
| 166 |
c->bkb = CreateBrushIndirect(&lh); // LOGBRUSH::lbHatch is ignored by BS_SOLID and BS_HOLLOW |
| 167 |
} |
| 168 |
|
| 169 |
return (INT_PTR)c->bkb; |
| 170 |
} |
| 171 |
} |
| 172 |
return 0; |
| 173 |
} |
| 174 |
#else |
| 175 |
#define HandleStaticBkColor() 0 |
| 176 |
#endif//~ NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 177 |
|
| 178 |
#ifdef NSIS_CONFIG_LOG |
| 179 |
#if !defined(NSIS_CONFIG_LOG_ODS) && !defined(NSIS_CONFIG_LOG_STDOUT) |
| 180 |
void NSISCALL build_g_logfile() |
| 181 |
{ |
| 182 |
mystrcat(addtrailingslash(mystrcpy(g_log_file,state_install_directory)),_T("install.log")); |
| 183 |
} |
| 184 |
#endif |
| 185 |
#endif |
| 186 |
|
| 187 |
int *cur_langtable; |
| 188 |
|
| 189 |
static TCHAR* update_caption() |
| 190 |
{ |
| 191 |
TCHAR *gcap = g_caption; |
| 192 |
GetNSISString(gcap, LANG_CAPTION); |
| 193 |
#ifdef NSIS_SUPPORT_BGBG |
| 194 |
my_SetWindowText(m_bgwnd, gcap); |
| 195 |
#endif |
| 196 |
return gcap; |
| 197 |
} |
| 198 |
|
| 199 |
static void NSISCALL set_language() |
| 200 |
{ |
| 201 |
LANGID lang_mask=(LANGID)~0; |
| 202 |
LANGID lang=myatoi(state_language); |
| 203 |
char *language_table=0; |
| 204 |
int lang_num; |
| 205 |
int *selected_langtable=0; |
| 206 |
|
| 207 |
// Jim Park: We are doing byte offsets to get to various data structures so |
| 208 |
// no TCHARs here. |
| 209 |
lang_again: |
| 210 |
lang_num=g_blocks[NB_LANGTABLES].num; |
| 211 |
while (lang_num--) { |
| 212 |
language_table=((char*)g_blocks[NB_LANGTABLES].offset)+lang_num*g_header->langtable_size; |
| 213 |
if (!((lang ^ *(LANGID*)language_table) & lang_mask)) { |
| 214 |
dlg_offset=*(int*)(language_table+sizeof(LANGID)); |
| 215 |
g_exec_flags.rtl=*(int*)(language_table+sizeof(LANGID)+sizeof(int)); |
| 216 |
selected_langtable=(int*)(language_table+sizeof(LANGID)+2*sizeof(int)); |
| 217 |
break; |
| 218 |
} |
| 219 |
} |
| 220 |
if (!selected_langtable) { |
| 221 |
if (lang_mask == (LANGID)~0) |
| 222 |
lang_mask=0x3ff; // primary lang |
| 223 |
else // we already tried once and we still don't have a language table |
| 224 |
lang_mask=0; // first lang |
| 225 |
goto lang_again; |
| 226 |
} |
| 227 |
|
| 228 |
cur_langtable = selected_langtable; |
| 229 |
myitoa(state_language, *(LANGID*)language_table); |
| 230 |
|
| 231 |
update_caption(); |
| 232 |
|
| 233 |
// reload section names |
| 234 |
{ |
| 235 |
section *sec = g_sections; |
| 236 |
int x = num_sections; |
| 237 |
|
| 238 |
while (x--) |
| 239 |
{ |
| 240 |
if (sec->name_ptr) |
| 241 |
{ |
| 242 |
GetNSISString(sec->name, sec->name_ptr); |
| 243 |
} |
| 244 |
sec++; |
| 245 |
} |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
FORCE_INLINE int NSISCALL ui_doinstall(void) |
| 250 |
{ |
| 251 |
header *header = g_header; |
| 252 |
static WNDCLASS wc; // richedit subclassing and bgbg creation |
| 253 |
|
| 254 |
// detect default language |
| 255 |
// more information at: |
| 256 |
// https://web.archive.org/web/20060618155426/http://msdn.microsoft.com/library/en-us/intl/nls_0xrn.asp |
| 257 |
|
| 258 |
LANGID (WINAPI *GUDUIL)(); |
| 259 |
|
| 260 |
#ifdef _WIN64 |
| 261 |
GUDUIL = GetUserDefaultUILanguage; |
| 262 |
#else |
| 263 |
GUDUIL = myGetProcAddress(MGA_GetUserDefaultUILanguage); |
| 264 |
if (GUDUIL) |
| 265 |
#endif |
| 266 |
{ |
| 267 |
// Windows ME/2000+ |
| 268 |
myitoa(state_language, GUDUIL()); |
| 269 |
} |
| 270 |
#ifndef _WIN64 |
| 271 |
else |
| 272 |
{ |
| 273 |
static const TCHAR reg_9x_locale[] = _T("Control Panel\\Desktop\\ResourceLocale"); |
| 274 |
static const TCHAR reg_nt_locale_key[] = _T(".DEFAULT\\Control Panel\\International"); |
| 275 |
const TCHAR *reg_nt_locale_val = ®_9x_locale[30]; // = _T("Locale") with opt |
| 276 |
|
| 277 |
state_language[0] = _T('0'); |
| 278 |
state_language[1] = _T('x'); |
| 279 |
state_language[2] = 0; |
| 280 |
|
| 281 |
{ |
| 282 |
// Windows 9x |
| 283 |
myRegGetStr(HKEY_CURRENT_USER, reg_9x_locale, NULL, g_tmp, 0); |
| 284 |
} |
| 285 |
|
| 286 |
if (!g_tmp[0]) |
| 287 |
{ |
| 288 |
// Windows NT |
| 289 |
// This key exists on 9x as well, so it's only read if ResourceLocale wasn't found |
| 290 |
myRegGetStr(HKEY_USERS, reg_nt_locale_key, reg_nt_locale_val, g_tmp, 0); |
| 291 |
} |
| 292 |
|
| 293 |
mystrcat(state_language, g_tmp); |
| 294 |
} |
| 295 |
#endif |
| 296 |
|
| 297 |
// set default language |
| 298 |
set_language(); |
| 299 |
|
| 300 |
// initialize auto close flag |
| 301 |
g_exec_flags.autoclose=g_flags&CH_FLAGS_AUTO_CLOSE; |
| 302 |
|
| 303 |
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT |
| 304 |
// initialize plugin api |
| 305 |
g_exec_flags.plugin_api_version=NSISPIAPIVER_CURR; |
| 306 |
#endif |
| 307 |
|
| 308 |
// read install directory from registry |
| 309 |
if (!is_valid_instpath(state_install_directory)) |
| 310 |
{ |
| 311 |
if (header->install_reg_key_ptr) |
| 312 |
{ |
| 313 |
myRegGetStr( |
| 314 |
(HKEY)(UINT_PTR)header->install_reg_rootkey, |
| 315 |
GetNSISStringNP(header->install_reg_key_ptr), |
| 316 |
GetNSISStringNP(header->install_reg_value_ptr), |
| 317 |
ps_tmpbuf, |
| 318 |
0 |
| 319 |
); |
| 320 |
if (ps_tmpbuf[0]) |
| 321 |
{ |
| 322 |
TCHAR *p=ps_tmpbuf; |
| 323 |
TCHAR *e; |
| 324 |
if (p[0]==_T('\"')) |
| 325 |
{ |
| 326 |
TCHAR *p2; |
| 327 |
p++; |
| 328 |
p2 = findchar(p, _T('"')); |
| 329 |
*p2 = 0; |
| 330 |
} |
| 331 |
// p is the path now, check for .exe extension |
| 332 |
|
| 333 |
e=p+mystrlen(p)-4; |
| 334 |
if (e > p) |
| 335 |
{ |
| 336 |
// if filename ends in .exe, and is not a directory, remove the filename |
| 337 |
if (!lstrcmpi(e, _T(".exe"))) // check extension |
| 338 |
{ |
| 339 |
DWORD d; |
| 340 |
d=GetFileAttributes(p); |
| 341 |
if (d == INVALID_FILE_ATTRIBUTES || !(d&FILE_ATTRIBUTE_DIRECTORY)) |
| 342 |
{ |
| 343 |
// if there is no back-slash, the string will become empty, but that's ok because |
| 344 |
// it would make an invalid instdir anyway |
| 345 |
trimslashtoend(p); |
| 346 |
} |
| 347 |
} |
| 348 |
} |
| 349 |
mystrcpy(state_install_directory,addtrailingslash(p)); |
| 350 |
} |
| 351 |
} |
| 352 |
} |
| 353 |
if (!is_valid_instpath(state_install_directory)) |
| 354 |
{ |
| 355 |
GetNSISString(state_install_directory,header->install_directory_ptr); |
| 356 |
} |
| 357 |
|
| 358 |
#ifdef NSIS_CONFIG_LOG |
| 359 |
if (g_flags & CH_FLAGS_SILENT_LOG && !g_is_uninstaller) |
| 360 |
{ |
| 361 |
#if !defined(NSIS_CONFIG_LOG_ODS) && !defined(NSIS_CONFIG_LOG_STDOUT) |
| 362 |
build_g_logfile(); |
| 363 |
#endif |
| 364 |
log_dolog=1; |
| 365 |
} |
| 366 |
#endif |
| 367 |
|
| 368 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 369 |
g_hIcon=LoadImage(g_hInstance,MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_SHARED); |
| 370 |
#ifdef NSIS_SUPPORT_BGBG |
| 371 |
if (header->bg_color1 != -1) |
| 372 |
{ |
| 373 |
LPCTSTR cn = _T("_Nb"); |
| 374 |
RECT vp; |
| 375 |
extern LRESULT CALLBACK BG_WndProc(HWND, UINT, WPARAM, LPARAM); |
| 376 |
wc.lpfnWndProc = BG_WndProc; |
| 377 |
wc.hInstance = g_hInstance; |
| 378 |
wc.hIcon = g_hIcon; |
| 379 |
//wc.hCursor = LoadCursor(NULL,IDC_ARROW); |
| 380 |
wc.lpszClassName = cn; |
| 381 |
|
| 382 |
if (!RegisterClass(&wc)) return 0; |
| 383 |
|
| 384 |
SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0); |
| 385 |
|
| 386 |
m_bgwnd = CreateWindowEx(WS_EX_TOOLWINDOW,cn,0,WS_POPUP, |
| 387 |
vp.left,vp.top,vp.right-vp.left,vp.bottom-vp.top,0,NULL,g_hInstance,NULL); |
| 388 |
} |
| 389 |
|
| 390 |
#endif//NSIS_SUPPORT_BGBG |
| 391 |
|
| 392 |
#endif//NSIS_CONFIG_VISIBLE_SUPPORT |
| 393 |
|
| 394 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 395 |
// Select language |
| 396 |
if (ExecuteCallbackFunction(CB_ONINIT)) return 2; |
| 397 |
set_language(); |
| 398 |
#endif |
| 399 |
|
| 400 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 401 |
|
| 402 |
#ifdef NSIS_CONFIG_SILENT_SUPPORT |
| 403 |
if (!g_exec_flags.silent) |
| 404 |
#endif//NSIS_CONFIG_SILENT_SUPPORT |
| 405 |
{ |
| 406 |
#ifdef NSIS_SUPPORT_BGBG |
| 407 |
ShowWindow(m_bgwnd, SW_SHOW); |
| 408 |
#endif//NSIS_SUPPORT_BGBG |
| 409 |
|
| 410 |
#ifdef NSIS_CONFIG_LICENSEPAGE |
| 411 |
{ // load richedit DLL |
| 412 |
static const CHAR riched20[]=("RichEd20"); // v2..3 DLL |
| 413 |
static const CHAR riched32[]=("RichEd32"); // v1 DLL |
| 414 |
#ifdef UNICODE |
| 415 |
static const TCHAR richedit20t[]=_T("RichEdit20W"); |
| 416 |
#else |
| 417 |
static const TCHAR richedit20t[]=_T("RichEdit20A"); |
| 418 |
#endif |
| 419 |
static const TCHAR richedit[]=_T("RichEdit"); // v1 class |
| 420 |
if (!LoadSystemLibrary(riched20)) |
| 421 |
{ |
| 422 |
LoadSystemLibrary(riched32); // Win95 only ships with v1.0, NT4 has v2.0: web.archive.org/web/20030607222419/http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/aboutricheditcontrols.asp |
| 423 |
} |
| 424 |
|
| 425 |
// Register RichEdit20A/W as a RICHEDIT clone (for Win95) |
| 426 |
if (!GetClassInfo(NULL,richedit20t,&wc)) |
| 427 |
{ |
| 428 |
GetClassInfo(NULL,richedit,&wc); |
| 429 |
wc.lpszClassName = richedit20t; |
| 430 |
RegisterClass(&wc); |
| 431 |
} |
| 432 |
} |
| 433 |
|
| 434 |
#endif |
| 435 |
|
| 436 |
{ |
| 437 |
int ret=(int) DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INST+dlg_offset),0,DialogProc); |
| 438 |
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT) |
| 439 |
ExecuteCallbackFunction(CB_ONGUIEND); |
| 440 |
#endif |
| 441 |
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT |
| 442 |
Plugins_SendMsgToAllPlugins(NSPIM_GUIUNLOAD); |
| 443 |
#endif |
| 444 |
return ret; |
| 445 |
} |
| 446 |
} |
| 447 |
#endif//NSIS_CONFIG_VISIBLE_SUPPORT |
| 448 |
#ifdef NSIS_CONFIG_SILENT_SUPPORT |
| 449 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 450 |
else |
| 451 |
#endif//NSIS_CONFIG_VISIBLE_SUPPORT |
| 452 |
{ |
| 453 |
if (install_thread(NULL)) |
| 454 |
{ |
| 455 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 456 |
if (!g_quit_flag) ExecuteCallbackFunction(CB_ONINSTFAILED); |
| 457 |
#endif//NSIS_SUPPORT_CODECALLBACKS |
| 458 |
return 2; |
| 459 |
} |
| 460 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 461 |
ExecuteCallbackFunction(CB_ONINSTSUCCESS); |
| 462 |
#endif//NSIS_SUPPORT_CODECALLBACKS |
| 463 |
|
| 464 |
return 0; |
| 465 |
} |
| 466 |
#endif//NSIS_CONFIG_SILENT_SUPPORT |
| 467 |
} |
| 468 |
|
| 469 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 470 |
static int CALLBACK WINAPI BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) |
| 471 |
{ |
| 472 |
// lpData has the TCHAR* to 'dir'. |
| 473 |
if (uMsg==BFFM_INITIALIZED) |
| 474 |
{ |
| 475 |
my_GetDialogItemText(IDC_DIR,(TCHAR*)lpData); |
| 476 |
SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)1,lpData); |
| 477 |
} |
| 478 |
if (uMsg==BFFM_SELCHANGED) |
| 479 |
{ |
| 480 |
SendMessage( |
| 481 |
hwnd, |
| 482 |
BFFM_ENABLEOK, |
| 483 |
0, |
| 484 |
SHGetPathFromIDList((LPITEMIDLIST)lParam,(TCHAR*)lpData) |
| 485 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 486 |
&& !ExecuteCallbackFunction(CB_ONVERIFYINSTDIR) |
| 487 |
#endif |
| 488 |
); |
| 489 |
} |
| 490 |
return 0; |
| 491 |
} |
| 492 |
|
| 493 |
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 494 |
{ |
| 495 |
if (uMsg == WM_INITDIALOG || uMsg == WM_NOTIFY_OUTER_NEXT) |
| 496 |
{ |
| 497 |
page *this_page; |
| 498 |
static DLGPROC winprocs[]= |
| 499 |
{ |
| 500 |
#ifdef NSIS_CONFIG_LICENSEPAGE |
| 501 |
LicenseProc, |
| 502 |
#endif |
| 503 |
#ifdef NSIS_CONFIG_COMPONENTPAGE |
| 504 |
SelProc, |
| 505 |
#endif |
| 506 |
DirProc, |
| 507 |
InstProc, |
| 508 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 509 |
UninstProc |
| 510 |
#endif |
| 511 |
}; |
| 512 |
|
| 513 |
m_delta = (int) wParam; |
| 514 |
|
| 515 |
if (uMsg == WM_INITDIALOG) |
| 516 |
{ |
| 517 |
g_hwnd=hwndDlg; |
| 518 |
m_hwndOK=GetDlgItem(hwndDlg,IDOK); |
| 519 |
m_hwndCancel=GetDlgItem(hwndDlg,IDCANCEL); |
| 520 |
SetDlgItemTextFromLang(hwndDlg,IDC_VERSTR,LANG_BRANDING); |
| 521 |
SetClassLongPtr(hwndDlg,GCLP_HICON,(LONG_PTR)g_hIcon); |
| 522 |
// use the following line instead of the above, if .rdata needs shirking |
| 523 |
//SendMessage(hwndDlg,WM_SETICON,ICON_BIG,(LPARAM)g_hIcon); |
| 524 |
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT) |
| 525 |
g_quit_flag = ExecuteCallbackFunction(CB_ONGUIINIT); |
| 526 |
#endif |
| 527 |
//ShowWindow(hwndDlg, SW_SHOW); |
| 528 |
m_delta = 1; |
| 529 |
} |
| 530 |
|
| 531 |
this_page=g_pages+m_page; |
| 532 |
|
| 533 |
if (m_page>=0) { |
| 534 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 535 |
// Call leave function. If Abort used don't move to the next page. |
| 536 |
// But if quit called we must exit now |
| 537 |
if (m_delta==1) if (ExecuteCodeSegment(this_page->leavefunc,NULL)) { |
| 538 |
SendMessage(m_curwnd, WM_IN_UPDATEMSG, 0, 1); |
| 539 |
return !g_quit_flag; |
| 540 |
} |
| 541 |
#endif |
| 542 |
|
| 543 |
// if the last page was a custom page, wait for it to finish by itself. |
| 544 |
// if it doesn't, it's a BAD plugin. |
| 545 |
// plugins should react to WM_NOTIFY_OUTER_NEXT. |
| 546 |
if (!this_page->dlg_id) return 0; |
| 547 |
} |
| 548 |
|
| 549 |
NotifyCurWnd(WM_NOTIFY_INIGO_MONTOYA); |
| 550 |
|
| 551 |
nextPage: |
| 552 |
m_page+=m_delta; |
| 553 |
this_page+=m_delta; |
| 554 |
|
| 555 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 556 |
if (m_page==g_blocks[NB_PAGES].num) ExecuteCallbackFunction(CB_ONINSTSUCCESS); |
| 557 |
#endif//NSIS_SUPPORT_CODECALLBACKS |
| 558 |
|
| 559 |
if (g_quit_flag || (unsigned int)m_page >= (unsigned int)g_blocks[NB_PAGES].num) |
| 560 |
{ |
| 561 |
DestroyWindow(m_curwnd); |
| 562 |
g_hwnd = 0; |
| 563 |
EndDialog(hwndDlg,m_retcode); |
| 564 |
} |
| 565 |
else |
| 566 |
{ |
| 567 |
HWND hwndtmp; |
| 568 |
int pflags = this_page->flags; |
| 569 |
|
| 570 |
GetNSISString(state_click_next, this_page->clicknext); |
| 571 |
SetDlgItemTextFromLang(hwndDlg, IDOK, this_page->next); |
| 572 |
SetDlgItemTextFromLang(hwndDlg, IDC_BACK, this_page->back); |
| 573 |
SetDlgItemTextFromLang(hwndDlg, IDCANCEL, this_page->cancel); |
| 574 |
|
| 575 |
hwndtmp = GetDlgItem(hwndDlg, IDC_BACK); |
| 576 |
|
| 577 |
if (g_exec_flags.abort) |
| 578 |
{ |
| 579 |
pflags &= ~(PF_BACK_ENABLE | PF_NEXT_ENABLE); |
| 580 |
pflags |= PF_CANCEL_ENABLE; |
| 581 |
} |
| 582 |
|
| 583 |
ShowWindow(hwndtmp, pflags & PF_BACK_SHOW);// SW_HIDE = 0, PF_BACK_SHOW = SW_SHOWNA = 8 |
| 584 |
EnableWindow(hwndtmp, pflags & PF_BACK_ENABLE); |
| 585 |
EnableNext(pflags & PF_NEXT_ENABLE); |
| 586 |
EnableWindow(m_hwndCancel, pflags & PF_CANCEL_ENABLE); |
| 587 |
|
| 588 |
if (pflags & PF_CANCEL_ENABLE) |
| 589 |
EnableMenuItem(GetSystemMenu(hwndDlg, FALSE), SC_CLOSE, MF_BYCOMMAND | MF_ENABLED); |
| 590 |
else |
| 591 |
EnableMenuItem(GetSystemMenu(hwndDlg, FALSE), SC_CLOSE, MF_BYCOMMAND | MF_GRAYED); |
| 592 |
|
| 593 |
SendMessage(hwndtmp, BM_SETSTYLE, BS_PUSHBUTTON, TRUE); |
| 594 |
|
| 595 |
if (g_exec_flags.abort) |
| 596 |
{ |
| 597 |
SendMessage(hwndDlg, DM_SETDEFID, IDCANCEL, 0); |
| 598 |
SetActiveCtl(m_hwndCancel); |
| 599 |
} |
| 600 |
else |
| 601 |
{ |
| 602 |
SetActiveCtl(m_hwndOK); |
| 603 |
} |
| 604 |
|
| 605 |
mystrcpy(g_tmp,update_caption()); |
| 606 |
GetNSISString(g_tmp+mystrlen(g_tmp),this_page->caption); |
| 607 |
my_SetWindowText(hwndDlg,g_tmp); |
| 608 |
|
| 609 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 610 |
// custom page or user used abort in prefunc |
| 611 |
if (ExecuteCodeSegment(this_page->prefunc, NULL) || !this_page->dlg_id) { |
| 612 |
goto nextPage; |
| 613 |
} |
| 614 |
#endif //NSIS_SUPPORT_CODECALLBACKS |
| 615 |
|
| 616 |
if (this_page->wndproc_id != PWP_COMPLETED) |
| 617 |
{ |
| 618 |
DestroyWindow(m_curwnd); |
| 619 |
} |
| 620 |
else { |
| 621 |
if (!g_exec_flags.abort && g_exec_flags.autoclose) |
| 622 |
goto nextPage; |
| 623 |
// no need to go to skipPage because PWP_COMPLETED always follows PWP_INSTFILES |
| 624 |
return FALSE; |
| 625 |
} |
| 626 |
|
| 627 |
// update g_this_page for the dialog proc |
| 628 |
g_this_page=this_page; |
| 629 |
|
| 630 |
if (this_page->dlg_id > 0) // NSIS page |
| 631 |
{ |
| 632 |
m_curwnd=CreateDialogParam( |
| 633 |
g_hInstance, |
| 634 |
MAKEINTRESOURCE(this_page->dlg_id+dlg_offset), |
| 635 |
hwndDlg,winprocs[this_page->wndproc_id],(LPARAM)this_page |
| 636 |
); |
| 637 |
if (m_curwnd) |
| 638 |
{ |
| 639 |
RECT r; |
| 640 |
|
| 641 |
SetDlgItemTextFromLang(m_curwnd,IDC_INTROTEXT,this_page->parms[0]); |
| 642 |
|
| 643 |
GetWindowRect(GetDlgItem(hwndDlg,IDC_CHILDRECT),&r); |
| 644 |
ScreenToClient(hwndDlg,(LPPOINT)&r); |
| 645 |
SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER); |
| 646 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 647 |
ExecuteCodeSegment(this_page->showfunc,NULL); |
| 648 |
if (g_quit_flag) |
| 649 |
return FALSE; |
| 650 |
#endif //NSIS_SUPPORT_CODECALLBACKS |
| 651 |
ShowWindow(m_curwnd,SW_SHOWNA); |
| 652 |
NotifyCurWnd(WM_NOTIFY_START); |
| 653 |
} |
| 654 |
} |
| 655 |
} |
| 656 |
|
| 657 |
skipPage: |
| 658 |
|
| 659 |
if (!ui_dlg_visible && m_curwnd) |
| 660 |
{ |
| 661 |
ShowWindow(hwndDlg, SW_SHOWDEFAULT); |
| 662 |
ui_dlg_visible = 1; |
| 663 |
} |
| 664 |
|
| 665 |
return FALSE; |
| 666 |
} |
| 667 |
|
| 668 |
#ifdef NSIS_SUPPORT_BGBG |
| 669 |
if (uMsg == WM_WINDOWPOSCHANGED) |
| 670 |
{ |
| 671 |
SetWindowPos(m_bgwnd, hwndDlg, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); |
| 672 |
} |
| 673 |
if (uMsg == WM_SIZE) { |
| 674 |
ShowWindow(m_bgwnd, wParam == SIZE_MINIMIZED ? SW_HIDE : SW_SHOW); |
| 675 |
#else //! NSIS_SUPPORT_BGBG |
| 676 |
if (uMsg == WM_SIZE) { |
| 677 |
#endif //~ NSIS_SUPPORT_BGBG |
| 678 |
if (wParam == SIZE_MAXIMIZED) { |
| 679 |
DWORD style = (DWORD) GetWindowLongPtr(hwndDlg, GWL_STYLE), mask = WS_MAXIMIZEBOX|WS_MAXIMIZE|WS_MINIMIZE; |
| 680 |
if ((style & mask) == WS_MAXIMIZE) ShowWindow(hwndDlg, SW_SHOWNOACTIVATE); // Disallow STARTF_USESHOWWINDOW+SW_MAXIMIZE unless someone does ${NSD_AddStyle} $hWndParent ${WS_MAXIMIZEBOX} |
| 681 |
} |
| 682 |
} |
| 683 |
if (uMsg == WM_NOTIFY_CUSTOM_READY) { |
| 684 |
DestroyWindow(m_curwnd); |
| 685 |
m_curwnd = (HWND)wParam; |
| 686 |
goto skipPage; |
| 687 |
} |
| 688 |
if (uMsg == WM_QUERYENDSESSION) |
| 689 |
{ |
| 690 |
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, FALSE); |
| 691 |
return TRUE; |
| 692 |
} |
| 693 |
if (uMsg == WM_COMMAND) |
| 694 |
{ |
| 695 |
int id = LOWORD(wParam); |
| 696 |
HWND hCtl = GetDlgItem(hwndDlg, id); // lParam might be NULL |
| 697 |
if (hCtl) |
| 698 |
{ |
| 699 |
SendMessage(hCtl, BM_SETSTATE, FALSE, 0); |
| 700 |
if (!IsWindowEnabled(hCtl)) |
| 701 |
return 0; |
| 702 |
} |
| 703 |
|
| 704 |
if (id == IDOK) |
| 705 |
{ |
| 706 |
outernotify(1); |
| 707 |
} |
| 708 |
else if (id == IDC_BACK && m_page>0) |
| 709 |
{ |
| 710 |
outernotify(-1); |
| 711 |
} |
| 712 |
else if (id == IDCANCEL) |
| 713 |
{ |
| 714 |
if (g_exec_flags.abort) |
| 715 |
{ |
| 716 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 717 |
ExecuteCallbackFunction(CB_ONINSTFAILED); |
| 718 |
#endif//NSIS_SUPPORT_CODECALLBACKS |
| 719 |
m_retcode=2; |
| 720 |
outernotify(NOTIFY_BYE_BYE); |
| 721 |
} |
| 722 |
else |
| 723 |
{ |
| 724 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 725 |
if (!ExecuteCallbackFunction(CB_ONUSERABORT)) |
| 726 |
#endif//NSIS_SUPPORT_CODECALLBACKS |
| 727 |
{ |
| 728 |
m_retcode=1; |
| 729 |
outernotify(NOTIFY_BYE_BYE); |
| 730 |
} |
| 731 |
} |
| 732 |
} |
| 733 |
else |
| 734 |
{ |
| 735 |
// Forward WM_COMMANDs to inner dialogs, can be custom ones. |
| 736 |
// Without this, enter on buttons in inner dialogs won't work. |
| 737 |
SendMessage(m_curwnd, WM_COMMAND, wParam, lParam); |
| 738 |
} |
| 739 |
} |
| 740 |
return HandleStaticBkColor(); |
| 741 |
} |
| 742 |
|
| 743 |
#define this_page ((page*)lParam) |
| 744 |
|
| 745 |
#ifdef NSIS_CONFIG_LICENSEPAGE |
| 746 |
|
| 747 |
#define _RICHEDIT_VER 0x0200 |
| 748 |
#include <richedit.h> |
| 749 |
#undef _RICHEDIT_VER |
| 750 |
static DWORD g_cbLicRead; |
| 751 |
DWORD CALLBACK StreamLicense(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) |
| 752 |
{ |
| 753 |
lstrcpyn((LPTSTR)pbBuff,(LPTSTR)(dwCookie+g_cbLicRead),cb/sizeof(TCHAR)); |
| 754 |
*pcb=lstrlen((LPTSTR)pbBuff)*sizeof(TCHAR); |
| 755 |
g_cbLicRead+=*pcb; |
| 756 |
return 0; |
| 757 |
} |
| 758 |
#ifdef _UNICODE |
| 759 |
// on-the-fly conversion of Unicode to ANSI (because Windows doesn't recognize Unicode RTF data) |
| 760 |
DWORD CALLBACK StreamLicenseRTF(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) |
| 761 |
{ |
| 762 |
size_t len = lstrlen(((LPWSTR) dwCookie)+g_cbLicRead); |
| 763 |
len = min(len, cb/sizeof(WCHAR)); |
| 764 |
*pcb=WideCharToMultiByte(CP_ACP,0,((LPWSTR) dwCookie)+g_cbLicRead,(int)len,(char*)pbBuff,cb,NULL,NULL); |
| 765 |
// RTF uses only ASCII characters, so we can assume "number of output bytes" = "number of source WChar consumed" |
| 766 |
g_cbLicRead+=*pcb; |
| 767 |
return 0; |
| 768 |
} |
| 769 |
#endif |
| 770 |
|
| 771 |
static INT_PTR CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 772 |
{ |
| 773 |
page *m_this_page=g_this_page; |
| 774 |
HWND hwLicense; |
| 775 |
#define LicIgnoreWMCommand g_cbLicRead // g_cbLicRead is only used in WM_INITDIALOG during EM_STREAMIN |
| 776 |
|
| 777 |
if (uMsg == WM_INITDIALOG) |
| 778 |
{ |
| 779 |
TCHAR *l = (TCHAR *)GetNSISStringNP(GetNSISTab(this_page->parms[1])); |
| 780 |
int lt = *l; |
| 781 |
EDITSTREAM es = { |
| 782 |
(DWORD_PTR)(++l), |
| 783 |
0, |
| 784 |
#ifdef _UNICODE |
| 785 |
lt==SF_RTF?StreamLicenseRTF:StreamLicense |
| 786 |
#else |
| 787 |
StreamLicense |
| 788 |
#endif |
| 789 |
}; |
| 790 |
|
| 791 |
int selected = (this_page->flags & PF_LICENSE_SELECTED) | !(this_page->flags & PF_LICENSE_FORCE_SELECTION); |
| 792 |
|
| 793 |
SetUITextFromLang(IDC_LICENSEAGREE,this_page->parms[2]); |
| 794 |
SetUITextFromLang(IDC_LICENSEDISAGREE,this_page->parms[3]); |
| 795 |
CheckDlgButton(hwndDlg,IDC_LICENSEAGREE+!selected,BST_CHECKED); |
| 796 |
EnableNext(selected); |
| 797 |
|
| 798 |
hwLicense=GetUIItem(IDC_EDIT1); |
| 799 |
SetActiveCtl(hwLicense); |
| 800 |
SendMessage(hwLicense,EM_AUTOURLDETECT,TRUE,0); |
| 801 |
#define lbg g_header->license_bg |
| 802 |
SendMessage(hwLicense,EM_SETBKGNDCOLOR,0,lbg>=0?lbg:GetSysColor(-lbg)); |
| 803 |
#undef lbg |
| 804 |
SendMessage(hwLicense,EM_SETEVENTMASK,0,ENM_LINK|ENM_KEYEVENTS); //XGE 8th September 2002 Or'd in ENM_KEYEVENTS |
| 805 |
SendMessage(hwLicense,EM_EXLIMITTEXT,0,mystrlen(l)); |
| 806 |
g_cbLicRead = 0; |
| 807 |
SendMessage(hwLicense,EM_STREAMIN,lt,(LPARAM)&es); |
| 808 |
LicIgnoreWMCommand = 0; |
| 809 |
return FALSE; |
| 810 |
} |
| 811 |
if (uMsg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && !LicIgnoreWMCommand) { |
| 812 |
if (m_this_page->flags & PF_LICENSE_FORCE_SELECTION) { |
| 813 |
int is = (int) (SendMessage(GetUIItem(IDC_LICENSEAGREE), BM_GETCHECK, 0, 0) & BST_CHECKED); |
| 814 |
m_this_page->flags &= ~PF_LICENSE_SELECTED; |
| 815 |
m_this_page->flags |= is; |
| 816 |
EnableNext(is); |
| 817 |
SetNextDef(); |
| 818 |
} |
| 819 |
} |
| 820 |
if (uMsg == WM_NOTIFY) { |
| 821 |
hwLicense=GetUIItem(IDC_EDIT1); |
| 822 |
#define nmhdr ((NMHDR *)lParam) |
| 823 |
#define enlink ((ENLINK *)lParam) |
| 824 |
#define msgfilter ((MSGFILTER *)lParam) |
| 825 |
if (nmhdr->code==EN_LINK) { |
| 826 |
if (enlink->msg==WM_LBUTTONDOWN) { |
| 827 |
TEXTRANGE tr = { |
| 828 |
{ |
| 829 |
enlink->chrg.cpMin, |
| 830 |
enlink->chrg.cpMax, |
| 831 |
}, |
| 832 |
ps_tmpbuf |
| 833 |
}; |
| 834 |
if (tr.chrg.cpMax-tr.chrg.cpMin < COUNTOF(ps_tmpbuf)) { |
| 835 |
SendMessage(hwLicense,EM_GETTEXTRANGE,0,(LPARAM)&tr); |
| 836 |
SetCursor(LoadCursor(0, IDC_WAIT)); |
| 837 |
LaunchURL(hwndDlg,tr.lpstrText,SW_SHOWNORMAL); |
| 838 |
SetCursor(LoadCursor(0, IDC_ARROW)); |
| 839 |
} |
| 840 |
} |
| 841 |
} |
| 842 |
//Ximon Eighteen 8th September 2002 Capture return key presses in the rich |
| 843 |
//edit control now that the control gets the focus rather than the default |
| 844 |
//push button. When the user presses return ask the outer dialog to move |
| 845 |
//the installer onto the next page. MSDN docs say return non-zero if the |
| 846 |
//rich edit control should NOT process this message, hence the return 1. |
| 847 |
// |
| 848 |
//This is required because the RichEdit control is eating all the key hits. |
| 849 |
//It does try to release some and convert VK_ESCAPE to WM_CLOSE, VK_ENTER |
| 850 |
//to a push on the default button and VM_TAB to WM_NEXTDLGCTL. But sadly it |
| 851 |
//it sends all of these messages to its parent instead of just letting the |
| 852 |
//dialog manager handle them. Instead of properly handling WM_GETDLGCODE, |
| 853 |
//it mimics the dialog manager. |
| 854 |
if (nmhdr->code==EN_MSGFILTER) |
| 855 |
{ |
| 856 |
if (msgfilter->msg==WM_KEYDOWN) |
| 857 |
{ |
| 858 |
if (msgfilter->wParam==VK_RETURN) { |
| 859 |
SendMessage(g_hwnd, WM_COMMAND, IDOK, 0); |
| 860 |
} |
| 861 |
if (msgfilter->wParam==VK_ESCAPE) { |
| 862 |
SendMessage(g_hwnd, WM_CLOSE, 0, 0); |
| 863 |
} |
| 864 |
return 1; |
| 865 |
} |
| 866 |
} |
| 867 |
#undef nmhdr |
| 868 |
#undef enlink |
| 869 |
#undef msgfilter |
| 870 |
} |
| 871 |
if (uMsg == WM_NOTIFY_INIGO_MONTOYA) |
| 872 |
{ |
| 873 |
LicIgnoreWMCommand++; |
| 874 |
} |
| 875 |
return HandleStaticBkColor(); |
| 876 |
} |
| 877 |
#endif |
| 878 |
|
| 879 |
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT |
| 880 |
static INT_PTR CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 881 |
{ |
| 882 |
if (uMsg == WM_INITDIALOG) |
| 883 |
{ |
| 884 |
SetUITextFromLang(IDC_UNINSTFROM,this_page->parms[1]); |
| 885 |
SetUITextNT(IDC_EDIT1,g_usrvars[this_page->parms[4]]); |
| 886 |
} |
| 887 |
return HandleStaticBkColor(); |
| 888 |
} |
| 889 |
#endif |
| 890 |
|
| 891 |
#ifndef _NSIS_NO_INT64_SHR |
| 892 |
#define NRT_U64Shr32(v,s) ( (v) >> (s) ) |
| 893 |
#else |
| 894 |
#define NRT_U64Shr32 Int64ShrlMod32 |
| 895 |
#endif |
| 896 |
|
| 897 |
static void NSISCALL SetSizeText64(int dlgItem, int prefix, ULARGE_INTEGER kb64) |
| 898 |
{ |
| 899 |
TCHAR scalestr[32], byte[32]; |
| 900 |
int scale = LANG_GIGA; |
| 901 |
UINT intgr, fract; |
| 902 |
|
| 903 |
if (kb64.HighPart) // >= 4 TiB ? |
| 904 |
{ |
| 905 |
kb64.QuadPart = NRT_U64Shr32(kb64.QuadPart, 20); // Convert from KiB to GiB |
| 906 |
// wsprintf only supports the I64 size specifier on WinXP+. |
| 907 |
// Older versions would crash because %s will use a bad pointer if we use "%I64u%s%s". |
| 908 |
// Consequently we will only use the bottom 32-bits of the size (in GiB), |
| 909 |
// this means we will display the wrong number if you have more than 4194303 TiB of free space. |
| 910 |
intgr = kb64.LowPart; |
| 911 |
fract = 0; // We don't even attempt to calculate this |
| 912 |
} |
| 913 |
else |
| 914 |
{ |
| 915 |
unsigned sh = 20, kb = kb64.LowPart; |
| 916 |
if (kb < 1024 * 1024) sh = 10, scale = LANG_MEGA; |
| 917 |
if (kb < 1024) sh = 0, scale = LANG_KILO; |
| 918 |
|
| 919 |
if (kb < (0xFFFFFFFF - ((1 << 20) / 20))) // check for overflow |
| 920 |
kb += (1 << sh) / 20; // round numbers for better display (e.g. 1.59 => 1.6) |
| 921 |
|
| 922 |
intgr = kb >> sh; |
| 923 |
// 0x00FFFFFF mask is used to prevent overflow that causes bad results |
| 924 |
fract = (((kb & 0x00FFFFFF) * 10) >> sh) % 10; |
| 925 |
} |
| 926 |
|
| 927 |
#if _MSC_VER == 1200 // patch #1982084 |
| 928 |
wsprintf( |
| 929 |
GetNSISString(g_tmp, prefix) + mystrlen(g_tmp), |
| 930 |
#else |
| 931 |
GetNSISString(g_tmp, prefix); |
| 932 |
wsprintf( |
| 933 |
g_tmp + mystrlen(g_tmp), |
| 934 |
#endif |
| 935 |
_T("%u.%u%s%s"), |
| 936 |
intgr, fract, |
| 937 |
GetNSISString(scalestr, scale), |
| 938 |
GetNSISString(byte, LANG_BYTE) |
| 939 |
); |
| 940 |
|
| 941 |
my_SetDialogItemText(m_curwnd,dlgItem,g_tmp); |
| 942 |
} |
| 943 |
static void NSISCALL SetSizeText(int dlgItem, int prefix, unsigned kb) |
| 944 |
{ |
| 945 |
ULARGE_INTEGER kb64; |
| 946 |
kb64.QuadPart = kb; |
| 947 |
SetSizeText64(dlgItem, prefix, kb64); |
| 948 |
} |
| 949 |
|
| 950 |
static int NSISCALL _sumsecsfield(int idx) |
| 951 |
{ |
| 952 |
int total = 0; |
| 953 |
int x = num_sections; |
| 954 |
section *s = g_sections; |
| 955 |
while (x--) |
| 956 |
{ |
| 957 |
#ifdef NSIS_CONFIG_COMPONENTPAGE |
| 958 |
if (s->flags & SF_SELECTED) |
| 959 |
#endif |
| 960 |
total += ((int *)s)[idx]; |
| 961 |
s++; |
| 962 |
} |
| 963 |
return total; |
| 964 |
} |
| 965 |
|
| 966 |
#define sumsecsfield(x) _sumsecsfield(SECTION_OFFSET(x)) |
| 967 |
|
| 968 |
static INT_PTR CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 969 |
{ |
| 970 |
static int dontsetdefstyle; |
| 971 |
page *thispage = g_this_page; |
| 972 |
TCHAR *dir = g_usrvars[thispage->parms[4]]; |
| 973 |
int browse_text = thispage->parms[3]; |
| 974 |
|
| 975 |
if (uMsg == WM_NOTIFY_INIGO_MONTOYA) |
| 976 |
{ |
| 977 |
GetUIText(IDC_DIR,dir); |
| 978 |
validate_filename(dir); |
| 979 |
#ifdef NSIS_CONFIG_LOG |
| 980 |
#if !defined(NSIS_CONFIG_LOG_ODS) && !defined(NSIS_CONFIG_LOG_STDOUT) |
| 981 |
build_g_logfile(); |
| 982 |
#endif |
| 983 |
if (GetUIItem(IDC_CHECK1) != NULL) |
| 984 |
log_dolog = IsDlgButtonChecked(hwndDlg,IDC_CHECK1); |
| 985 |
#endif |
| 986 |
} |
| 987 |
if (uMsg == WM_INITDIALOG) |
| 988 |
{ |
| 989 |
HWND hDir = GetUIItem(IDC_DIR); |
| 990 |
|
| 991 |
#ifdef NSIS_CONFIG_LOG |
| 992 |
if (GetAsyncKeyState(VK_SHIFT)&0x8000) |
| 993 |
{ |
| 994 |
HWND h=GetUIItem(IDC_CHECK1); |
| 995 |
SetUITextFromLang(IDC_CHECK1,LANG_LOG_INSTALL_PROCESS); |
| 996 |
ShowWindow(h,SW_SHOWNA); |
| 997 |
} |
| 998 |
#endif |
| 999 |
if (validpathspec(dir) && !skip_root(dir)) |
| 1000 |
addtrailingslash(dir); |
| 1001 |
|
| 1002 |
// workaround for bug #1209843 |
| 1003 |
// |
| 1004 |
// m_curwnd is only updated once WM_INITDIALOG returns. |
| 1005 |
// my_SetWindowText triggers an EN_CHANGE message that |
| 1006 |
// triggers a WM_IN_UPDATEMSG message that uses m_curwnd |
| 1007 |
// to get the selected directory (GetUIText). |
| 1008 |
// because m_curwnd is still outdated, dir variable is |
| 1009 |
// filled with an empty string. by default, dir points |
| 1010 |
// to $INSTDIR. |
| 1011 |
// |
| 1012 |
// to solve this, m_curwnd is manually set to the correct |
| 1013 |
// window handle. |
| 1014 |
|
| 1015 |
m_curwnd=hwndDlg; |
| 1016 |
|
| 1017 |
my_SetWindowText(hDir,dir); |
| 1018 |
SetUITextFromLang(IDC_BROWSE,this_page->parms[2]); |
| 1019 |
SetUITextFromLang(IDC_SELDIRTEXT,this_page->parms[1]); |
| 1020 |
SetActiveCtl(hDir); |
| 1021 |
|
| 1022 |
{ |
| 1023 |
typedef HRESULT (WINAPI *SHAutoCompletePtr)(HWND, DWORD); |
| 1024 |
SHAutoCompletePtr fSHAutoComplete; |
| 1025 |
fSHAutoComplete = (SHAutoCompletePtr) myGetProcAddress(MGA_SHAutoComplete); |
| 1026 |
if (fSHAutoComplete) |
| 1027 |
{ |
| 1028 |
fSHAutoComplete(hDir, SHACF_FILESYSTEM); |
| 1029 |
} |
| 1030 |
} |
| 1031 |
} |
| 1032 |
if (uMsg == WM_COMMAND) |
| 1033 |
{ |
| 1034 |
int id=LOWORD(wParam); |
| 1035 |
if (id == IDC_DIR && HIWORD(wParam) == EN_CHANGE) |
| 1036 |
{ |
| 1037 |
uMsg = WM_IN_UPDATEMSG; |
| 1038 |
} |
| 1039 |
if (id == IDC_BROWSE) |
| 1040 |
{ |
| 1041 |
static TCHAR bt[NSIS_MAX_STRLEN]; |
| 1042 |
BROWSEINFO bi = {0,}; |
| 1043 |
LPITEMIDLIST idlist; |
| 1044 |
bi.hwndOwner = hwndDlg; |
| 1045 |
bi.pszDisplayName = g_tmp; |
| 1046 |
bi.lpfn = BrowseCallbackProc; |
| 1047 |
bi.lParam = (LPARAM)dir; |
| 1048 |
bi.lpszTitle = GetNSISString(bt, browse_text); |
| 1049 |
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; |
| 1050 |
idlist = SHBrowseForFolder(&bi); |
| 1051 |
if (idlist) |
| 1052 |
{ |
| 1053 |
// free idlist |
| 1054 |
CoTaskMemFree(idlist); |
| 1055 |
|
| 1056 |
addtrailingslash(dir); |
| 1057 |
|
| 1058 |
if (g_header->install_directory_auto_append && |
| 1059 |
dir == state_install_directory) // only append to $INSTDIR (bug #1174184) |
| 1060 |
{ |
| 1061 |
const TCHAR *post_str = ps_tmpbuf; |
| 1062 |
GetNSISStringTT(g_header->install_directory_auto_append); |
| 1063 |
// display name gives just the folder name |
| 1064 |
if (lstrcmpi(post_str, g_tmp)) |
| 1065 |
{ |
| 1066 |
mystrcat(dir, post_str); |
| 1067 |
} |
| 1068 |
} |
| 1069 |
|
| 1070 |
dontsetdefstyle++; |
| 1071 |
SetUITextNT(IDC_DIR,dir); |
| 1072 |
} |
| 1073 |
else |
| 1074 |
{ |
| 1075 |
uMsg = WM_IN_UPDATEMSG; |
| 1076 |
} |
| 1077 |
} |
| 1078 |
} |
| 1079 |
if (uMsg == WM_IN_UPDATEMSG || uMsg == WM_NOTIFY_START) |
| 1080 |
{ |
| 1081 |
static TCHAR s[NSIS_MAX_STRLEN]; |
| 1082 |
int error = 0; |
| 1083 |
UINT total, available_set = FALSE; |
| 1084 |
ULARGE_INTEGER available; |
| 1085 |
|
| 1086 |
GetUIText(IDC_DIR,dir); |
| 1087 |
if (!is_valid_instpath(dir)) |
| 1088 |
error = NSIS_INSTDIR_INVALID; |
| 1089 |
|
| 1090 |
/** |
| 1091 |
* This part is tricky. We need to make sure a few things: |
| 1092 |
* |
| 1093 |
* 1. GetDiskFreeSpaceEx is always called at least once for large HD. |
| 1094 |
* Even if skip_root() returned NULL (e.g. "C:"). |
| 1095 |
* Note that trimslashtoend() will nullify "C:". |
| 1096 |
* 2. GetDiskFreeSpaceEx is called with the deepest valid directory. |
| 1097 |
* e.g. C:\drive when the user types C:\drive\folder1\folder2. |
| 1098 |
* This makes sure NTFS mount points are treated properly (#1946112). |
| 1099 |
* 3. `s' stays valid after the loop for GetDiskFreeSpace. |
| 1100 |
* This means there is no cutting beyond what skip_root() returns. |
| 1101 |
* Or `s' could be recreated when GetDiskFreeSpace is called. |
| 1102 |
* 4. If GetDiskFreeSpaceEx doesn't exist, GetDiskFreeSpace is used. |
| 1103 |
* 5. Both functions require a trailing backslash |
| 1104 |
* 6. `dir' is never modified. |
| 1105 |
* |
| 1106 |
*/ |
| 1107 |
mystrcpy(s,dir); |
| 1108 |
|
| 1109 |
// Test for and use the GetDiskFreeSpaceEx API |
| 1110 |
{ |
| 1111 |
BOOL (WINAPI *GDFSE)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) = |
| 1112 |
#ifdef _WIN64 |
| 1113 |
GetDiskFreeSpaceEx; |
| 1114 |
#else |
| 1115 |
myGetProcAddress(MGA_GetDiskFreeSpaceEx); |
| 1116 |
if (GDFSE) |
| 1117 |
#endif |
| 1118 |
{ |
| 1119 |
ULARGE_INTEGER a, b; |
| 1120 |
TCHAR *p, *pw = NULL; |
| 1121 |
while (pw != s) // trimslashtoend() cut the entire string |
| 1122 |
{ |
| 1123 |
if (GDFSE(s, &available, &a, &b)) |
| 1124 |
{ |
| 1125 |
available.QuadPart = NRT_U64Shr32(available.QuadPart, 10); |
| 1126 |
available_set++; |
| 1127 |
break; |
| 1128 |
} |
| 1129 |
|
| 1130 |
if (pw) |
| 1131 |
// if pw was set, remove the backslash so trimslashtoend() will cut a new one |
| 1132 |
*pw = 0; |
| 1133 |
|
| 1134 |
p = trimslashtoend(s); // trim last backslash |
| 1135 |
// bring it back, but make the next char null |
| 1136 |
pw = p; |
| 1137 |
*pw = 0; |
| 1138 |
--pw; |
| 1139 |
*pw = _T('\\'); |
| 1140 |
} |
| 1141 |
} |
| 1142 |
} |
| 1143 |
#ifndef _WIN64 |
| 1144 |
if (!available_set) |
| 1145 |
{ |
| 1146 |
DWORD spc, bps, fc, tc; |
| 1147 |
TCHAR *root; |
| 1148 |
|
| 1149 |
// GetDiskFreeSpaceEx accepts any path, but GetDiskFreeSpace accepts only the root |
| 1150 |
mystrcpy(s,dir); |
| 1151 |
root=skip_root(s); |
| 1152 |
if (root) *root=0; |
| 1153 |
|
| 1154 |
// GetDiskFreeSpaceEx is not available |
| 1155 |
if (GetDiskFreeSpace(s, &spc, &bps, &fc, &tc)) |
| 1156 |
{ |
| 1157 |
available.QuadPart = (int)MulDiv(bps * spc, fc, 1 << 10); |
| 1158 |
available_set++; |
| 1159 |
} |
| 1160 |
} |
| 1161 |
#endif |
| 1162 |
total = (UINT) sumsecsfield(size_kb); |
| 1163 |
|
| 1164 |
if (available_set) |
| 1165 |
if (available.QuadPart < total) |
| 1166 |
error = NSIS_INSTDIR_NOT_ENOUGH_SPACE; |
| 1167 |
|
| 1168 |
if (LANG_STR_TAB(LANG_SPACE_REQ)) { |
| 1169 |
SetSizeText(IDC_SPACEREQUIRED,LANG_SPACE_REQ,total); |
| 1170 |
if (available_set) |
| 1171 |
SetSizeText64(IDC_SPACEAVAILABLE,LANG_SPACE_AVAIL,available); |
| 1172 |
else |
| 1173 |
SetUITextNT(IDC_SPACEAVAILABLE,_T("")); |
| 1174 |
} |
| 1175 |
|
| 1176 |
g_exec_flags.instdir_error = error; |
| 1177 |
|
| 1178 |
#ifdef NSIS_SUPPORT_CODECALLBACKS |
| 1179 |
if (!error) |
| 1180 |
error = ExecuteCallbackFunction(CB_ONVERIFYINSTDIR); |
| 1181 |
#endif |
| 1182 |
|
| 1183 |
if (thispage->flags & PF_DIR_NO_BTN_DISABLE) |
| 1184 |
error = 0; |
| 1185 |
|
| 1186 |
EnableNext(!error); |
| 1187 |
if (!error && !dontsetdefstyle) |
| 1188 |
SetNextDef(); |
| 1189 |
dontsetdefstyle = 0; |
| 1190 |
} |
| 1191 |
return HandleStaticBkColor(); |
| 1192 |
} |
| 1193 |
|
| 1194 |
#ifdef NSIS_CONFIG_COMPONENTPAGE |
| 1195 |
|
| 1196 |
static void FORCE_INLINE NSISCALL RefreshComponents(HWND hwTree, HTREEITEM *items) |
| 1197 |
{ |
| 1198 |
TVITEM item; |
| 1199 |
int i, flags, state; |
| 1200 |
section *sec; |
| 1201 |
|
| 1202 |
item.stateMask = TVIS_STATEIMAGEMASK | TVIS_EXPANDED | TVIS_BOLD; |
| 1203 |
|
| 1204 |
for (i = 0, sec = g_sections; i < num_sections; i++, sec++) |
| 1205 |
{ |
| 1206 |
if (!items[i]) |
| 1207 |
{ |
| 1208 |
continue; |
| 1209 |
} |
| 1210 |
|
| 1211 |
flags = sec->flags; |
| 1212 |
|
| 1213 |
item.hItem = items[i]; |
| 1214 |
|
| 1215 |
item.mask = TVIF_STATE; |
| 1216 |
|
| 1217 |
if (flags & SF_NAMECHG) |
| 1218 |
{ |
| 1219 |
item.mask |= TVIF_TEXT; |
| 1220 |
item.pszText = sec->name; |
| 1221 |
sec->flags &= ~SF_NAMECHG; |
| 1222 |
} |
| 1223 |
|
| 1224 |
if (flags & SF_PSELECTED) |
| 1225 |
{ |
| 1226 |
state = 3; |
| 1227 |
} |
| 1228 |
else |
| 1229 |
{ |
| 1230 |
state = 1 + (flags & SF_SELECTED); // SF_SELECTED == 1 |
| 1231 |
if (flags & SF_RO) state += 3; |
| 1232 |
} |
| 1233 |
|
| 1234 |
item.state = (flags & SF_BOLD) << 1; // (SF_BOLD << 1) == 16 == TVIS_BOLD |
| 1235 |
item.state |= flags & SF_EXPAND; // TVIS_EXPANDED == SF_EXPAND |
| 1236 |
item.state |= INDEXTOSTATEIMAGEMASK(state); |
| 1237 |
|
| 1238 |
// TVE_COLLAPSE = 1, TVE_EXPAND = 2 |
| 1239 |
TreeView_Expand(hwTree, item.hItem, TVE_COLLAPSE + ((flags & SF_EXPAND) / SF_EXPAND)); |
| 1240 |
|
| 1241 |
TreeView_SetItem(hwTree, &item); |
| 1242 |
} |
| 1243 |
|
| 1244 |
// workaround for bug #1397031 A.K.A #434 |
| 1245 |
// |
| 1246 |
// Windows 95 & NT4 doesn't erase the background of the state image |
| 1247 |
// before it draws a new one. Because of this parts of the old |
| 1248 |
// state image will show where the new state image is masked. |
| 1249 |
// |
| 1250 |
// To solve this, the following line forces the background to |
| 1251 |
// be erased. sadly, this redraws the entire control. It might |
| 1252 |
// be a good idea to figure out where the state images are and |
| 1253 |
// redraw only those. |
| 1254 |
|
| 1255 |
if (IsWin95NT4()) // Checking for < IE4 is probably better but more work |
| 1256 |
InvalidateRect(hwTree, NULL, TRUE); |
| 1257 |
} |
| 1258 |
|
| 1259 |
int NSISCALL TreeGetSelectedSection(HWND tree, BOOL mouse) |
| 1260 |
{ |
| 1261 |
HTREEITEM hItem = TreeView_GetSelection(tree); |
| 1262 |
TVITEM item; |
| 1263 |
|
| 1264 |
if (mouse) |
| 1265 |
{ |
| 1266 |
TVHITTESTINFO ht; |
| 1267 |
DWORD dwpos = GetMessagePos(); |
| 1268 |
|
| 1269 |
ht.pt.x = GET_X_LPARAM(dwpos); |
| 1270 |
ht.pt.y = GET_Y_LPARAM(dwpos); |
| 1271 |
ScreenToClient(tree, &ht.pt); |
| 1272 |
|
| 1273 |
{ |
| 1274 |
const HTREEITEM UNUSED hDummy1 = TreeView_HitTest(tree, &ht); |
| 1275 |
} |
| 1276 |
|
| 1277 |
#ifdef NSIS_CONFIG_COMPONENTPAGE_ALTERNATIVE |
| 1278 |
if (!(ht.flags & TVHT_ONITEMSTATEICON)) |
| 1279 |
#else |
| 1280 |
if (!(ht.flags & (TVHT_ONITEMSTATEICON|TVHT_ONITEMLABEL|TVHT_ONITEMRIGHT|TVHT_ONITEM))) |
| 1281 |
#endif |
| 1282 |
return -1; |
| 1283 |
|
| 1284 |
hItem = ht.hItem; |
| 1285 |
} |
| 1286 |
|
| 1287 |
item.mask = TVIF_PARAM; |
| 1288 |
item.hItem = hItem; |
| 1289 |
TreeView_GetItem(tree, &item); |
| 1290 |
|
| 1291 |
return (int) item.lParam; |
| 1292 |
} |
| 1293 |
|
| 1294 |
void NSISCALL ExecuteCallbackFunctionWithr0Int(int num,int r0) |
| 1295 |
{ |
| 1296 |
mystrcpy(g_tmp, g_usrvars[0]); |
| 1297 |
myitoa(g_usrvars[0], r0); |
| 1298 |
ExecuteCallbackFunction(num); |
| 1299 |
mystrcpy(g_usrvars[0], g_tmp); |
| 1300 |
} |
| 1301 |
|
| 1302 |
static WNDPROC oldTreeWndProc; |
| 1303 |
static LPARAM last_selected_tree_item; |
| 1304 |
static LRESULT CALLBACK newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1305 |
{ |
| 1306 |
if (uMsg == WM_CHAR && wParam == VK_SPACE) { |
| 1307 |
NotifyCurWnd(WM_TREEVIEW_KEYHACK); |
| 1308 |
return 0; |
| 1309 |
} |
| 1310 |
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT) |
| 1311 |
#ifndef NSIS_CONFIG_COMPONENTPAGE_ALTERNATIVE |
| 1312 |
if (uMsg == WM_MOUSEMOVE) { |
| 1313 |
if (IsWindowVisible(hwnd)) { |
| 1314 |
lParam = TreeGetSelectedSection(hwnd, TRUE); |
| 1315 |
uMsg = WM_NOTIFY_SELCHANGE; |
| 1316 |
} |
| 1317 |
} |
| 1318 |
#endif |
| 1319 |
if (uMsg == WM_NOTIFY_SELCHANGE) { |
| 1320 |
if (last_selected_tree_item != lParam) |
| 1321 |
{ |
| 1322 |
last_selected_tree_item = lParam; |
| 1323 |
ExecuteCallbackFunctionWithr0Int(CB_ONMOUSEOVERSECTION,(int)lParam); |
| 1324 |
} |
| 1325 |
} |
| 1326 |
#endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 1327 |
return CallWindowProc(oldTreeWndProc,hwnd,uMsg,wParam,lParam); |
| 1328 |
} |
| 1329 |
|
| 1330 |
static INT_PTR CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1331 |
{ |
| 1332 |
const int wParamSelChangeNotifyInstTypeChanged = -1; |
| 1333 |
static HTREEITEM *hTreeItems; |
| 1334 |
static HIMAGELIST hImageList; |
| 1335 |
HWND hwndCombo1 = GetUIItem(IDC_COMBO1); |
| 1336 |
HWND hwndTree1 = GetUIItem(IDC_TREE1); |
| 1337 |
extern HWND g_SectionHack;// TODO: Can we remove this? |
| 1338 |
section *sections=g_sections; |
| 1339 |
int *install_types=g_header->install_types; |
| 1340 |
if (uMsg == WM_INITDIALOG) |
| 1341 |
{ |
| 1342 |
int doLines=0; |
| 1343 |
HTREEITEM Par; |
| 1344 |
HBITMAP hBMcheck1; |
| 1345 |
int x, i, noCombo=2; |
| 1346 |
|
| 1347 |
g_SectionHack=hwndDlg; |
| 1348 |
|
| 1349 |
hTreeItems=(HTREEITEM*)GlobalAlloc(GPTR,sizeof(HTREEITEM)*num_sections); |
| 1350 |
|
| 1351 |
hBMcheck1=LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); // LR_CREATEDIBSECTION required to load TopDown bitmaps but that breaks modern.bmp |
| 1352 |
|
| 1353 |
last_selected_tree_item=-1; |
| 1354 |
oldTreeWndProc=(WNDPROC)SetWindowLongPtr(hwndTree1,GWLP_WNDPROC,(LONG_PTR)newTreeWndProc); |
| 1355 |
|
| 1356 |
hImageList = ImageList_Create(16,16, ILC_COLOR32|ILC_MASK, 6, 0); |
| 1357 |
ImageList_AddMasked(hImageList,hBMcheck1,RGB(255,0,255)); |
| 1358 |
|
| 1359 |
{ |
| 1360 |
const HIMAGELIST UNUSED hDummy1 = TreeView_SetImageList(hwndTree1, hImageList, TVSIL_STATE); |
| 1361 |
} |
| 1362 |
|
| 1363 |
if (TreeView_GetItemHeight(hwndTree1) < 16) |
| 1364 |
TreeView_SetItemHeight(hwndTree1, 16); |
| 1365 |
|
| 1366 |
DeleteObject(hBMcheck1); |
| 1367 |
|
| 1368 |
for (i = 0; i < NSIS_MAX_INST_TYPES+1; i++) |
| 1369 |
{ |
| 1370 |
if (install_types[i]) |
| 1371 |
{ |
| 1372 |
LRESULT j; |
| 1373 |
if (i != NSIS_MAX_INST_TYPES) noCombo = 0; |
| 1374 |
j=SendMessage(hwndCombo1,CB_ADDSTRING,0,(LPARAM)GetNSISStringTT(install_types[i])); |
| 1375 |
SendMessage(hwndCombo1,CB_SETITEMDATA,j,i); |
| 1376 |
} |
| 1377 |
} |
| 1378 |
|
| 1379 |
SetUITextFromLang(IDC_TEXT1,this_page->parms[1+noCombo]); |
| 1380 |
SetUITextFromLang(IDC_TEXT2,this_page->parms[2+noCombo]); |
| 1381 |
|
| 1382 |
Par=NULL; |
| 1383 |
|
| 1384 |
for (x = 0; x < num_sections; x ++) |
| 1385 |
{ |
| 1386 |
section *sec=sections+x; |
| 1387 |
|
| 1388 |
if (sec->name[0]) |
| 1389 |
{ |
| 1390 |
TVINSERTSTRUCT tv; |
| 1391 |
|
| 1392 |
tv.hParent = Par; |
| 1393 |
tv.hInsertAfter = TVI_LAST; |
| 1394 |
tv.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE; |
| 1395 |
tv.item.stateMask = TVIS_EXPANDED; |
| 1396 |
tv.item.lParam = x; |
| 1397 |
tv.item.pszText = sec->name; |
| 1398 |
|
| 1399 |
tv.item.state = sec->flags & SF_EXPAND; // TVIS_EXPANDED == SF_EXPAND |
| 1400 |
|
| 1401 |
if (sec->flags & SF_SECGRP) |
| 1402 |
{ |
| 1403 |
tv.item.mask |= TVIF_CHILDREN; |
| 1404 |
tv.item.cChildren = 1; |
| 1405 |
Par = hTreeItems[x] = TreeView_InsertItem(hwndTree1, &tv); |
| 1406 |
doLines = 1; |
| 1407 |
} |
| 1408 |
else if (sec->flags & SF_SECGRPEND) |
| 1409 |
{ |
| 1410 |
Par = TreeView_GetParent(hwndTree1, Par); |
| 1411 |
} |
| 1412 |
else |
| 1413 |
{ |
| 1414 |
hTreeItems[x] = TreeView_InsertItem(hwndTree1, &tv); |
| 1415 |
} |
| 1416 |
} |
| 1417 |
} |
| 1418 |
|
| 1419 |
if (!doLines) |
| 1420 |
{ |
| 1421 |
SetWindowLongPtr(hwndTree1,GWL_STYLE,GetWindowLongPtr(hwndTree1,GWL_STYLE)&~(TVS_LINESATROOT)); |
| 1422 |
} |
| 1423 |
|
| 1424 |
if (!noCombo) |
| 1425 |
{ |
| 1426 |
ShowWindow(hwndCombo1, SW_SHOW); |
| 1427 |
SetActiveCtl(hwndCombo1); |
| 1428 |
} |
| 1429 |
else |
| 1430 |
SetActiveCtl(hwndTree1); |
| 1431 |
} |
| 1432 |
|
| 1433 |
if (uMsg == WM_NOTIFY_START) |
| 1434 |
{ |
| 1435 |
wParam = 0; |
| 1436 |
lParam = 1; |
| 1437 |
uMsg = WM_IN_UPDATEMSG; |
| 1438 |
} |
| 1439 |
|
| 1440 |
if (uMsg == WM_NOTIFY || uMsg == WM_TREEVIEW_KEYHACK) |
| 1441 |
{ |
| 1442 |
LPNMHDR lpnmh = (LPNMHDR) lParam; |
| 1443 |
if (uMsg == WM_TREEVIEW_KEYHACK || lpnmh->idFrom == IDC_TREE1) |
| 1444 |
{ |
| 1445 |
if (!(g_flags&CH_FLAGS_NO_CUSTOM) && (uMsg == WM_TREEVIEW_KEYHACK || lpnmh->code == NM_CLICK)) |
| 1446 |
{ |
| 1447 |
int secid = TreeGetSelectedSection(hwndTree1, uMsg != WM_TREEVIEW_KEYHACK); |
| 1448 |
|
| 1449 |
if (secid >= 0) |
| 1450 |
{ |
| 1451 |
int flags = sections[secid].flags; |
| 1452 |
|
| 1453 |
if ((flags & SF_RO) == 0) |
| 1454 |
{ |
| 1455 |
if ((flags & SF_PSELECTED)) |
| 1456 |
{ |
| 1457 |
flags ^= SF_TOGGLED; |
| 1458 |
|
| 1459 |
if (flags & SF_TOGGLED) |
| 1460 |
{ |
| 1461 |
flags |= SF_SELECTED; |
| 1462 |
} |
| 1463 |
else |
| 1464 |
{ |
| 1465 |
flags &= ~SF_SELECTED; |
| 1466 |
} |
| 1467 |
} |
| 1468 |
else |
| 1469 |
{ |
| 1470 |
flags ^= SF_SELECTED; |
| 1471 |
} |
| 1472 |
|
| 1473 |
sections[secid].flags = flags; |
| 1474 |
|
| 1475 |
SectionFlagsChanged(secid); |
| 1476 |
|
| 1477 |
wParam = secid + 1; |
| 1478 |
lParam = !(g_flags & CH_FLAGS_COMP_ONLY_ON_CUSTOM); |
| 1479 |
uMsg = WM_IN_UPDATEMSG; |
| 1480 |
} |
| 1481 |
} // was valid click |
| 1482 |
} // was click or hack |
| 1483 |
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT) |
| 1484 |
if (lpnmh) |
| 1485 |
{ |
| 1486 |
if (lpnmh->code == TVN_SELCHANGED) |
| 1487 |
{ |
| 1488 |
SendMessage(hwndTree1, WM_NOTIFY_SELCHANGE, 0, ((LPNMTREEVIEW)lpnmh)->itemNew.lParam); |
| 1489 |
} |
| 1490 |
if (lpnmh->code == TVN_ITEMEXPANDED) |
| 1491 |
{ |
| 1492 |
LPNMTREEVIEW pnmtv = (LPNMTREEVIEW) lpnmh; |
| 1493 |
if (pnmtv->action == TVE_EXPAND) |
| 1494 |
sections[pnmtv->itemNew.lParam].flags |= SF_EXPAND; |
| 1495 |
else |
| 1496 |
sections[pnmtv->itemNew.lParam].flags &= ~SF_EXPAND; |
| 1497 |
} |
| 1498 |
} |
| 1499 |
#endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_ENHANCEDUI_SUPPORT |
| 1500 |
} |
| 1501 |
} |
| 1502 |
|
| 1503 |
if (uMsg == WM_COMMAND && LOWORD(wParam) == IDC_COMBO1 && HIWORD(wParam) == CBN_SELCHANGE) |
| 1504 |
{ |
| 1505 |
LRESULT t = SendMessage(hwndCombo1,CB_GETCURSEL,0,0); |
| 1506 |
if (t != CB_ERR) |
| 1507 |
{ |
| 1508 |
int whichcfg = (int) SendMessage(hwndCombo1, CB_GETITEMDATA, t, 0); |
| 1509 |
|
| 1510 |
if (whichcfg == CB_ERR || !install_types[whichcfg]) |
| 1511 |
whichcfg = NSIS_MAX_INST_TYPES; |
| 1512 |
|
| 1513 |
SetInstType(whichcfg); |
| 1514 |
|
| 1515 |
SendMessage(hwndDlg, WM_NOTIFY_INSTTYPE_CHANGED, 0, whichcfg); |
| 1516 |
|
| 1517 |
wParam = wParamSelChangeNotifyInstTypeChanged; |
| 1518 |
lParam = 0; |
| 1519 |
uMsg = WM_IN_UPDATEMSG; |
| 1520 |
} |
| 1521 |
} |
| 1522 |
|
| 1523 |
if (uMsg == WM_MOUSEMOVE) |
| 1524 |
{ |
| 1525 |
SendMessage(hwndTree1, WM_MOUSEMOVE, 0, 0); |
| 1526 |
} |
| 1527 |
|
| 1528 |
if (uMsg == WM_NOTIFY_INIGO_MONTOYA) |
| 1529 |
{ |
| 1530 |
if (hImageList) ImageList_Destroy(hImageList); |
| 1531 |
if (hTreeItems) GlobalFree(hTreeItems); |
| 1532 |
hImageList = NULL; |
| 1533 |
hTreeItems = NULL; |
| 1534 |
g_SectionHack = NULL; |
| 1535 |
} |
| 1536 |
|
| 1537 |
if (uMsg == WM_IN_UPDATEMSG) |
| 1538 |
{ |
| 1539 |
RefreshSectionGroups(); |
| 1540 |
|
| 1541 |
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_COMPONENTPAGE) |
| 1542 |
if (wParam != 0) |
| 1543 |
{ |
| 1544 |
int secid = (int) wParam; |
| 1545 |
if (wParamSelChangeNotifyInstTypeChanged != secid) --secid; |
| 1546 |
ExecuteCallbackFunctionWithr0Int(CB_ONSELCHANGE,secid); |
| 1547 |
} |
| 1548 |
#endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_COMPONENTPAGE |
| 1549 |
|
| 1550 |
if (lParam) |
| 1551 |
{ |
| 1552 |
int i, cbi; |
| 1553 |
int inst_type = GetInstType(hTreeItems); |
| 1554 |
SetInstType(inst_type); |
| 1555 |
|
| 1556 |
for (i = 0, cbi = 0; i < inst_type; i++) |
| 1557 |
{ |
| 1558 |
if (install_types[i]) |
| 1559 |
{ |
| 1560 |
cbi++; |
| 1561 |
} |
| 1562 |
} |
| 1563 |
|
| 1564 |
SendMessage(hwndCombo1, CB_SETCURSEL, cbi, 0); |
| 1565 |
|
| 1566 |
lParam = inst_type; |
| 1567 |
uMsg = WM_NOTIFY_INSTTYPE_CHANGED; |
| 1568 |
} |
| 1569 |
|
| 1570 |
RefreshSectionGroups(); |
| 1571 |
RefreshComponents(hwndTree1, hTreeItems); |
| 1572 |
|
| 1573 |
if (LANG_STR_TAB(LANG_SPACE_REQ)) { |
| 1574 |
SetSizeText(IDC_SPACEREQUIRED,LANG_SPACE_REQ,sumsecsfield(size_kb)); |
| 1575 |
} |
| 1576 |
} |
| 1577 |
|
| 1578 |
if (uMsg == WM_NOTIFY_INSTTYPE_CHANGED) |
| 1579 |
{ |
| 1580 |
if (g_flags & CH_FLAGS_COMP_ONLY_ON_CUSTOM) |
| 1581 |
{ |
| 1582 |
int c = (lParam == NSIS_MAX_INST_TYPES ? 1 : 0) << 3;// SW_SHOWNA=8, SW_HIDE=0 |
| 1583 |
ShowWindow(hwndTree1, c); |
| 1584 |
ShowWindow(GetUIItem(IDC_TEXT2), c); |
| 1585 |
} |
| 1586 |
} |
| 1587 |
|
| 1588 |
return HandleStaticBkColor(); |
| 1589 |
} |
| 1590 |
#endif//NSIS_CONFIG_COMPONENTPAGE |
| 1591 |
|
| 1592 |
#endif//NSIS_CONFIG_VISIBLE_SUPPORT |
| 1593 |
|
| 1594 |
void NSISCALL update_status_text(int strtab, const TCHAR *text) { |
| 1595 |
static TCHAR tmp[NSIS_MAX_STRLEN*2]; |
| 1596 |
LVITEM new_item; |
| 1597 |
HWND linsthwnd = insthwnd; |
| 1598 |
if (linsthwnd) |
| 1599 |
{ |
| 1600 |
int updateflag = g_exec_flags.status_update; |
| 1601 |
int tmplen; |
| 1602 |
|
| 1603 |
if (!(updateflag & 1)) |
| 1604 |
GetNSISString(tmp, strtab); |
| 1605 |
|
| 1606 |
tmplen = mystrlen(tmp); |
| 1607 |
|
| 1608 |
if (text) |
| 1609 |
{ |
| 1610 |
if (tmplen + mystrlen(text) >= sizeof(tmp)) return; |
| 1611 |
mystrcat(tmp, text); |
| 1612 |
} |
| 1613 |
|
| 1614 |
if ((updateflag & 4) == 0) my_SetWindowText(insthwnd2, tmp); |
| 1615 |
if ((updateflag & 2) == 0) |
| 1616 |
{ |
| 1617 |
new_item.mask = LVIF_TEXT; |
| 1618 |
new_item.pszText = tmp; |
| 1619 |
new_item.iItem = ListView_GetItemCount(linsthwnd) - (updateflag & 1); |
| 1620 |
new_item.iSubItem = 0; |
| 1621 |
// LVM_INSERTITEM - LVM_SETITEM = 1 |
| 1622 |
SendMessage(linsthwnd, LVM_INSERTITEM - (updateflag & 1), 0, (LPARAM) &new_item); |
| 1623 |
ListView_EnsureVisible(linsthwnd, new_item.iItem, 0); |
| 1624 |
} |
| 1625 |
|
| 1626 |
if (updateflag & 1) |
| 1627 |
tmp[tmplen] = 0; |
| 1628 |
} |
| 1629 |
} |
| 1630 |
|
| 1631 |
static DWORD WINAPI install_thread(LPVOID p) |
| 1632 |
{ |
| 1633 |
int m_inst_sec=num_sections; |
| 1634 |
HWND progresswnd = (HWND)p; |
| 1635 |
section *s = g_sections; |
| 1636 |
|
| 1637 |
#if defined(NSIS_SUPPORT_ACTIVEXREG) || defined(NSIS_SUPPORT_CREATESHORTCUT) |
| 1638 |
{ |
| 1639 |
extern HRESULT g_hres; |
| 1640 |
g_hres|=OleInitialize(NULL); |
| 1641 |
} |
| 1642 |
#endif |
| 1643 |
|
| 1644 |
// workaround for bug #1400995 |
| 1645 |
// |
| 1646 |
// for an unexplained reason, MessageBox with MB_TOPMOST |
| 1647 |
// will fail, if no other messages were sent from this |
| 1648 |
// thread to the GUI thread before it. |
| 1649 |
// |
| 1650 |
// the source of the problem couldn't be found, so a |
| 1651 |
// WM_NULL is sent to work around it. |
| 1652 |
|
| 1653 |
NotifyCurWnd(WM_NULL); |
| 1654 |
|
| 1655 |
while (m_inst_sec--) |
| 1656 |
{ |
| 1657 |
#ifdef NSIS_CONFIG_COMPONENTPAGE |
| 1658 |
if (s->flags&SF_SELECTED) |
| 1659 |
#endif |
| 1660 |
{ |
| 1661 |
log_printf2(_T("Section: \"%s\""),s->name); |
| 1662 |
if (ExecuteCodeSegment(s->code,progresswnd)) |
| 1663 |
{ |
| 1664 |
g_exec_flags.abort++; |
| 1665 |
break; |
| 1666 |
} |
| 1667 |
} |
| 1668 |
#ifdef NSIS_CONFIG_COMPONENTPAGE |
| 1669 |
else |
| 1670 |
{ |
| 1671 |
log_printf2(_T("Skipping section: \"%s\""),s->name); |
| 1672 |
} |
| 1673 |
#endif |
| 1674 |
s++; |
| 1675 |
} |
| 1676 |
NotifyCurWnd(WM_NOTIFY_INSTPROC_DONE); |
| 1677 |
|
| 1678 |
#if defined(NSIS_SUPPORT_ACTIVEXREG) || defined(NSIS_SUPPORT_CREATESHORTCUT) |
| 1679 |
OleUninitialize(); |
| 1680 |
#endif |
| 1681 |
|
| 1682 |
return g_exec_flags.abort; |
| 1683 |
} |
| 1684 |
|
| 1685 |
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT |
| 1686 |
|
| 1687 |
static INT_PTR CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1688 |
{ |
| 1689 |
HWND linsthwnd=insthwnd; |
| 1690 |
if (uMsg == WM_INITDIALOG) |
| 1691 |
{ |
| 1692 |
RECT r; |
| 1693 |
LVCOLUMN lvc = {LVCF_WIDTH, 0, -1, 0, 0, -1}; |
| 1694 |
int lb_bg=g_header->lb_bg,lb_fg=g_header->lb_fg; |
| 1695 |
|
| 1696 |
insthwndbutton=GetUIItem(IDC_SHOWDETAILS); |
| 1697 |
insthwnd2=GetUIItem(IDC_INTROTEXT); |
| 1698 |
linsthwnd=insthwnd=GetUIItem(IDC_LIST1); |
| 1699 |
|
| 1700 |
SetActiveCtl(insthwndbutton); |
| 1701 |
|
| 1702 |
progress_bar_len=sumsecsfield(code_size); |
| 1703 |
progress_bar_pos=0; |
| 1704 |
|
| 1705 |
log_printf3(_T("New install of \"%s\" to \"%s\""),GetNSISStringTT(LANG_NAME),state_install_directory); |
| 1706 |
|
| 1707 |
GetClientRect(linsthwnd, &r); |
| 1708 |
lvc.cx = r.right - GetSystemMetrics(SM_CXVSCROLL); |
| 1709 |
ListView_InsertColumn(linsthwnd, 0, &lvc); |
| 1710 |
|
| 1711 |
ListView_SetExtendedListViewStyleEx(linsthwnd, LVS_EX_LABELTIP, LVS_EX_LABELTIP); |
| 1712 |
if (lb_bg >= 0) { |
| 1713 |
ListView_SetBkColor(linsthwnd, lb_bg); |
| 1714 |
ListView_SetTextBkColor(linsthwnd, lb_bg); |
| 1715 |
} |
| 1716 |
if (lb_fg >= 0) { |
| 1717 |
ListView_SetTextColor(linsthwnd, lb_fg); |
| 1718 |
} |
| 1719 |
SetUITextFromLang(IDC_SHOWDETAILS,this_page->parms[1]); |
| 1720 |
if (g_flags&(CH_FLAGS_DETAILS_SHOWDETAILS|CH_FLAGS_DETAILS_NEVERSHOW)) |
| 1721 |
{ |
| 1722 |
ShowWindow(insthwndbutton,SW_HIDE); |
| 1723 |
if (!(g_flags&CH_FLAGS_DETAILS_NEVERSHOW)) ShowWindow(linsthwnd,SW_SHOWNA); |
| 1724 |
else insthwndbutton=NULL; |
| 1725 |
SetActiveCtl(insthwnd2); |
| 1726 |
} |
| 1727 |
|
| 1728 |
{ |
| 1729 |
HWND progresswnd=GetUIItem(IDC_PROGRESS); |
| 1730 |
SendMessage(progresswnd,PBM_SETRANGE,0,MAKELPARAM(0,30000)); |
| 1731 |
if (g_flags&CH_FLAGS_PROGRESS_COLORED) |
| 1732 |
{ |
| 1733 |
SendMessage(progresswnd,PBM_SETBARCOLOR,0,lb_fg); |
| 1734 |
SendMessage(progresswnd,PBM_SETBKCOLOR,0,lb_bg); |
| 1735 |
} |
| 1736 |
} |
| 1737 |
|
| 1738 |
return FALSE; |
| 1739 |
} |
| 1740 |
if (uMsg == WM_NOTIFY_START) { |
| 1741 |
DWORD id; |
| 1742 |
CloseHandle(CreateThread(NULL,0,install_thread,GetUIItem(IDC_PROGRESS),0,&id)); |
| 1743 |
} |
| 1744 |
if (uMsg == WM_COMMAND && LOWORD(wParam) == IDC_SHOWDETAILS) |
| 1745 |
{ |
| 1746 |
ShowWindow(insthwndbutton,SW_HIDE); |
| 1747 |
ShowWindow(linsthwnd,SW_SHOWNA); |
| 1748 |
SetActiveCtl(linsthwnd); |
| 1749 |
} |
| 1750 |
if (uMsg == WM_NOTIFY_INSTPROC_DONE) |
| 1751 |
{ |
| 1752 |
if (g_quit_flag) |
| 1753 |
{ |
| 1754 |
m_retcode=2; |
| 1755 |
outernotify(NOTIFY_BYE_BYE); |
| 1756 |
} |
| 1757 |
else |
| 1758 |
{ |
| 1759 |
ShowWindow(g_hwnd,SW_SHOWNA); |
| 1760 |
if (!g_exec_flags.abort) |
| 1761 |
update_status_text(g_this_page->parms[2],0); |
| 1762 |
outernotify(1); |
| 1763 |
} |
| 1764 |
} |
| 1765 |
//>>>Ximon Eighteen aka Sunjammer 30th August 2002 |
| 1766 |
//+++Popup "Copy Details To Clipboard" menu when RMB clicked in DetailView |
| 1767 |
if (uMsg == WM_CONTEXTMENU && wParam == (WPARAM) linsthwnd) |
| 1768 |
{ |
| 1769 |
int count = ListView_GetItemCount(linsthwnd); |
| 1770 |
if (count > 0) |
| 1771 |
{ |
| 1772 |
HMENU menu = CreatePopupMenu(); |
| 1773 |
POINT pt; |
| 1774 |
AppendMenu(menu,MF_STRING,1,GetNSISStringTT(LANG_COPYDETAILS)); |
| 1775 |
pt.x = GET_X_LPARAM(lParam), pt.y = GET_Y_LPARAM(lParam); |
| 1776 |
if (lParam == (LPARAM)((INT_PTR)-1)) |
| 1777 |
{ |
| 1778 |
RECT r; |
| 1779 |
GetWindowRect(linsthwnd,&r); |
| 1780 |
pt.x = r.left, pt.y = r.top; |
| 1781 |
} |
| 1782 |
if (1==TrackPopupMenu(menu,TPM_NONOTIFY|TPM_RETURNCMD,pt.x,pt.y,0,hwndDlg,0)) |
| 1783 |
{ |
| 1784 |
int i,total = 1; // 1 for the null char |
| 1785 |
LVITEM item; |
| 1786 |
HGLOBAL memory; |
| 1787 |
LPTSTR ptr;//,endPtr; |
| 1788 |
|
| 1789 |
// 1st pass - determine clipboard memory required. |
| 1790 |
item.iSubItem = 0; |
| 1791 |
item.pszText = g_tmp; |
| 1792 |
item.cchTextMax = COUNTOF(g_tmp); |
| 1793 |
i = count; |
| 1794 |
while (i--) |
| 1795 |
// Add 2 for the CR/LF combination that must follow every line. |
| 1796 |
total += 2+(int)SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item); |
| 1797 |
|
| 1798 |
// 2nd pass - store detail view strings on the clipboard |
| 1799 |
// Clipboard MSDN docs say mem must be GMEM_MOVEABLE |
| 1800 |
OpenClipboard(0); |
| 1801 |
EmptyClipboard(); |
| 1802 |
memory = GlobalAlloc(GHND,total*sizeof(TCHAR)); |
| 1803 |
ptr = GlobalLock(memory); |
| 1804 |
//endPtr = ptr+total-2; // -2 to allow for CR/LF |
| 1805 |
i = 0; |
| 1806 |
do { |
| 1807 |
item.pszText = ptr; |
| 1808 |
ptr += SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item); |
| 1809 |
*ptr++ = _T('\r'); |
| 1810 |
*ptr++ = _T('\n'); |
| 1811 |
} while (++i < count); |
| 1812 |
// memory is auto zeroed when allocated with GHND - *ptr = 0; |
| 1813 |
GlobalUnlock(memory); |
| 1814 |
#ifdef _UNICODE |
| 1815 |
SetClipboardData(CF_UNICODETEXT,memory); |
| 1816 |
#else |
| 1817 |
SetClipboardData(CF_TEXT,memory); |
| 1818 |
#endif |
| 1819 |
CloseClipboard(); |
| 1820 |
} |
| 1821 |
} |
| 1822 |
return FALSE; |
| 1823 |
} |
| 1824 |
//<<< |
| 1825 |
return HandleStaticBkColor(); |
| 1826 |
} |
| 1827 |
#endif//NSIS_CONFIG_VISIBLE_SUPPORT |