From 3f3aef9940c0321732cabd247028be2627e4c650 Mon Sep 17 00:00:00 2001 From: kichik Date: Fri, 22 Feb 2008 18:32:35 +0000 Subject: [PATCH] added ${NSD_SetImage}, ${NSD_SetStretchedImage}, ${NSD_ClearImage} and ${NSD_FreeImage} git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5551 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/nsDialogs/Readme.html | 73 ++++++++++++++++++++++++++++++ Contrib/nsDialogs/nsDialogs.nsh | 80 +++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) diff --git a/Contrib/nsDialogs/Readme.html b/Contrib/nsDialogs/Readme.html index cd38d17c..d8f1ffd0 100644 --- a/Contrib/nsDialogs/Readme.html +++ b/Contrib/nsDialogs/Readme.html @@ -70,6 +70,10 @@ code
  • NSD_Check
  • NSD_Uncheck
  • NSD_SetFocus
  • +
  • NSD_SetImage
  • +
  • NSD_SetStretchedImage
  • +
  • NSD_ClearImage
  • +
  • NSD_FreeImage
  • FAQ
  • @@ -680,6 +684,75 @@ SectionEnd

    Sets focus to a control.

    +

    NSD_SetImage

    + +

    ${NSD_SetImage} control_HWND image_path output_variable

    + +

    Loads a bitmap from image_path and displays it on control_HWND created by ${NSD_CreateBitmap}. The image handle is stored in output_variable and should be freed using ${NSD_FreeImage} once no longer necessary.

    + +

    The image must be extracted to the user's computer prior to calling this macro. A good place to extract images is $PLUGINSDIR.

    + +
    !include nsDialogs.nsh
    +
    +Name nsDialogs
    +OutFile nsDialogs.exe
    +
    +XPStyle on
    +
    +Page custom nsDialogsImage
    +Page instfiles
    +
    +Var Dialog
    +Var Image
    +Var ImageHandle
    +
    +Function .onInit
    +
    +	InitPluginsDir
    +	File /oname=$PLUGINSDIR\image.bmp "${NSISDIR}\Contrib\Graphics\Header\nsis-r.bmp"
    +
    +FunctionEnd
    +
    +Function nsDialogsImage
    +
    +	nsDialogs::Create /NOUNLOAD 1018
    +	Pop $Dialog
    +
    +	${If} $Dialog == error
    +		Abort
    +	${EndIf}
    +
    +	${NSD_CreateBitmap} 0 0 100% 100% ""
    +	Pop $Image
    +	${NSD_SetImage} $Image $PLUGINSDIR\image.bmp $ImageHandle
    +
    +	nsDialogs::Show
    +
    +	${NSD_FreeImage} $ImageHandle
    +
    +FunctionEnd
    +
    +Section
    +SectionEnd
    + +

    NSD_SetStretchedImage

    + +

    ${NSD_SetStretchedImage} control_HWND image_path output_variable

    + +

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

    + +

    NSD_ClearImage

    + +

    ${NSD_ClearImage} control_HWND

    + +

    Clears an image from a control.

    + +

    NSD_FreeImage

    + +

    ${NSD_FreeImage} image_handle

    + +

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

    +

    FAQ

    diff --git a/Contrib/nsDialogs/nsDialogs.nsh b/Contrib/nsDialogs/nsDialogs.nsh index 43bf9750..9db34835 100644 --- a/Contrib/nsDialogs/nsDialogs.nsh +++ b/Contrib/nsDialogs/nsDialogs.nsh @@ -353,6 +353,86 @@ Header file for creating custom installer pages with nsDialogs !define NSD_SetFocus `!insertmacro __NSD_SetFocus` +!macro __NSD_SetImage 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 + + Pop $R0 + Exch $0 + + Pop ${HANDLE} + +!macroend + +!define NSD_SetImage `!insertmacro __NSD_SetImage` + +!macro __NSD_SetStretchedImage CONTROL IMAGE HANDLE + + Push $0 + Push $1 + Push $2 + Push $R0 + + StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0 + + StrCpy $1 "" + StrCpy $2 "" + + System::Call '*(i, i, i, i) i.s' + Pop $0 + + ${If} $0 <> 0 + + System::Call 'user32::GetClientRect(iR0, ir0)' + System::Call '*$0(i, i, i .s, i .s)' + System::Free $0 + Pop $1 + Pop $2 + + ${EndIf} + + System::Call 'user32::LoadImage(i0, ts, i ${IMAGE_BITMAP}, ir1, ir2, i${LR_LOADFROMFILE}) i.s' "${IMAGE}" + Pop $0 + SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0 + + Pop $R0 + Pop $2 + Pop $1 + Exch $0 + + Pop ${HANDLE} + +!macroend + +!define NSD_SetStretchedImage `!insertmacro __NSD_SetStretchedImage` + +!macro __NSD_FreeImage IMAGE + + ${If} ${IMAGE} <> 0 + + System::Call gdi32::DeleteObject(is) ${IMAGE} + + ${EndIf} + +!macroend + +!define NSD_FreeImage `!insertmacro __NSD_FreeImage` + +!macro __NSD_ClearImage CONTROL + + SendMessage ${CONTROL} ${STM_SETIMAGE} ${IMAGE_BITMAP} 0 + +!macroend + +!define NSD_ClearImage `!insertmacro __NSD_ClearImage` + !define DEBUG `System::Call kernel32::OutputDebugString(ts)` !macro __NSD_ControlCase TYPE