- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do I highlight items that was selected in a list box on previous calls to the list box?
Neels
Neels
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure if it is possible, but you could try sending LB_SELITEMRANGE message with the fselect argument set to .TRUE. and the selection argument set to MAKELPARM(itemno,itemno) for each itemno in the list that you select?
iret=SendDlgItemMessage(hDlg,IDC_LISTBOX,LB_SELITEMRANGE, .TRUE.,MAKELPARAM(itemno,itemno) )
I'm not sure if an item will remain highlighted when you move on to the next item.
iret=SendDlgItemMessage(hDlg,IDC_LISTBOX,LB_SELITEMRANGE, .TRUE.,MAKELPARAM(itemno,itemno) )
I'm not sure if an item will remain highlighted when you move on to the next item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Anthony,
I could not get it to work - maybe my own stupidity. I also tried the following without success:
bret = DlgSet(dlg, IDC_LIST_Plot_Select, i, DLG_SELCHANGE)
I could not get it to work - maybe my own stupidity. I also tried the following without success:
bret = DlgSet(dlg, IDC_LIST_Plot_Select, i, DLG_SELCHANGE)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting neels
How do I highlight items that was selected in a list box on previous calls to the list box?
A list box keeps its selection as long as the dialog box is alive. If you want to persist the selection between different invocations of the dialog box, and it is a multi-selection list, you have to store it in a SAVEd (or MODULE) variable.
To retrieve a multi-selection from a list box, use the following code structure (well, if I recall correctly, haven't used the feature for ages):
[fortran]integer, allocatable, save:: selection(:) integer, save:: numSelected=0 logical:: ret !Setting the selection do i = 1,numSelected ret = DlgSet(dlg, IDC_LISTBOX, selection(i), i) end do ret = DlgModal(...) !Retrieving the selection if (.not.allocated(selection)) allocate(selection(numItems)) numSelected = 0 selection = 0 do while(DlgGet(dlg, IDC_LISTBOX, selection(numSelected+1), numSelected+1)) numSelected = numSelected+1 end do [/fortran]
Hope this helps,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jugoslav
I have the code as you suggested. It works fine to do a multiple selection from the list box. If I close the list box (and in this case) plot the selected curves, it works. If I open the list box again, I can select more items and then they, as well as the previously selected items are now plotted. What I need is on the second (and subsequent) visits to the list box for the selected items in the list box to be highlighted so I can unselect some of them and add others. To select and unselect them I can do the code, but to highlight the previously selected ones on the second or more visits is what I have trouble with.
Thanks
Neels
I have the code as you suggested. It works fine to do a multiple selection from the list box. If I close the list box (and in this case) plot the selected curves, it works. If I open the list box again, I can select more items and then they, as well as the previously selected items are now plotted. What I need is on the second (and subsequent) visits to the list box for the selected items in the list box to be highlighted so I can unselect some of them and add others. To select and unselect them I can do the code, but to highlight the previously selected ones on the second or more visits is what I have trouble with.
Thanks
Neels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Um, still not sure that I follow when your "I" means "Neels the programmer" and when "Neels the user" :D. I don't think that a list item can be three-state ("selected", "highhighted" and "none").
What you describe vaguely resembles the UI pattern where you have two distinct "Available" and "Selected" lists, and have two buttons to move from one to another, like in the picture below. In the left list, you would maintain "Available" curves, and in the right, the "Selected" curves, which you will have to persist between calls; no item may be in both lists simultaneiously. Am I on the right track?
![](http://www.uwec.edu/HELP/Word07/Images/dialog/organizer.gif)
What you describe vaguely resembles the UI pattern where you have two distinct "Available" and "Selected" lists, and have two buttons to move from one to another, like in the picture below. In the left list, you would maintain "Available" curves, and in the right, the "Selected" curves, which you will have to persist between calls; no item may be in both lists simultaneiously. Am I on the right track?
![](http://www.uwec.edu/HELP/Word07/Images/dialog/organizer.gif)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first time I open the list box it looks as follows:
![](http://www.designababies.co.za/downloads/screen1.bmp)
I then select some items to plot:
![](http://www.designababies.co.za/downloads/screen2.bmp)
And then I plot them.
Now I want to add more items to plot and remove some previously selected but when I open the list box again, it looks like the first time, not as it was after I selected the items to plot. I want it to now look as it does in the second figure above.
It is straight forward to do the book keeping to know which items selected on previuos calls to highlight on the subsequent calls to the list box, I just cannot get them highlighted. Myquestion is: How do I do it?
Hope this explains better.
Neels
![](http://www.designababies.co.za/downloads/screen1.bmp)
I then select some items to plot:
![](http://www.designababies.co.za/downloads/screen2.bmp)
And then I plot them.
Now I want to add more items to plot and remove some previously selected but when I open the list box again, it looks like the first time, not as it was after I selected the items to plot. I want it to now look as it does in the second figure above.
It is straight forward to do the book keeping to know which items selected on previuos calls to highlight on the subsequent calls to the list box, I just cannot get them highlighted. Myquestion is: How do I do it?
Hope this explains better.
Neels
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I apologize in advance for being dense; have in mind that I'm a Bosnian after all :).
I believe I answered that question above, in my first post; did you perhaps skim it too quickly? According to the documentation (haven't tried it for a long time, please verify), the following code:
do i=1,3
ret = DlgSet(dlg, IDC_LISTBOX, i*2, i)
end do
will select the 2nd, 4th and 6th item in a multi-selection list box. If you replace the "i*2" with A(i), where A is an array of indices, it will select items with indices A(1), A(2) and A(3). You get the contents of A from the previous invocation of the dialog box, as I outlined in my previous post.
Now, you would have a problem if in the meanwhile you remove or add some items at the beginning of the list, i.e. if the "PITrace(1)" was the 2nd item in first call, but will become 1st in the second call. If that's your situation, tough luck, you will have to do some string matching (i.e. instead of array of indices use an array of strings), but you didn't indicate so far that would be the case.
I believe I answered that question above, in my first post; did you perhaps skim it too quickly? According to the documentation (haven't tried it for a long time, please verify), the following code:
do i=1,3
ret = DlgSet(dlg, IDC_LISTBOX, i*2, i)
end do
will select the 2nd, 4th and 6th item in a multi-selection list box. If you replace the "i*2" with A(i), where A is an array of indices, it will select items with indices A(1), A(2) and A(3). You get the contents of A from the previous invocation of the dialog box, as I outlined in my previous post.
Now, you would have a problem if in the meanwhile you remove or add some items at the beginning of the list, i.e. if the "PITrace(1)" was the 2nd item in first call, but will become 1st in the second call. If that's your situation, tough luck, you will have to do some string matching (i.e. instead of array of indices use an array of strings), but you didn't indicate so far that would be the case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Jogoslav
Yes, you did answer my question in your first post, I just did not realize it- seeing that neither our mother tongues is English!
I have it working now.
Neels
Yes, you did answer my question in your first post, I just did not realize it- seeing that neither our mother tongues is English!
I have it working now.
Neels
![](/skins/images/7FC17B7B85029576C25F1E43CE255B51/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page