- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have any idea how to connect two "listboxes" so that they scroll together in dependence on one "vertical scrollbar".
I would appreciate some advice on how best to do it.
Thanks. Lada.
I would appreciate some advice on how best to do it.
Thanks. Lada.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it Win32 or DFLOGM-based dialog?
Two ideas:
1) Subclass the list boxes. In subclassed procedure(s), handle WM_VSCROLL. Scroll the other listbox when "this" one is scrolled.
2) Define a separate scrollbar control. In its callback, scroll both listboxes simultaneously. Remove the "natural" listboxes' scrolbars by removing "vertical scroll" style.
To scroll the listbox programatically:
1) Try sending it a WM_VSCROLL message (I'm not sure it will work, especially if you remove "vertical scroll") or use SetScrollPos API.
2) Send it a LB_SETCURSEL message (that will change the selection as well).
Jugoslav
Two ideas:
1) Subclass the list boxes. In subclassed procedure(s), handle WM_VSCROLL. Scroll the other listbox when "this" one is scrolled.
2) Define a separate scrollbar control. In its callback, scroll both listboxes simultaneously. Remove the "natural" listboxes' scrolbars by removing "vertical scroll" style.
To scroll the listbox programatically:
1) Try sending it a WM_VSCROLL message (I'm not sure it will work, especially if you remove "vertical scroll") or use SetScrollPos API.
2) Send it a LB_SETCURSEL message (that will change the selection as well).
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is DFLOGM-based dialog.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In that case, approach 2) looks simpler. Take care that user can navigate through listbox using keyboard arrows -- you have to write DLG_SELCHANGE callbacks to both listboxes as well and set the same selection in the other as well.
Re-thinking about all of it, what's wrong with using one listbox instead if the two are to behave like one? You can conveniently define two "columns" within one list box using "Use tab stops" style. Then, you can send the LB_SETTABSTOPS message on dialog startup to define the tab positions; when filling the listbox, separate "columns" with CHAR(9):
Re-thinking about all of it, what's wrong with using one listbox instead if the two are to behave like one? You can conveniently define two "columns" within one list box using "Use tab stops" style. Then, you can send the LB_SETTABSTOPS message on dialog startup to define the tab positions; when filling the listbox, separate "columns" with CHAR(9):
i = DlgSetSub(Dlg, IDD_DIALOG1, OnDialogInit) DO i = 1, nItems i = DlgSet(Dlg, IDC_LIST1, TRIM(sText1)//CHAR(9)//sText2, i) END DO ... SUBROUTINE OnDialogInit(Dlg, ID, iEvent) USE DFLOGM USE DFWIN IMPLICIT NONE INCLUDE "Resource.fd" TYPE(Dialog):: Dlg INTEGER:: ID, iEvent, iSt INTEGER,PARAMETER:: iTabStop(2)=(/260,300/) iSt=SendMessage(GetDlgItem(Dlg%Hwnd,IDC_LIST1), & LB_SETTABSTOPS, SIZE(iTabStop), LOC(iTabStop)) END SUBROUTINEJugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for your advice Jugoslav.
It works well. I am very satisfied.
Lada.
It works well. I am very satisfied.
Lada.

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