实现预览图片切换功能
优质
小牛编辑
135浏览
2023-12-01
效果如图:
引用flighty.nsi的内容:
Name "www.flighty.cn" OutFile "flighty.exe" !include MUI.nsh !ifndef LR_LOADTRANSPARENT !define LR_LOADTRANSPARENT 0x0020 !endif !ifndef LR_LOADFROMFILE !define LR_LOADFROMFILE 0x0010 !endif !ifndef LR_CreateDIBSECTION !define LR_CreateDIBSECTION 0x2000 !endif !ifndef STM_SETIMAGE !define STM_SETIMAGE 370 !endif !ifndef IMAGE_BITMAP !define IMAGE_BITMAP 0 !endif !ifndef sysLoadImage !define sysLoadImage "user32::LoadImageA(i, t, i, i, i, i) i" !endif !ifndef sysDeleteObject !define sysDeleteObject "gdi32::DeleteObject(i) i" !endif Var hwnd Var ImageHandle !macro DisplayImage PARENTWIN IMGHANDLE IMG_NAME StrCmp $ImageHandle '' +4 StrCpy $6 $ImageHandle System::Call "${sysDeleteObject} (r6)" StrCpy $6 '' GetDlgItem $0 ${PARENTWIN} ${IMGHANDLE} System::Call '${sysLoadImage} (0, s, ${IMAGE_BITMAP}, 0, 0, ${LR_CreateDIBSECTION}|${LR_LOADFROMFILE}) .r6' "${IMG_NAME}" SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $6 StrCpy $ImageHandle $6 !macroend ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" ReserveFile io.ini ReserveFile img1.bmp ReserveFile img2.bmp Page custom SetCustom LeaveCustom !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_LANGUAGE SimpChinese Section -nothing SectionEnd Function .onInit InitPluginsDir File /oname=$PLUGINSDIR\io.ini io.ini File /oname=$PLUGINSDIR\img1.bmp img1.bmp File /oname=$PLUGINSDIR\img2.bmp img2.bmp WriteINIStr "$PLUGINSDIR\io.ini" "Field 1" "Text" "$PLUGINSDIR\img1.bmp" FunctionEnd Function SetCustom InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\io.ini" Pop $hwnd !insertmacro DisplayImage $hwnd 1200 "$PLUGINSDIR\img1.bmp" InstallOptions::show FunctionEnd Function LeaveCustom ReadINIStr $0 "$PLUGINSDIR\io.ini" "Settings" "State" StrCmp $0 3 ImgBtn1 StrCmp $0 4 ImgBtn2 Goto InstallBtn ImgBtn1: !insertmacro DisplayImage $hwnd 1200 "$PLUGINSDIR\img1.bmp" Abort ImgBtn2: !insertmacro DisplayImage $hwnd 1200 "$PLUGINSDIR\img2.bmp" Abort InstallBtn: FunctionEnd
引用io.ini的内容:
; Ini file generated by the HM NIS Edit IO designer. [Settings] NumFields=4 [Field 1] Type=Bitmap Left=6 Right=201 Top=3 Bottom=134 [Field 2] Type=Groupbox Text=select Left=212 Right=271 Top=6 Bottom=60 [Field 3] Type=RadioButton Text=img 1 Flags=GROUP|NOTIFY State=1 Left=222 Right=260 Top=22 Bottom=32 [Field 4] Type=RadioButton Text=img 2 Flags=NOTIFY Left=222 Right=260 Top=40 Bottom=51
资源文件点击另存。