Archive: how does a specific BMP show when a radiobutton clicked?


how does a specific BMP show when a radiobutton clicked?
I already read this article
http://forums.winamp.com/showthread....ht=radiobutton

like the sample file {_trueparuex^} uploaded, i modified my INI and NSI file but it doesn't seem to work.


=== INI file ===============================================
[Settings]
NumFields=9

[Field 1]
Type=Label
Text=choose your monitor resolution
Left=17
Right=211
Top=4
Bottom=14

[Field 2]
Type=Groupbox
Text=resolution
Left=0
Right=84
Top=22
Bottom=153

[Field 3]
Type=Groupbox
Text=description
Left=88
Right=228
Top=23
Bottom=153

[Field 4]
Type=RadioButton
Text=1280 X 1024
Left=10
Right=68
Top=43
Bottom=71
Flags=NOTIFY

[Field 5]
Type=RadioButton
Text=1680 X 1050 small
Left=10
Right=75
Top=76
Bottom=99
Flags=NOTIFY

[Field 6]
Type=RadioButton
Text=1680x1050 big
Left=10
Right=72
Top=108
Bottom=128
Flags=NOTIFY

[Field 7]
Type=Bitmap
Text=crt.bmp
Left=95
Right=220
Top=35
Bottom=144
Flags=RESIZETOFIT

[Field 8]
Type=Bitmap
Text=wide2.bmp
Left=94
Right=218
Top=33
Bottom=144
Flags=RESIZETOFIT

[Field 9]
Type=Bitmap
Text=wide.bmp
Left=95
Right=219
Top=32
Bottom=144
Flags=RESIZETOFIT


======== and this is NSI file ===========================


Name "InstallOptions Test"
OutFile "imagechanging.exe"
ShowInstDetails show

Function .onInit

InitPluginsDir
File /oname=$PLUGINSDIR\monitor.ini "AccountInf.ini"
File /oname=$PLUGINSDIR\crt.bmp "crt.bmp"
File /oname=$PLUGINSDIR\wide2.bmp "wide2.bmp"
File /oname=$PLUGINSDIR\wide.bmp "wide.bmp"

FunctionEnd

Page custom ShowCustom LeaveCustom ": Testing InstallOptions"

Function ShowCustom

InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\monitor.ini"
Pop $0

InstallOptions::show
Pop $0

FunctionEnd

Function LeaveCustom

; At this point the user has either pressed Next or one of our custom buttons
; We find out which by reading from the INI file
ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Settings" "State"
StrCmp $0 1 RadioButton
StrCmp $0 2 RadioButton
StrCmp $0 3 RadioButton
Abort ; Return to the page

RadioButton:

ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Field 4" "State"
ReadINIStr $1 "$PLUGINSDIR\monitor.ini" "Field 7" "HWND"
ShowWindow $1 $0
ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Field 5" "State"
ReadINIStr $1 "$PLUGINSDIR\monitor.ini" "Field 8" "HWND"
ShowWindow $1 $0
ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Field 6" "State"
ReadINIStr $1 "$PLUGINSDIR\monitor.ini" "Field 9" "HWND"
ShowWindow $1 $0

Abort ; Return to the page

FunctionEnd

Page instfiles

Section
SectionEnd

=========================================================

anyone knows which part i made mistake?


First, I'll say it's probably best to keep all your PAGE calls together. While it may work the way you have it, I think it makes for a cleaner script.

Next, have a look at this part:

ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Settings" "State"
StrCmp $0 1 RadioButton
StrCmp $0 2 RadioButton
StrCmp $0 3 RadioButton
Abort ; Return to the page
There are a couple things to point out:
1) You are checking to see which control is "notifying" of an action. But, you are checking for the wrong values. In your case, the radio buttons are fields 4, 5, 6. So you need to check for values of "4", "5", or "6". In your case, it simply returns you back to page without doing anything

2) You have an abort command if the none of the radio buttons are selected. When the user presses "next", it returns a value of zero. But in your case, you are going to go right back to the page instead of moving forward.

3) When using radio buttons in an INI file, you should set Flag=Group on the first radio button in the list (which is Field #4 in your example.)

Since you only seem to care whether or not a radio button is selected (and not necessarily WHICH radio button), you could probably get away with a much simpler check, which would also correctly handle a press of the "next" button: (example created using LogicLib...don't forget to add !include logiclib.nsh near the top of your script):

ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Settings" "State"
${Unless} $0 = 0
ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Field 4" "State"
ReadINIStr $1 "$PLUGINSDIR\monitor.ini" "Field 7" "HWND"
ShowWindow $1 $0
ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Field 5" "State"
ReadINIStr $1 "$PLUGINSDIR\monitor.ini" "Field 8" "HWND"
ShowWindow $1 $0
ReadINIStr $0 "$PLUGINSDIR\monitor.ini" "Field 6" "State"
ReadINIStr $1 "$PLUGINSDIR\monitor.ini" "Field 9" "HWND"
ShowWindow $1 $0
abort
${EndUnless}

//Comperio

Thanks so much!
I can see the BMPs chaging now!
wow!