From 5a9bbbb021a4e3617bd73360747f24f09f01aac1 Mon Sep 17 00:00:00 2001 From: anders_k Date: Sat, 24 Jan 2009 22:09:31 +0000 Subject: [PATCH] applied patch #2500960 - NSD_SetIcon support git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5908 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/nsDialogs/Readme.html | 31 ++++++++++++++++++++- Contrib/nsDialogs/nsDialogs.nsh | 48 ++++++++++++++++++++++++++------- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/Contrib/nsDialogs/Readme.html b/Contrib/nsDialogs/Readme.html index bc5da664..670334b2 100644 --- a/Contrib/nsDialogs/Readme.html +++ b/Contrib/nsDialogs/Readme.html @@ -87,8 +87,12 @@ code
  • NSD_SetFocus
  • NSD_SetImage
  • NSD_SetStretchedImage
  • +
  • NSD_SetIcon
  • +
  • NSD_SetIconFromInstaller
  • NSD_ClearImage
  • +
  • NSD_ClearIcon
  • NSD_FreeImage
  • +
  • NSD_FreeIcon
  • FAQ
  • @@ -862,18 +866,43 @@ SectionEnd

    Loads and displays a bitmap just like ${NSD_SetImage}, but stretched the image to fit the control.

    +

    NSD_SetIcon

    + +

    ${NSD_SetIcon} control_HWND image_path output_variable

    + +

    Same as ${NSD_SetImage}, but used for loading and setting an icon in a control created by ${NSD_CreateIcon}. The image handle is stored in output_variable and should be freed using ${NSD_FreeIcon} once no longer necessary.

    + +

    NSD_SetIconFromInstaller

    + +

    ${NSD_SetIconFromInstaller} control_HWND output_variable

    + +

    Loads the icon used in the isntaller and displays it on control_HWND created by ${NSD_CreateIcon}. The image handle is stored in output_variable and should be freed using ${NSD_FreeIcon} once no longer necessary.

    +

    NSD_ClearImage

    ${NSD_ClearImage} control_HWND

    Clears an image from a control.

    +

    NSD_ClearIcon

    + +

    ${NSD_ClearIcon} control_HWND

    + +

    Clears an icon from a control.

    +

    NSD_FreeImage

    ${NSD_FreeImage} image_handle

    Frees an image handle previously loaded with ${NSD_SetImage} or ${NSD_SetStretchedImage}.

    +

    NSD_FreeIcon

    + +

    ${NSD_FreeIcon} icon_handle

    + +

    Frees an icon handle previously loaded with ${NSD_SetIcon} or ${NSD_SetIconFromInstaller}.

    + +

    FAQ

    @@ -892,4 +921,4 @@ SectionEnd
    - \ No newline at end of file + diff --git a/Contrib/nsDialogs/nsDialogs.nsh b/Contrib/nsDialogs/nsDialogs.nsh index efdca975..dc68d859 100644 --- a/Contrib/nsDialogs/nsDialogs.nsh +++ b/Contrib/nsDialogs/nsDialogs.nsh @@ -510,16 +510,21 @@ Header file for creating custom installer pages with nsDialogs !define NSD_LB_GetSelection `!insertmacro __NSD_LB_GetSelection` -!macro __NSD_SetImage CONTROL IMAGE HANDLE - +!macro __NSD_LoadAndSetImage _LIHINSTMODE _IMGTYPE _LIHINSTSRC _LIFLAGS CONTROL IMAGE HANDLE + Push $0 Push $R0 StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0 - - System::Call 'user32::LoadImage(i0, ts, i ${IMAGE_BITMAP}, i0, i0, i${LR_LOADFROMFILE}) i.s' "${IMAGE}" - Pop $0 - SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0 + + !if "${_LIHINSTMODE}" == "exeresource" + System::Call 'kernel32::GetModuleHandle(i0) i.r0' + !undef _LIHINSTSRC + !define _LIHINSTSRC r0 + !endif + + System::Call 'user32::LoadImage(i ${_LIHINSTSRC}, ts, i ${_IMGTYPE}, i0, i0, i${_LIFLAGS}) i.r0' "${IMAGE}" + SendMessage $R0 ${STM_SETIMAGE} ${_IMGTYPE} $0 Pop $R0 Exch $0 @@ -528,7 +533,21 @@ Header file for creating custom installer pages with nsDialogs !macroend -!define NSD_SetImage `!insertmacro __NSD_SetImage` +!macro __NSD_SetIconFromExeResource CONTROL IMAGE HANDLE + !insertmacro __NSD_LoadAndSetImage exeresource ${IMAGE_ICON} 0 ${LR_DEFAULTSIZE} "${CONTROL}" "${IMAGE}" ${HANDLE} +!macroend + +!macro __NSD_SetIconFromInstaller CONTROL HANDLE + !insertmacro __NSD_SetIconFromExeResource "${CONTROL}" "#103" ${HANDLE} +!macroend + +!define NSD_SetImage `!insertmacro __NSD_LoadAndSetImage file ${IMAGE_BITMAP} 0 "${LR_LOADFROMFILE}"` +!define NSD_SetBitmap `${NSD_SetImage}` + +!define NSD_SetIcon `!insertmacro __NSD_LoadAndSetImage file ${IMAGE_ICON} 0 "${LR_LOADFROMFILE}|${LR_DEFAULTSIZE}"` +!define NSD_SetIconFromExeResource `!insertmacro __NSD_SetIconFromExeResource` +!define NSD_SetIconFromInstaller `!insertmacro __NSD_SetIconFromInstaller` + !macro __NSD_SetStretchedImage CONTROL IMAGE HANDLE @@ -581,14 +600,23 @@ Header file for creating custom installer pages with nsDialogs !macroend !define NSD_FreeImage `!insertmacro __NSD_FreeImage` +!define NSD_FreeBitmap `${NSD_FreeImage}` -!macro __NSD_ClearImage CONTROL +!macro __NSD_FreeIcon IMAGE + System::Call user32::DestroyIcon(is) ${IMAGE} +!macroend - SendMessage ${CONTROL} ${STM_SETIMAGE} ${IMAGE_BITMAP} 0 +!define NSD_FreeIcon `!insertmacro __NSD_FreeIcon` + +!macro __NSD_ClearImage _IMGTYPE CONTROL + + SendMessage ${CONTROL} ${STM_SETIMAGE} ${_IMGTYPE} 0 !macroend -!define NSD_ClearImage `!insertmacro __NSD_ClearImage` +!define NSD_ClearImage `!insertmacro __NSD_ClearImage ${IMAGE_BITMAP}` +!define NSD_ClearIcon `!insertmacro __NSD_ClearImage ${IMAGE_ICON}` + !define DEBUG `System::Call kernel32::OutputDebugString(ts)`