Old 23rd April 2013, 12:10   #1
nashtor
Junior Member
 
Join Date: Feb 2013
Posts: 11
Question DoubleClick (ListBox)

Hello there!

Whenever a user DoubleClicks an entry in a ListBox I am trying to call a function.
Searching the documentation and this forum did not help me: found nothing concerning DoubleClicks ...
I tried intercepting LBN_DBLCLK (--> http://msdn.microsoft.com/en-us/library/ms997541.aspx) with NSD_OnNotify but it never fires ...
(NSD_OnClick is not working for me either ...)

At the moment I am using NSD_OnChange to simulate a very slow and bad 'Double'Click.

Is there any way to call a function if someone doubleclicks an entry in a ListBox?
(... Am I doing something stupid?)

PHP Code:
;--------------------------------
;Include
    
    !include 
"MUI2.nsh"
    
!include "nsDialogs.nsh"


;--------------------------------
;
General

!define VERSION "0.1.1"

Name "LB DoubleClick Test"

OutFile "LB_DoubleClick_Test.exe"

RequestExecutionLevel user


;--------------------------------
;
Variables
    
    
Var LB_test
    
Var CurrentString
    
    
;--------------------------------
;
Pages
    
    Page custom nsDialogsMain
    

;--------------------------------
;
Languages
    
    
!insertmacro MUI_LANGUAGE "English"
    
    
;--------------------------------
;
Descriptions

    
;Header
    LangString 
"^SetupCaption" ${LANG_ENGLISH"$(^Name) v${VERSION}"
    
LangString PAGEMAIN_TITLE ${LANG_ENGLISH"ListBox DoubleClick Test"
    
LangString PAGEMAIN_SUBTITLE ${LANG_ENGLISH"Does a DoubleClick even work ?"
    
    
;--------------------------------
;
Makros
    
    
;select (firstsecondthird ... lastitem of a ListBox
    
!macro _NSD_LB_SelectItem CONTROL ITEM

        SendMessage 
${CONTROL} ${LB_SETCURSEL} ${ITEM0

    
!macroend

    
!define NSD_LB_SelectItem "!insertmacro _NSD_LB_SelectItem"


;--------------------------------
;
Installer Sections

Section 
""
SectionEnd


;--------------------------------
;
Installer Functions

;PagesAndExitFunctions START
Function nsDialogsMain

    
!insertmacro MUI_HEADER_TEXT $(PAGEMAIN_TITLE) $(PAGEMAIN_SUBTITLE)
    
    
nsDialogs::Create 1018
        Pop 
$0

    
${If} $== error
        Abort
    
${EndIf}
    
    ${
NSD_CreateListBox300 4060""
        
Pop $LB_test
        
${NSD_OnNotify$LB_test func_OnNotify
        
${NSD_OnClick$LB_test func_OnClick
        
${NSD_OnChange$LB_test func_OnChange
        Call func_fillListBox
    
    nsDialogs
::Show
    
FunctionEnd
;PagesAndExitFunctions END

Function func_fillListBox

    
${NSD_LB_Clear$LB_test $0
    
${NSD_LB_AddString$LB_test "testString1"
    
${NSD_LB_AddString$LB_test "testString2"
    
${NSD_LB_AddString$LB_test "testString3"
    
;select first item in ListBox
    
${NSD_LB_SelectItem$LB_test 0
    
FunctionEnd


;this will never fire ...
Function 
func_OnNotify
    
    
${NSD_LB_GetSelection$LB_test $CurrentString
    MessageBox MB_OK 
"$CurrentString:$\r$\nfunc_OnNotify fired ..."
    
    
; for func_OnChange:
    
StrCpy $CurrentString ""
    
FunctionEnd

;this will never fire ...
Function 
func_OnClick
    
    
${NSD_LB_GetSelection$LB_test $CurrentString
    MessageBox MB_OK 
"$CurrentString:$\r$\nfunc_OnClick fired ..."
    
    
; for func_OnChange:
    
StrCpy $CurrentString ""
    
FunctionEnd

Function func_OnChange
    
    
;it fires even if clicked twice(slowlyon an empty field of ListBox ...
    
    ; 
just to imitate a very slow double click 1/2:
    ${
NSD_LB_GetSelection$LB_test $0
    StrCmp 
"$CurrentString" "$0" +3 0
        StrCpy $CurrentString 
$0
        Abort 
###
        
    
MessageBox MB_OK "$CurrentString:$\r$\nfunc_OnChange fired ..."
    
    
just to imitate a very slow double click 2/2:
    
StrCpy "$CurrentString" ""
    
FunctionEnd 
nashtor is offline   Reply With Quote
Old 23rd April 2013, 14:53   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
nsDialogs is rather limited when it comes to which events are passed on and NSD_OnNotify is probably only for WM_NOTIFY (ListView)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th April 2013, 10:12   #3
nashtor
Junior Member
 
Join Date: Feb 2013
Posts: 11
What a shame! Seems like I have to get used to my 'Double'Click function...
Nonetheless: thank you for your really fast replay!
nashtor 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