0

我正在使用NSD_SetImageOLE来自http://nsis.sourceforge.net/NsDialogs_SetImageOLE的插件宏- 我想NSD_SetStretchedImageOLE以同样的方式添加另一个宏nsDialog.nsh

但我不确定这是否可能,我发现IPicture可以通过获取“HBITMAP、BITMAP 和 BITMAPINFO”并调整其大小来调整 an 的大小(引自http://www.mofeel.net/958 -microsoft-public-vc-mfc/12516.aspx)。无论如何,我有点迷失了试图将这些方法转换为 NSIS 的System::Call风格。

4

2 回答 2

1

我已经用 ${NSD_SetStretchedImageOLE}更新了http://nsis.sourceforge.net/mediawiki/images/6/65/NsDialogs_setImageOle.zip ,它封装了 Anders 的代码以实现可重用性。我也将其更改为使用控件尺寸,而不是您必须自己指定尺寸。

于 2014-12-05T03:20:29.007 回答
0
!ifndef IID_IPicture
    !define IID_IPicture {7BF80980-BF32-101A-8BBB-00AA00300CAB}
!endif
!define SRCCOPY 0xCC0020
!include nsDialogs.nsh

!define IMAGEPATH "$sysdir\migwiz\PostMigRes\Web\base_images\Documents.gif" ;"C:\Windows\Web\Wallpaper\Windows\img0.jpg"
!define NEWSIZEW 200
!define NEWSIZEH 100

Page Custom mypagestretchcreate_GDI ; GDI resize
Page Custom mypagestretchcreate_CTL ; Simple control resize


Function mypagestretchcreate_GDI
nsDialogs::Create 1018
Pop $0
System::Call 'oleaut32::OleLoadPicturePath(w "${IMAGEPATH}",i0r2,i0,i0,g"${IID_IPicture}",*i.r9)i.r1'
${If} $1 = 0
    System::Call 'user32::GetDC(i0)i.s'
    System::Call 'gdi32::CreateCompatibleDC(iss)i.r1'
    System::Call 'gdi32::CreateCompatibleBitmap(iss,i${NEWSIZEW},i${NEWSIZEH})i.r2'
    System::Call 'user32::ReleaseDC(i0,is)'
    System::Call $9->3(*i.r3)i.r4 ; IPicture->get_Handle
    ${If} $4 = 0
        System::Call 'gdi32::SetStretchBltMode(ir1,i4)'
        System::Call '*(&i40,&i1024)i.r4' ; BITMAP / BITMAPINFO
        System::Call 'gdi32::GetObject(ir3,i24,ir4)'
        System::Call 'gdi32::SelectObject(ir1,ir2)i.s'
        System::Call '*$4(i40,i.r6,i.r7,i0,i,i.s)' ; Grab size and bits-ptr AND init as BITMAPINFOHEADER
        System::Call 'gdi32::GetDIBits(ir1,ir3,i0,i0,i0,ir4,i0)' ; init BITMAPINFOHEADER
        System::Call 'gdi32::GetDIBits(ir1,ir3,i0,i0,i0,ir4,i0)' ; init BITMAPINFO
        System::Call 'gdi32::StretchDIBits(ir1,i0,i0,i${NEWSIZEW},i${NEWSIZEH},i0,i0,ir6,ir7,is,ir4,i0,i${SRCCOPY})'
        System::Call 'gdi32::SelectObject(ir1,is)'
        System::Free $4
    ${EndIf}
    System::Call 'gdi32::DeleteDC(ir1)'
    System::Call $9->2() ; IPicture->release()
${EndIf}
${NSD_CreateBitmap} 1u 1u ${NEWSIZEW} ${NEWSIZEH} ""
Pop $9
;Not required when the control size matches: ${NSD_AddStyle} $9 ${SS_CENTERIMAGE}
SendMessage $9 ${STM_SETIMAGE} ${IMAGE_BITMAP} $2
nsDialogs::Show
System::Call 'gdi32::DeleteObject(ir2)'
FunctionEnd

Function mypagestretchcreate_CTL
nsDialogs::Create 1018
Pop $2
${NSD_CreateBitmap} 0 1u 70% 50% ""
Pop $3
${NSD_AddStyle} $3 ${SS_REALSIZECONTROL}
File "/oname=$PLUGINSDIR\image.bmp" "${NSISDIR}\Contrib\Graphics\Header\win.bmp"
${NSD_SetImage} $3 "$PLUGINSDIR\image.bmp" $1
nsDialogs::Show
${NSD_FreeImage} $1
FunctionEnd
于 2012-11-15T20:33:35.420 回答