Old 3rd February 2009, 02:43   #1
joe1202
Junior Member
 
Join Date: Feb 2009
Posts: 11
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?
joe1202 is offline   Reply With Quote
Old 3rd February 2009, 04:50   #2
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
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:
code:
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):
code:

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 is offline   Reply With Quote
Old 3rd February 2009, 14:03   #3
joe1202
Junior Member
 
Join Date: Feb 2009
Posts: 11
//Comperio

Thanks so much!
I can see the BMPs chaging now!
wow!
joe1202 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump