IonicWind Software

IWBasic => General Questions => Topic started by: Brian on May 02, 2012, 06:24:32 AM

Title: Dual Scrollbars
Post by: Brian on May 02, 2012, 06:24:32 AM
Hi,

Thinking out loud here. You've got two listboxes filled with data. You move the vertical scrollbar
on the lefthand box, and the vertical scrollbar moves in the righthand box, in sync

Maybe the same with the horizontal scrollbars

Is this possible? Make my day!

Brian
Title: Re: Dual Scrollbars
Post by: LarryMc on May 02, 2012, 08:25:44 AM
CONST LB_GETTOPINDEX = 0x18E
CONST LB_SETTOPINDEX = 0x197

CONST LISTBOX_1 = 1
CONST LISTBOX_2 = 2
CONST BUTTON_3 = 3
DIALOG d1
CREATEDIALOG d1,0,0,320,202,0x80CB0080,0,"Scroll Sync",&d1_handler
CONTROL d1,@LISTBOX,"ListBox1",28,23,126,137,@CTLISTNOTIFY|@VSCROLL,LISTBOX_1
CONTROL d1,@LISTBOX,"ListBox2",162,24,126,137,@CTLISTNOTIFY|@VSCROLL,LISTBOX_2
CONTROL d1,@SYSBUTTON,"Close",204,172,70,20,0,BUTTON_3

showdialog d1
waituntil d1=0
end

SUB d1_handler(),int
SELECT @MESSAGE
CASE @IDINITDIALOG
starttimer d1,100
CENTERWINDOW d1
for x=1 to 100
addstring d1,1,"String #"+str$(x)
addstring d1,2,"String #"+str$(x)
next x
case @IDTIMER
int pos=sendmessage d1,LB_GETTOPINDEX,0,0,1
sendmessage d1,LB_SETTOPINDEX,pos,0,2
CASE @IDCLOSEWINDOW
stoptimer d1
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE LISTBOX_1
CASE LISTBOX_2
CASE BUTTON_3
IF @NOTIFYCODE = 0
CLOSEDIALOG d1,@IDOK
ENDIF
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB


LarryMc
Title: Re: Dual Scrollbars
Post by: Brian on May 02, 2012, 09:56:20 AM
Blimey!

What can I say? Larry comes up with the goods again...

Brian
Title: Re: Dual Scrollbars
Post by: LarryMc on May 03, 2012, 07:33:09 PM
This allows sync'd scrolling of two listboxes from either listbox.(requires subclassing the LBs)
Also selects matching line in both LB's from either LB.

LarryMc
Title: Re: Dual Scrollbars
Post by: Brian on May 19, 2012, 12:31:31 PM
Larry,

Is there a way of using this technique with dual Listviews, as well?

Brian
Title: Re: Dual Scrollbars
Post by: LarryMc on May 19, 2012, 07:08:48 PM
Quote from: Brian Pugh on May 19, 2012, 12:31:31 PM
Is there a way of using this technique with dual Listviews, as well?
When I first looked at it for a listview I thought it was going to be a breeze to convert the listbox version, especially when I found that listviews have a LVM_GETTOPINDEX just like the listbox's LBM_GETTOPINDEX. ;D ;D ;D

Then  :o ??? :o ::) :'(
I discovered that listviews don't have a LVM_SETTOPINDEX just like the listbox's LBM_SETTOPINDEX.

So, I had to to do some looking and heavy duty head scratching.

The result is attached.  Because there are fundmental differences between how listviews and listboxes work there are some differences.

The listview version does sync the 2 LVs when the scroll bars are used just like the LBs.
However, if you use the arrow keys they will not be in sync.

Also, when you select in one it will automaticly select the same line in the other but the selection in the 2 LVs will be different colors (one has focus and the other doesn't)

But maybe it will get you where you want to go.
Title: Re: Dual Scrollbars
Post by: RitchieF on November 16, 2013, 10:14:59 AM
Hi Larry,

QuoteIs there a way of using this technique with dual RichEdit, as well?

Richard
Title: Re: Dual Scrollbars
Post by: LarryMc on November 16, 2013, 11:02:30 AM
Quote from: RitchieF on November 16, 2013, 10:14:59 AM
Is there a way of using this technique with dual RichEdit, as well?
With all the messages that are available to richedits I would have to say yes(for the most part)
It would really come down to the specifics of what you are trying to do(and I do mean SPECIFIC).