Menu

#543 Insert String into a ListBox control

3.0 Series
closed-fixed
nobody
None
5
2017-09-22
2017-09-07
No

Currently in nsDialogs.nsh there is no function to Insert a string into a listbox. The only option is to add a string after the last entry.

Following could be included in nsDialgs.nsh to insert a string at the beginning of the list.

!macro _NSD_LB_InsertString CONTROL STRING
    SendMessage ${CONTROL} ${LB_INSERTSTRING} 0 `STR:${STRING}`
!macroend

!define NSD_LB_InsertString "!insertmacro _NSD_LB_InsertString"

Regards
Scott

Discussion

  • Anders

    Anders - 2017-09-16
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -2,11 +2,13 @@
    
     Following could be included in nsDialgs.nsh to insert a string at the beginning of the list.
    
    +~~~~NSIS
     !macro _NSD_LB_InsertString CONTROL STRING
        SendMessage ${CONTROL} ${LB_INSERTSTRING} 0 `STR:${STRING}`
     !macroend
    
     !define NSD_LB_InsertString "!insertmacro _NSD_LB_InsertString"
    +~~~~
    
     Regards
     Scott
    
    • status: open --> closed-fixed
     
  • idleberg

    idleberg - 2017-09-16

    IMHO, the syntax is more than confusing. Neither "insert" nor "add" communicate the position where a string is added (uhm, or inserted). Using NSDLBAppendString / NSDLBPrependString would be distinct (and there could be a temporary alias for the existing NSDLBAddString macro)

     
    • Anders

      Anders - 2017-09-16

      AddString is AddString because that is a different message in Windows and the new string is inserted at the end and the list is sorted if LBS_SORT is set. Insert inserts at a specific index and you must specify where because I did not hardcode 0 when I merged this patch. If anything, we can add aliases for Prepend/Append.

       
  • idleberg

    idleberg - 2017-09-19

    With an index specified, "insert" makes sense

     
  • Scott Davies

    Scott Davies - 2017-09-22

    Thanks idleberg.

    I agree, an index does make much more sense for an Insert.

    Regards
    Scott

     

Log in to post a comment.

MongoDB Logo MongoDB