LoadAndSetImage can return the image handle
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7179 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
52da4576ba
commit
e73d05f1f5
7 changed files with 31 additions and 24 deletions
|
@ -61,7 +61,7 @@
|
|||
// 5000..5999 Important generic warnings
|
||||
// 6000..6999 Script warnings
|
||||
// 7000..7499 Recovered from bad input etc. warnings
|
||||
// 7500..7999 Discouraged usage warnings (allocated top to bottom to reserve as much space as possible for more bad input codes)
|
||||
// 7500..7999 Discouraged usage warnings (allocated high to low to reserve as much space as possible for more bad input codes)
|
||||
// 8000..8999 Generic warnings
|
||||
// 9000..9999 Breaking our and/or MS guidelines warnings
|
||||
typedef enum {
|
||||
|
@ -107,6 +107,7 @@ typedef enum {
|
|||
DW_LICENSE_EMPTY = 7050,
|
||||
DW_ATTRIBUTE_OVERLONGSTRING = 7060,
|
||||
DW_PARSE_BADNUMBER = 7070,
|
||||
DW_PARSE_NUMBEROUTOFSPEC = 7071,
|
||||
DW_PARSE_LNK_HK = 7075,
|
||||
DW_GENERIC_DEPRECATED = 7998,
|
||||
DW_PARSE_REGPATHPREFIX = 7999,
|
||||
|
|
|
@ -843,14 +843,15 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
case EW_LOADANDSETIMAGE:
|
||||
{
|
||||
RECT r;
|
||||
HANDLE hImage;
|
||||
HWND hCtl=(parm2 & LASIF_HWND) ? GetHwndFromParm(1) : GetDlgItem(g_hwnd, parm1);
|
||||
UINT it=parm2 & LASIM_IMAGE, exeres=parm2 & LASIF_EXERES, fitw=(UINT)parm2 >> LASIS_FITCTLW, fith=(parm2 & LASIF_FITCTLH) != 0;
|
||||
LPCTSTR imgname = (parm2 & LASIF_STRID) ? GetStringFromParm(0x00) : MAKEINTRESOURCE(parm0);
|
||||
HANDLE hNewImage, hPrevImage;
|
||||
HWND hCtl=(parm3 & LASIF_HWND) ? GetHwndFromParm(2) : GetDlgItem(g_hwnd, parm2);
|
||||
UINT it=parm3 & LASIM_IMAGE, exeres=parm3 & LASIF_EXERES, fitw=(UINT)parm3 >> LASIS_FITCTLW, fith=(parm3 & LASIF_FITCTLH) != 0;
|
||||
LPCTSTR imgid = (parm3 & LASIF_STRID) ? GetStringFromParm(0x11) : MAKEINTRESOURCE(parm1);
|
||||
GetClientRect(hCtl, &r);
|
||||
hImage=LoadImage(exeres ? g_hInstance : NULL, imgname, it, fitw*r.right, fith*r.bottom, parm2 & LASIM_LR);
|
||||
hImage=(HANDLE)SendMessage(hCtl, STM_SETIMAGE, it, (LPARAM)hImage);
|
||||
if (hImage && IMAGE_BITMAP == it) DeleteObject(hImage); // Delete the old image
|
||||
hNewImage=LoadImage(exeres ? g_hInstance : NULL, imgid, it, fitw*r.right, fith*r.bottom, parm3 & LASIM_LR);
|
||||
hPrevImage=(HANDLE)SendMessage(hCtl, STM_SETIMAGE, it, (LPARAM)hNewImage);
|
||||
if (hPrevImage && IMAGE_BITMAP == it) DeleteObject(hPrevImage); // Delete the old bitmap
|
||||
if (parm0 >=0) iptrtostr(var0, (INT_PTR)hNewImage); // Optional output handle
|
||||
}
|
||||
break;
|
||||
case EW_CREATEFONT:
|
||||
|
|
|
@ -112,7 +112,7 @@ enum
|
|||
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
||||
EW_GETDLGITEM, // GetDlgItem: 3: [outputvar, dialog, item_id]
|
||||
EW_SETCTLCOLORS, // SerCtlColors: 3: [hwnd, pointer to struct colors]
|
||||
EW_LOADANDSETIMAGE, // SetBrandingImage/LoadAndSetImage: 3: [imgid ctl flags]
|
||||
EW_LOADANDSETIMAGE, // SetBrandingImage/LoadAndSetImage: 5: [ctrl imagetype lrflags imageid [output]]
|
||||
EW_CREATEFONT, // CreateFont: 5: [handle output, face name, height, weight, flags]
|
||||
EW_SHOWWINDOW, // ShowWindow: 2: [hwnd, show state]
|
||||
#endif
|
||||
|
|
|
@ -4913,10 +4913,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
return add_entry(&ent);
|
||||
case TOK_LOADANDSETIMAGE:
|
||||
{
|
||||
SCRIPT_MSG(_T("LoadAndSetImage: "));
|
||||
ent.which=EW_LOADANDSETIMAGE;
|
||||
int tidx = 1, conv = 1, fail = 0;
|
||||
unsigned int flags = LASIF_HWND;
|
||||
unsigned int flags = LASIF_HWND, lrflagsin;
|
||||
for (; tidx < line.getnumtokens(); tidx++)
|
||||
{
|
||||
if (!_tcsicmp(line.gettoken_str(tidx),_T("/EXERESOURCE"))) flags |= LASIF_EXERES;
|
||||
|
@ -4927,12 +4926,16 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/GETDLGITEM"))) flags &= ~LASIF_HWND; // Reuses TOK_SETBRANDINGIMAGE functionality
|
||||
else { if (line.gettoken_str(tidx)[0] == '/') ++fail; break; }
|
||||
}
|
||||
ent.offsets[1]=(flags & LASIF_HWND) ? add_string(line.gettoken_str(tidx+0)) : line.gettoken_int(tidx+0, &conv); fail += !conv; // HWND/CtrlId
|
||||
flags |= (line.gettoken_int(tidx+1, &conv) & LASIM_IMAGE); fail += !conv;
|
||||
flags |= (line.gettoken_int(tidx+2, &conv) & LASIM_LR); fail += !conv;
|
||||
ent.offsets[0]=(flags & LASIF_STRID) ? add_string(line.gettoken_str(tidx+3)) : line.gettoken_int(tidx+3, &conv); fail += !conv; // Image path/resid
|
||||
ent.offsets[2]=flags;
|
||||
SCRIPT_MSG(_T("%") NPRIs _T(" %#x \"%") NPRIs _T("\" \n"), line.gettoken_str(tidx+0), flags, line.gettoken_str(tidx+3));
|
||||
ent.offsets[2] = (flags & LASIF_HWND) ? add_string(line.gettoken_str(tidx+0)) : line.gettoken_int(tidx+0, &conv); fail |= !conv; // HWND/CtrlId
|
||||
flags |= (line.gettoken_int(tidx+1, &conv) & LASIM_IMAGE); fail |= !conv; // IMAGE_*
|
||||
flags |= ((lrflagsin = line.gettoken_int(tidx+2, &conv)) & LASIM_LR); fail |= !conv; // LR_*
|
||||
ent.offsets[1] = (flags & LASIF_STRID) ? add_string(line.gettoken_str(tidx+3)) : line.gettoken_int(tidx+3, &conv); fail |= !conv; // Image path/resid
|
||||
ent.offsets[3] = flags; // Packed flags, IMAGE_* and LR_*
|
||||
ent.offsets[0] = GetUserVarIndex(line, tidx+4); // Outvar
|
||||
SCRIPT_MSG(_T("LoadAndSetImage %") NPRIs _T(" %#x \"%") NPRIs _T("\""), line.gettoken_str(tidx+0), flags, line.gettoken_str(tidx+3));
|
||||
if (ent.offsets[0] >= 0) SCRIPT_MSG(_T(" -> %") NPRIs _T(""), line.gettoken_str(tidx+4));
|
||||
SCRIPT_MSG(_T("\n"));
|
||||
if ((lrflagsin & LASIM_LR) != lrflagsin) warning_fl(DW_PARSE_NUMBEROUTOFSPEC, _T("Out of spec: \"%") NPRIs _T("\""), line.gettoken_str(tidx+2));
|
||||
if (fail) PRINTHELP();
|
||||
}
|
||||
return add_entry(&ent);
|
||||
|
@ -4941,7 +4944,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
case TOK_LOADANDSETIMAGE:
|
||||
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_ENHANCEDUI_SUPPORT not defined.\n"),line.gettoken_str(0));
|
||||
return PS_ERROR;
|
||||
#endif //~ NSIS_SUPPORT_CREATEFONT
|
||||
#endif //~ NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
||||
case TOK_DEFVAR:
|
||||
{
|
||||
int a=1;
|
||||
|
|
|
@ -196,7 +196,7 @@ static tokenType tokenlist[TOK__LAST] =
|
|||
{TOK_SETAUTOCLOSE,_T("SetAutoClose"),1,0,_T("(false|true)"),TP_CODE},
|
||||
{TOK_SETCTLCOLORS,_T("SetCtlColors"),2,2,_T("hwnd [/BRANDING] [text_color] [transparent|bg_color]"),TP_CODE},
|
||||
{TOK_SETBRANDINGIMAGE,_T("SetBrandingImage"),1,2,_T("[/IMGID=image_item_id_in_dialog] [/RESIZETOFIT] bitmap.bmp"),TP_CODE},
|
||||
{TOK_LOADANDSETIMAGE,_T("LoadAndSetImage"),4,4,_T("[/EXERESOURCE] [/STRINGID] [/RESIZETOFIT[WIDTH|HEIGHT]] ctrl imagetype lrflags image"),TP_CODE},
|
||||
{TOK_LOADANDSETIMAGE,_T("LoadAndSetImage"),4,5,_T("[/EXERESOURCE] [/STRINGID] [/RESIZETOFIT[WIDTH|HEIGHT]] ctrl imagetype lrflags imageid [$(user_var: imagehandle)]"),TP_CODE},
|
||||
{TOK_SETCOMPRESS,_T("SetCompress"),1,0,_T("(off|auto|force)"),TP_ALL},
|
||||
{TOK_SETCOMPRESSOR,_T("SetCompressor"),1,2,_T("[/FINAL] [/SOLID] (zlib|bzip2|lzma)"),TP_GLOBAL},
|
||||
{TOK_SETCOMPRESSORDICTSIZE,_T("SetCompressorDictSize"),1,0,_T("dict_size_mb"),TP_ALL},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue