杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2212|回复: 0

NSIS关于预览图片切换功能的实现

[复制链接]
发表于 2017-2-26 10:43:19 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
i2006831235838.gif
  1. Name                "test"
  2. OutFile              "test.exe"

  3. !include            MUI.nsh

  4. !ifndef LR_LOADTRANSPARENT
  5.   !define LR_LOADTRANSPARENT  0x0020
  6. !endif

  7. !ifndef LR_LOADFROMFILE
  8.   !define LR_LOADFROMFILE     0x0010
  9. !endif

  10. !ifndef LR_CreateDIBSECTION
  11.   !define LR_CreateDIBSECTION 0x2000
  12. !endif

  13. !ifndef STM_SETIMAGE
  14.   !define STM_SETIMAGE        370
  15. !endif

  16. !ifndef IMAGE_BITMAP
  17.   !define IMAGE_BITMAP        0
  18. !endif

  19. !ifndef sysLoadImage
  20.   !define sysLoadImage        "user32::LoadImageA(i, t, i, i, i, i) i"
  21. !endif

  22. !ifndef sysDeleteObject
  23.   !define sysDeleteObject     "gdi32::DeleteObject(i) i"
  24. !endif

  25. Var hwnd
  26. Var ImageHandle

  27. !macro DisplayImage PARENTWIN IMGHANDLE IMG_NAME
  28.   StrCmp $ImageHandle '' +4
  29.     StrCpy $6 $ImageHandle
  30.     System::Call "${sysDeleteObject} (r6)"
  31.     StrCpy $6 ''
  32.   GetDlgItem $0 ${PARENTWIN} ${IMGHANDLE}
  33.   System::Call '${sysLoadImage} (0, s, ${IMAGE_BITMAP}, 0, 0, ${LR_CreateDIBSECTION}|${LR_LOADFROMFILE}) .r6' "${IMG_NAME}"
  34.   SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $6
  35.   StrCpy $ImageHandle $6
  36. !macroend

  37. ReserveFile "${NSISDIR}PluginsInstallOptions.dll"
  38. ReserveFile io.ini
  39. ReserveFile img1.bmp
  40. ReserveFile img2.bmp

  41. Page custom SetCustom LeaveCustom
  42. !insertmacro MUI_PAGE_INSTFILES

  43. !insertmacro MUI_LANGUAGE SimpChinese

  44. Section -nothing
  45. SectionEnd

  46. Function .onInit
  47.   InitPluginsDir
  48.   File /oname=$PLUGINSDIRio.ini io.ini
  49.   File /oname=$PLUGINSDIRimg1.bmp img1.bmp
  50.   File /oname=$PLUGINSDIRimg2.bmp img2.bmp
  51.   WriteINIStr "$PLUGINSDIRio.ini" "Field 1" "Text" "$PLUGINSDIRimg1.bmp"
  52. FunctionEnd

  53. Function SetCustom
  54.   InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIRio.ini"
  55.   Pop $hwnd
  56.   !insertmacro DisplayImage $hwnd 1200 "$PLUGINSDIRimg1.bmp"
  57.   InstallOptions::show
  58. FunctionEnd

  59. Function LeaveCustom
  60.   ReadINIStr $0 "$PLUGINSDIRio.ini" "Settings" "State"
  61.   StrCmp $0 3 ImgBtn1
  62.   StrCmp $0 4 ImgBtn2
  63.   Goto InstallBtn
  64.   ImgBtn1:
  65.     !insertmacro DisplayImage $hwnd 1200 "$PLUGINSDIRimg1.bmp"
  66.     Abort
  67.   ImgBtn2:
  68.     !insertmacro DisplayImage $hwnd 1200 "$PLUGINSDIRimg2.bmp"
  69.     Abort
  70.   InstallBtn:
  71. FunctionEnd
复制代码

  1. ; Ini file generated by the HM NIS Edit IO designer.
  2. [Settings]
  3. NumFields=4

  4. [Field 1]
  5. Type=Bitmap
  6. Left=6
  7. Right=201
  8. Top=3
  9. Bottom=134

  10. [Field 2]
  11. Type=Groupbox
  12. Text=select
  13. Left=212
  14. Right=271
  15. Top=6
  16. Bottom=60

  17. [Field 3]
  18. Type=RadioButton
  19. Text=img 1
  20. Flags=GROUP|NOTIFY
  21. State=1
  22. Left=222
  23. Right=260
  24. Top=22
  25. Bottom=32

  26. [Field 4]
  27. Type=RadioButton
  28. Text=img 2
  29. Flags=NOTIFY
  30. Left=222
  31. Right=260
  32. Top=40
  33. Bottom=51
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-18 03:26 , Processed in 0.126456 second(s), 25 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表