Skip to content
⌘ NSIS Forum Archive

How to send text to a listbox when hovering over a checkbox ?

4 posts

stass#

How to send text to a listbox when hovering over a checkbox ?

Please tell me how to solve this problem:
It is necessary that when the mouse pointer hovers over checkbox 1, the text about the purpose of checkbox 1 is sent to the list box.
And when the mouse pointer hovers over checkbox 2, the text about the purpose of checkbox 2 is sent to the list box.
If the mouse pointer is removed from the checkboxes, the list box is empty.

The list box is used because the text is very voluminous. Other information will also be sent to the list box.

OutFile ListBoxInfo.exe
!include "MUI2.nsh"
Page custom MyPage
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Var Dlg
Var ListBox
Var check
Var check2
Function MyPage
nsDialogs::Create 1044
Pop $Dlg
GetDlgItem $1 $hwndparent 1
ShowWindow $1 0
GetDlgItem $1 $hwndparent 1028
ShowWindow $1 0
nsDialogs::CreateControl /NOUNLOAD ${__NSD_ListBox_CLASS} ${__NSD_ListBox_STYLE}|${WS_HSCROLL} ${__NSD_ListBox_EXSTYLE} 15u 30u 300u 100u ""
Pop $ListBox
SendMessage $ListBox ${LB_SETHORIZONTALEXTENT} 2000  0
SetCtlColors $ListBox `0x0000FF` `0x99FFFF`
    
${NSD_CreateCheckbox} 15u 140u 50u 14u "checkbox"
Pop $check
    
${NSD_CreateCheckbox} 100u 140u 50u 14u "checkbox2"
Pop $check2
    
nsDialogs::Show
FunctionEnd
Section
SectionEnd​ 
Anders#
nsDialogs does not really support hover callbacks, you have to use a timer (500ms or so?) and check the rectangle. You also want to check where GetFocus() is to handle keyboard TABbing.

If you compare with something like Tweak UI for XP, it only checks the focus, not keyboard hover.
stass#edited
This option works very poorly - the text ("MyLabelInfo") "shakes" and is transferred to the list box endlessly... Are there really no other options ?

OutFile ListBoxInfo.exe
!include "MUI2.nsh"
Page custom MyPage
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Var Link
Var ListBox
Function OnTimer
System::Alloc 16
Pop $0
System::Call USER32::GetCursorPos(ir0)
System::Call *$0(i.r1,i.r2)
System::Free $0
System::Call USER32::WindowFromPoint(ir1,ir2)i.r1
${If} $1 = $Link
SendMessage $ListBox ${LB_ADDSTRING} 0 "STR:Text-Text-Text"
System::Free $R1
${Else}
SendMessage $ListBox ${LB_RESETCONTENT} 0 0
${EndIf}
System::Call user32::RedrawWindow(i$Link,i0,i0,i0x0105)
FunctionEnd
Function MyPage
nsDialogs::Create 1044
Pop $0
nsDialogs::CreateControl /NOUNLOAD ${__NSD_ListBox_CLASS} ${__NSD_ListBox_STYLE}|${WS_HSCROLL} ${__NSD_ListBox_EXSTYLE} 15u 30u 300u 100u ""
Pop $ListBox
SendMessage $ListBox ${LB_SETHORIZONTALEXTENT} 2000  0
SetCtlColors $ListBox `0x0000FF` `0x99FFFF`  
    
${NSD_CreateLabel} 15u 140u 50u 15u "MyLabelInfo"
Pop $Link
${NSD_CreateTimer} OnTimer 500
nsDialogs::Show
FunctionEnd
Section
SectionEnd 


How to "catch" an event when hovering over a checkbox or any control ? This is a very important and necessary moment, but it is not used in the NSIS...
Anders#
It's sent to the listbox endlessly because you keep sending it. If you only want to send it once, store the string you want to send in a variable and check if the text is the same before setting.