Change DropDown listitems
I would like to change the content of a dropdown list when a user presses a refresh button or opens the list. I checked the WinMessages.nsh but I couldnt find anything that could change them.
So how do I change it?
Archive: Change DropDown listitems
Change DropDown listitems
I would like to change the content of a dropdown list when a user presses a refresh button or opens the list. I checked the WinMessages.nsh but I couldnt find anything that could change them.
So how do I change it?
This is possible (I think) but I'm unfamiliar on the way to do it.
It's a new method which I've never used.
Sorry that I can't help you, but I'm sure somebody else can help you.
-Stu
You can read the InstallOptions or InstallOptionsEx documentations for the "NOTIFY" flag (InstallOptions) or "Notify" INI value name (InstallOptionsEx).
opens the listOnly IOEx has a notification for this.
Well the dropdown shows the available cdrom drives and the label of the disk that's currently in it, and it would be nice to be able to refresh the labels if a user puts in a new cd.
1) (INI File) You need to use the flag "NOTIFY" for the Button control (InstallOptions) or use "Notify" INI value name with value "ONCLICK" for the Button control and "ONLISTOPEN" for the DropList control (InstallOptionsEx).
2) You need a Leave Function for your custom page so the notifications can work correctly.
3) Instead of showing the page normally, reserve it first, pop the result of the reservation (page handle) and then show the page.
4) To get a control handle by knowing the ID, use the following code:[code]!define IOGetDlgItem '!insertmacro IOGetDlgItem'
!macro IOGetDlgItem Var PageHWND FieldNumber
StrCpy '${Var}' '${FieldNumber}'
IntOp '${Var}' '${Var}' + 1199
GetDlgItem '${Var}' '${PageHWND}' '${Var}'
!macroend[/quote]To use it:
${IOGetDlgItem} $Var $PageHandleVar FieldNumber
Example:
${IOGetDlgItem} $0 $PH 2; "Field 2"
6) Done! You need Detect Drives function in order to use the code below:
(Needs adaption to your code - Not totally tested)
!define MAX_PATH 260
!define CB_ERR -1
!define CB_ADDSTRING 0x0143
!define CB_RESETCONTENT 0x014B
!define CB_SETCURSEL 0x014E
Function YourCustomPageLeave
;...Some code...
;TODO: Detect if the control you want was notified, then execute code below
# $0 = Control handle (use GetDlgItem to get this)
Push $1
System::Call `user32::SendMessageA(i r0,i ${CB_GETCURSEL},,)i .r1`
StrCmp $1 ${CB_ERR} 0 +2
StrCpy $1 0
System::Call `user32::SendMessageA(i r0,i ${CB_RESETCONTENT},,)i`
Push "CDROM Drives"
Push $0
GetFunctionAddress $0 "DetectCDROMDrives"
Exch $0
Call DetectDrives
System::Call `user32::SendMessageA(i r0,i ${CB_SETCURSEL},i r1,)i`
Pop $1
;...Some other code...
FunctionEnd
Function DetectCDROMDrives
Push $R1
System::Call `Kernel32::GetVolumeInformation(t R0,t .R1,i ${MAX_PATH},,,,,)i`
StrCpy $R0 $R0 2
System::Call `user32::SendMessageA(i r0,i ${CB_ADDSTRING},,t "$R1 ($R0)")i`
Pop $R1
Push "Go"
FunctionEnd
EDIT #1: Fixed no selection when refreshing listhm thanx a lot for your code, but I had the drive detection already working, just the dropdown updating at runtime was the problem. School now :( I'll try this tonight.