nsdialogs + Trackbar control [NSD_OnNotify problem]
I would like to ask about TrackBar control support in NSIS.
I need to use a trackbar in my nsdialogs based custom page.
I have few problems with it...
Here is how I create the control:
!define TBM_SETPOS 0x0405
!define TBM_GETPOS 0x0400
!define TBM_SETRANGEMIN 0x0407
!define TBM_SETRANGEMAX 0x0408
; Slider
nsDialogs::CreateControl "msctls_trackbar32" "0x50010000|0x00000018" "" 15u 76u 100 20 ""
Pop $Slider1
SendMessage $Slider1 ${TBM_SETRANGEMIN} 1 1 ; Setting Min range (1)
SendMessage $Slider1 ${TBM_SETRANGEMAX} 1 8 ; Setting Max range (8)
${NSD_OnNotify} $Slider1 onNotify_Slider1 ; Using OnNotify
First problem. ${NSD_OnClick} or ${NSD_OnChange$} doeasnt work. Is it possible to make it work?
I want to do some action, when user move the slider.
I am using ${NSD_OnNotify} instead. This works, but there are some problems...
Take a look at this function:
Function onNotify_Slider1
SendMessage $Slider1 ${TBM_GETPOS} 0 0 $1 ; Get Trackbar position
${Select} $1
${Case} "1"
; Do something 1 (I am displaying here an image 1)
${Case} "2"
; Do something 2 (I am displaying here an image 2)
${Case} "n"
; Do something n (I am displaying here an image n)
${EndSelect}
System::Call "gdi32:DeleteObject(i $Image_Var)" ; Here I am freeing used resource for Images
FunctionEnd
The big problem is, that if I move slider of trackbar (few times, from position 1 to 8), installer uses more and more memory.
Even if function "onNotify_Slider1" has no code (is empty), there are some memory leaks or something.
Why? What is the way to use correctly ${NSD_OnNotify}?
OnNotify
nsDialogs::OnNotify control_HWND function_address
Sets a notification callback function for the given control. Whenever the control receives the WM_NOTIFY message, the function will be called and the control's HWND, notification code and a pointer to the MNHDR structure will be waiting on its stack.
Use GetFunctionAddress to get the address of the desired callback function.
Maybe memory problems is result of this MNHDR structure on stack? Maybe I should free this? (how?)
How can I just use OnChange for Trackbar?
Somebody has an idea, example?
Thanks
-Pawel