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
This commit is contained in:
kichik 2008-02-22 18:32:35 +00:00
parent f943d43bb3
commit 3f3aef9940
2 changed files with 153 additions and 0 deletions

View file

@ -70,6 +70,10 @@ code
<li><a href="#mref-check">NSD_Check</a></li>
<li><a href="#mref-uncheck">NSD_Uncheck</a></li>
<li><a href="#mref-setfocus">NSD_SetFocus</a></li>
<li><a href="#mref-setimage">NSD_SetImage</a></li>
<li><a href="#mref-setsimage">NSD_SetStretchedImage</a></li>
<li><a href="#mref-clearimage">NSD_ClearImage</a></li>
<li><a href="#mref-freeimage">NSD_FreeImage</a></li>
</ul>
</li>
<li><a href="#faq">FAQ</a></li>
@ -680,6 +684,75 @@ SectionEnd</pre></blockquote>
<p>Sets focus to a control.</p>
<h3><a name="mref-setimage"></a>NSD_SetImage</h3>
<p><code>${NSD_SetImage} <i>control_HWND</i> <i>image_path</i> <i>output_variable</i></code></p>
<p>Loads a bitmap from <i>image_path</i> and displays it on <i>control_HWND</i> created by <a href="#mref-create">${NSD_CreateBitmap}</a>. The image handle is stored in <i>output_variable</i> and should be freed using <a href="#mref-freeimage">${NSD_FreeImage}</a> once no longer necessary.</p>
<p>The image must be extracted to the user's computer prior to calling this macro. A good place to extract images is $PLUGINSDIR.</p>
<blockquote><pre>!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</pre></blockquote>
<h3><a name="mref-setsimage"></a>NSD_SetStretchedImage</h3>
<p><code>${NSD_SetStretchedImage} <i>control_HWND</i> <i>image_path</i> <i>output_variable</i></code></p>
<p>Loads and displays a bitmap just like <a href="#mref-setimage">${NSD_SetImage}</a>, but stretched the image to fit the control.</p>
<h3><a name="mref-clearimage"></a>NSD_ClearImage</h3>
<p><code>${NSD_ClearImage} <i>control_HWND</i></code></p>
<p>Clears an image from a control.</p>
<h3><a name="mref-freeimage"></a>NSD_FreeImage</h3>
<p><code>${NSD_FreeImage} <i>image_handle</i></code></p>
<p>Frees an image handle previously loaded with <a href="#mref-setimage">${NSD_SetImage}</a> or <a href="#mref-setsimage">${NSD_SetStretchedImage}</a>.</p>
<h2><a name="faq"></a>FAQ</h2>
<div>

View file

@ -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