Old 8th November 2016, 15:31   #1
Marbled
Junior Member
 
Join Date: Dec 2015
Posts: 24
Some questions about creating a new page...

Hi!

I just created my first new page using nsDialogs and I have a few issues...

The first one is that I want to create a list box but and I was wondering if there is a way to have two values for each entry, one for display and the other one would be returned when I get the selection.

For example the displayed value could be name of a country while the return value would be its country code.

Is there any way to do that?

My other question is about the position of the different labels on a Modern UI 2 page, is there any way to know what it is so that I can use the same positions in my new page?

Thank you and have a nice day!

Nick
Marbled is offline   Reply With Quote
Old 8th November 2016, 16:00   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,528
1) Use the LB_GETITEMDATA and LB_SETITEMDATA messages (More info on MSDN)

2) Look in \NSIS\Contrib\Modern UI 2\Pages

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th November 2016, 20:17   #3
Marbled
Junior Member
 
Join Date: Dec 2015
Posts: 24
Thank you very much Anders!

Quote:
Originally Posted by Anders View Post
1) Use the LB_GETITEMDATA and LB_SETITEMDATA messages (More info on MSDN)
I think I understand the idea but I don't know how to do it since I am not familiar enought with Windows APIs and NSIS...

It tried something like this:

${NSD_LB_AddString} $ListBox_division "$(DIVISION_EAST)"
SendMessage $ListBox_division ${CB_SETITEMDATA} 0 "STR:east"

${NSD_LB_AddString} $ListBox_division "$(DIVISION_WEST)"
SendMessage $ListBox_division ${CB_SETITEMDATA} 1 "STR:west"

${NSD_LB_AddString} $ListBox_division "$(DIVISION_BOTH)"
SendMessage $ListBox_division ${CB_SETITEMDATA} 2 "STR:both"

${NSD_LB_SelectString} $ListBox_division "$(DIVISION_EAST)"

It didn't complain but I am not sure I did it ok...

The thing I am most doubtful of is where I get it:

Function nsDialogsPageLeave
;${NSD_LB_GetSelection} $ListBox_division $division
SendMessage $ListBox_division ${CB_GETITEMDATA} 0 $division
FunctionEnd

Is that how I should do that? I doubt it since it doesn't work and complain about division being unused...

Quote:
Originally Posted by Anders View Post
2) Look in \NSIS\Contrib\Modern UI 2\Pages
The only page I could see absolute positionings is the welcome page... I don't know NSIS well enough to understand how the positioning is done in the other pages (like the component one for example).

Thank you very much and have a nice day!

Nick
Marbled is offline   Reply With Quote
Old 10th November 2016, 21:03   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,528
SendMessage $mycontrol ${LB_GETITEMDATA} $itemindex 0 $outputgoeshere but I don't remember if you can store strings there or just numbers. (Don't mix LB and CB messages)

Only the Welcome and Finish pages use nsDialogs, the others are NSIS built-in pages. The resource scripts for those are @ https://sourceforge.net/p/nsis/code/...k/Contrib/UIs/

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 11th November 2016, 19:22   #5
Marbled
Junior Member
 
Join Date: Dec 2015
Posts: 24
Hi Anders!

Quote:
Originally Posted by Anders View Post
SendMessage $mycontrol ${LB_GETITEMDATA} $itemindex 0 $outputgoeshere but I don't remember if you can store strings there or just numbers.
I am just getting numbers out of this and no string even though I passed strings to LB_SETITEMDATA...

Is there a way to remap those numbers to the strings I passed or those messages are simply unable to handle strings at all?

Quote:
Originally Posted by Anders View Post
(Don't mix LB and CB messages)
Thank you!

I was initially searching for examples of using LB_SETITEMDATA in NSIS but when I did not found any I started searching for examples for any type of control...

When came time to add those lines I had both type of control messages (list box and combo box) mixed up...

Quote:
Originally Posted by Anders View Post
Only the Welcome and Finish pages use nsDialogs, the others are NSIS built-in pages. The resource scripts for those are @ https://sourceforge.net/p/nsis/code/...k/Contrib/UIs/
Unfortunately I don't know how to read this and I don't have the time to learn it at this time (I spent waaaaaaay too much time on this, something which I thought would be much simpler to do) so I will just do my best approximation as far as positioning is concerned...

As for the list box problem, at this point even though I don't find that clean I am tempted to do that list box the usual way (without those added SendMessage), get the selected value using ${NSD_LB_GetSelection} and then remap those display values back to the codes I need using multiple ifs or a case...

Thank you very much and have a nice day!

Nick
Marbled 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