June 27, 2024, 11:50:32 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Dual Scrollbars

Started by Brian, May 02, 2012, 06:24:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

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

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Blimey!

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

Brian

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Larry,

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

Brian

LarryMc

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.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

RitchieF

Hi Larry,

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

Richard

LarryMc

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).
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library