Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Two LISTBOXES and one SCROLLBAR

Intel_C_Intel
Employee
650 Views
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.
0 Kudos
4 Replies
Jugoslav_Dujic
Valued Contributor II
650 Views
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

0 Kudos
Intel_C_Intel
Employee
650 Views
It is DFLOGM-based dialog.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
650 Views
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):
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 SUBROUTINE
Jugoslav
0 Kudos
Intel_C_Intel
Employee
650 Views
Thanks a lot for your advice Jugoslav.
It works well. I am very satisfied.
Lada.
0 Kudos
Reply