PowerBASIC Forums
  Programming
  Help with Borje Virtual ListBox control (Page 1)

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone!
This topic is 4 pages long:   1  2  3  4 
next newest topic | next oldest topic
Author Topic:   Help with Borje Virtual ListBox control
Jules Marchildon
Member
posted April 18, 2001 12:07 PM     Click Here to See the Profile for Jules Marchildon     Edit/Delete Message   Reply w/Quote
I have started to add Borje's code to my PB/DLL SDK style template for a new
project, my "Hex Editor". For now I just want to do a file dump in Hex
to the Virtual Listbox. Then add the editing handlers later.

My first question is when I resize the Listbox control to the parents
client area inside the WM_SIZE block...
[code
CASE %WM_SIZE
Call GetClientRect( hWnd,rc )
x& = 0
y& = 0
cx& = rc.nRight
cy& = rc.nBottom -10
Call MoveWindow( hVList1, x&, y&, cx&, cy&, 1 )
Call SendMessage( hVList1, %VLB_SIZEHANDLER, 0, 0 )
Call InvalidateRect( hVList1, ByVal %NULL, 1 )
Call UpdateWindow( hVList1 )
[/code]

This seems to work except for when the List has been scrolled to
near the bottom, at that point, just before I resize the control,
the scrollbar becomes nonfunctional until I page back up to the top.

Is their another message that will update the scrollbar? Or have I
incorrectly resized the VListbox control?

Next, for Borje, I was wondering, "in-a-no-pressure-kind-of-a-way"
if you have you added the HorzScrollbar handler yet?

In anycase, I need to dig deeper into the C/C's include file to see
if I should make some changes.

Many Thanks!
Regards,
Jules


IP: Logged

Borje Hagsten
Member
posted April 18, 2001 03:53 PM     Click Here to See the Profile for Borje Hagsten     Edit/Delete Message   Reply w/Quote
Hm, yes - first error is fixed by changing @v.wFirstLine = .. in
WM_PAINT to:

@v.wFirstLine = MAX&(0, MIN&(@v.wFirstLine, @v.tLineCount - @v.wMaxHeight + 1))

Regarding horizontal scrollbar - I have started with it, but other
things got in the way. I'll see if I can finish it up and post an
updated sample as soon as possible. Some other things that needs to
be taken care of in it too, I think.

Also, I have some other things I want to add to it too, like tab
position handling, possibility to use different column colors and
grid lines, etc. Most of that code is ready - I use it in the latest
beta of Poffs. It's a bit of a mess that needs to be cleaned up before
I release it though, because otherwise people will get a lot trouble,
trying to understand how to use it properly..

I say like PB - next update will fix all these things..

------------------

IP: Logged

Mike Burns
Member
posted April 18, 2001 05:03 PM     Click Here to See the Profile for Mike Burns     Edit/Delete Message   Reply w/Quote
I wanted to thank you for posting the virtual listbox code Borje.
It was very easy to bind the listbox to a database and has been
invaluable in a number of programs. Great job and wonderfully adaptable
code.

Mike

------------------

IP: Logged

Jules Marchildon
Member
posted April 18, 2001 07:16 PM     Click Here to See the Profile for Jules Marchildon     Edit/Delete Message   Reply w/Quote
Borje!

Borje, your countryman, Mats Sundin did his job tonight, clean sweep'd the Sen's.
He is well worth the $4M/yr! On to the next round of the playoffs.
Go! Leafs Go!

I had a chance to go over the pbvlist.inc custom control and better understand
it's functionality. I am going to add the Horz Scroll handler now and I
am going to add some additional stuff for the WM_PAINT block.

Great work Borje! I have had alot of fun with all your hard work.

Regards,
Jules

IP: Logged

Jules Marchildon
Member
posted April 23, 2001 08:41 AM     Click Here to See the Profile for Jules Marchildon     Edit/Delete Message   Reply w/Quote
Dear Borje and other PBVLIST users;

Regarding the Vertical ScrollBar Thumb tracking...

Before I started to add the Horziontal Scrollbar handler, I noticed that
when the VList control is maximized(my screen 1024x768) the mouse arrow
does not track the Vscroll bar thumb correctly. I have tried a few
optimizations, even used stand alone ScrollBars too see if I can improve
it, without any luck so far. I have done some other optimizations inside
the WM_PAINT handler, with no luck either. I have come to the conclusion
that the delayed response is directly proportional to the time it takes
to refresh the screen.

For my testing, I only loaded up the VLIST with 1000 items and drag the
Vscroll Thumb up and down less than fast. The smaller the Client area,
the better the tracking. But for my Hex Editor, I want to have a sizable
frame and in most cases it will be maximized to fit the Main Window.

Hmmm... The Editor control in your Poffs 2nd generation does the same thing.
There must be a solution here, since most Programmers editors mouse Arrow seems
to track very well.

If anyone has any thoughts/tips/solutions, please kindly express them here.

Thank you kindly,
Regards,
Jules


'-------------------------
EMAIL: jmarchildon@look.ca


IP: Logged

Borje Hagsten
Member
posted April 23, 2001 03:02 PM     Click Here to See the Profile for Borje Hagsten     Edit/Delete Message   Reply w/Quote
Nor sure I understand. Do you mean the mouse arrow isn't "stuck" to
the scrollbar drag handle? Without syntax highlighting on, it performs
better, but on, plus large screen and slow computer, it kind of floats
a bit, yes I know. I can actually se the same thing in both CodeMax and
PBedit.

Reason is line parsing and painting different syntax highlight colors
takes extra time. Large screen means more lines to draw, so speed is
slower.

Something that may improve performance is by setting Class style to 0
and hbrBackground to %NULL. The list takes care of all painting anyway,
so those things aren't really needed. Other than that - have you added
any parsing code to your control yet? If so, maybe that is where to look
for slow down. Plain virtual list looks alright here for me, but as
I said, in editor and syntax highlight on, it kind of floats a bit due
to all the extra things that must be dealt with.

Improvements to both list and editor is in the makes, but my time
is very limited right now, so it may take a while before I can have
them ready for release.

------------------

IP: Logged

Jules Marchildon
Member
posted April 23, 2001 07:22 PM     Click Here to See the Profile for Jules Marchildon     Edit/Delete Message   Reply w/Quote
Hi Borje;

Yes, your observation is correct...
"the mouse arrow isn't "stuck" to the scrollbar drag handle?"
"it kind of floats a bit"

My machine is 360MHZ, the test code just uses your memdc with
textout and finally blit'd, nothing more than that for now while
I investigate it. On my machine, I do not see the PB/IDE behave
as such even with syntax on and 15000 lines of code. Maybe different
for other machines.

Okay, no big deal, I can live with that, just poking around for clues.
And Borje, many thanks for all your hard work and sharing this with the
PB community... Your'e the GREATEST!!!!!

Thanks Again!
Regards,
Jules

IP: Logged

Borje Hagsten
Member
posted April 28, 2001 07:08 PM     Click Here to See the Profile for Borje Hagsten     Edit/Delete Message   Reply w/Quote
Found it, Jules! The reason why it floats is the combination of
InvalidateRect and Updatewindow in WM_VSCROLL. Remove UpdateWindow
and only use InvalidateRect, and mouse sticks to the thumbtrack
like it should.

Why this is so, I can't really understand - but it works..


------------------

[This message has been edited by Borje Hagsten (edited April 28, 2001).]

IP: Logged

Jules Marchildon
Member
posted April 29, 2001 07:48 PM     Click Here to See the Profile for Jules Marchildon     Edit/Delete Message   Reply w/Quote
Hmm... Borje, how fast is your machine? My machine is 18 months old,
360MHZ and running 1024x768. I did that earlier and found no improvements.
I even replace the InvalidateRect with ScrollWindow, and got a slight improvement,
but it is not completely gone yet. I am still studying this problem.
Again, it is most noticable when the window is maximized. The smaller
the client area, the better it is. On my machine usually I see the
wishy-washy tracking whe the client area is about 70%+ of my LCD screen.
This has to do with the "time" to handle the WM_PAINT block. In my simple
editor it just consist of black text on white backgound and no parsing,
just a plain text dump to the memory DC and then Bit-bangged to the hDC.
Alot less time then your colorizer parser.

Regards,
Jules

IP: Logged

Gösta H. Lovgren-2
Member
posted April 15, 2003 06:13 PM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
Hi Borje,

Love your Virtual ListBox. However I'm having a problem getting
the highlight to show when I resort (reorder) the array.

In the following code the array displays fine but there is no
highlight until an arrow key (or mouse click) unless the
Index_Item_Number_To_Display is within the first few items
in the list (28 in my screen). If an Up/Down arrow key the
highlight jumps to the Item adjacent to
Index_Item_Number_To_Display so %VLB_SETSELECTED is doing its
job. I just can't get the highlight to display until a
key is pressed.


' %VLB_SETSELECTED - sets selected line number ((array item)
' wParam = Line to select.
' lParam = Redraw flag. %TRUE to redraw, %FALSE to ignore

lprm = %True '%False
SendMessage hVList1, %VLB_SETSELECTED, Index_Item_Number_To_Display, lprm
SetFocus hVList1

'' didn't work
' Control Redraw hDlg, %Id_ListBox

'' none of these work either
' SendMessage hVList1, %VLB_SETTOPLINE, Index_Record_To_Display, lprm
' SendMessage hVList1, %VLB_REFRESH, 0, 0 'array order changed so refresh

' %VLB_SETTOPLINE - sets first visible line in control
' wParam = Line to show as top (first visible) line.
' lParam = Redraw flag. %TRUE to redraw, %FALSE to ignore
' Returns: Index of top line, or -1 if no items are available.
' Example: index = SendMessage(hWndCtrl, %VLB_SETTOPLINE, TopLine, %TRUE)

'doesn't work either
' ListBox Select hDlg, %Id_ListBox, Index_Item_Number_To_Display 'Highlight

------------------
Thx............Gösta
Gosta@SwedesDock.com
http://www.SwedesDock.com
http://www.PondersBible.com

[This message has been edited by Gösta H. Lovgren-2 (edited April 15, 2003).]

IP: Logged

Borje Hagsten
Member
posted April 15, 2003 06:44 PM     Click Here to See the Profile for Borje Hagsten     Edit/Delete Message   Reply w/Quote
Thanks! Hm, following works for me, like if I want selLine to show up at top:

SendMessage hVList1, %VLB_SETSELECTED, selLine, 0
SendMessage hVList1, %VLB_SETTOPLINE, selLine, 1

This way is also used in POFFS, which uses this virtual list for found items,
when "header" is clicked for sort and selected item stays visible after sort.

So not sure I understand what you mean. Maybe you can use small sample code
to reproduce the problem?

------------------
http://www.tolkenxp.com/pb
Download: incLean, PBcodec, custom controls and code, etc.
Borje Hagsten - pb@tolkenxp.com

IP: Logged

Gösta H. Lovgren-2
Member
posted April 16, 2003 07:01 AM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
quote:
Originally posted by Borje Hagsten:
Thanks! Hm, following works for me, like if I want selLine to show up at top:

SendMessage hVList1, %VLB_SETSELECTED, selLine, 0
SendMessage hVList1, %VLB_SETTOPLINE, selLine, 1

This way is also used in POFFS, which uses this virtual list for found items,
when "header" is clicked for sort and selected item stays visible after sort.
...<snip>


Works for me too .......... NOW!.

Tried all kinds of combinations but just never hit the right one.

Or maybe VBL just wouldn't work until it had been "blessed" by
the master. {grin}

Thanks.

------------------
Thx............Gösta
Gosta@SwedesDock.com
http://www.SwedesDock.com
http://www.PondersBible.com

IP: Logged

Gösta H. Lovgren-2
Member
posted April 16, 2003 08:31 AM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
Borje,

I'm not understanding something here (What else is new?).
When my program increments the list item number past what is
showing in the VLB, the list doesn't visibly scroll unless I
send a %VLB_SETTOPLINE.

I send:


Sub VBL_Highlight(Item_To_HighLight AS LONG)
'-1 because VLB array starts at 0 and mine starts at 1

SendMessage hVList1, %VLB_SETSELECTED, Item_To_HighLight - 1, 1

''If I rem out next line (%VLB_SETTOPLINE), highlight moves but doesn't show
''if highlight moves past last dosplayed item.
''though correct item is selected. IOW the VBL array doesn't move down in
''te Virtual Listbox

SendMessage hVList1, %VLB_SETTOPLINE, Item_To_HighLight -1 , 1

'' Note %VLB_SETTOPLINE (if not remmed) works as expected and the highlight shows as the
'' first item in the displayed portion of the list (which is fine).

End Sub

I guess what I thought by looking at it is that %VLB_SETSELECTED
would (all by itself) highlight the Item_To_HighLight and if
Item_To_HighLight was greater than the highest item displayed
the list would move up to show Item_To_HighLight as the bottom
displayed item.


------------------
Thx............Gösta
Gosta@SwedesDock.com
http://www.SwedesDock.com
http://www.PondersBible.com

[This message has been edited by Gösta H. Lovgren-2 (edited April 16, 2003).]

IP: Logged

Borje Hagsten
Member
posted April 16, 2003 09:34 AM     Click Here to See the Profile for Borje Hagsten     Edit/Delete Message   Reply w/Quote
Ok, I understand. You mean like LB_SETCURSEL in ListBox. I'll add it to
the control, thanks for the tip! There are some other things I would like
to add too, so won't upload new file yet, but in the meantime, maybe you
can use the following:

'in PBVlist.inc, add an equate like:
%VLB_SETCURSEL = %WM_USER + 9 'wParam sets sel. Behaviour like LB_SETCURSEL.


'in PBVlist.inc - VListProc - paste the following right before %VLB_GETTOPLINE message:

CASE %VLB_SETCURSEL
IF wParam < 0 THEN
@v.SelLine = -1
ELSE
@v.SelLine = MIN&(wParam, @v.tLineCount)
IF @v.SelLine < @v.wFirstLine THEN
@v.wFirstLine = @v.SelLine
ELSEIF @v.SelLine > @v.wFirstLine + @v.wMaxHeight - 1 THEN
@v.wFirstLine = MIN&(@v.SelLine - @v.wMaxHeight + 1, @v.tLineCount - @v.wMaxHeight + 1)
END IF
END IF

SetPBVLScrollData hwnd, @v.wMaxHeight, MAX&(0, @v.tLineCount), @v.wFirstLine, %SB_VERT
InvalidateRect hWnd, BYVAL %NULL, 0 : UpdateWindow hwnd
FUNCTION = @v.SelLine


'then use in code, like
SendMessage hVList1, %VLB_SETCURSEL, Item_To_HighLight, 0

------------------
http://www.tolkenxp.com/pb
Download: incLean, PBcodec, custom controls and code, etc.
Borje Hagsten - pb@tolkenxp.com

IP: Logged

Gösta H. Lovgren-2
Member
posted April 16, 2003 05:24 PM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
Thanks, Borje.

You da bomb! (American teenager slang for The Best{grin})

------------------
Thx............Gösta
Gosta@SwedesDock.com
http://www.SwedesDock.com
http://www.PondersBible.com

[This message has been edited by Gösta H. Lovgren-2 (edited April 16, 2003).]

IP: Logged


This topic is 4 pages long:   1  2  3  4 

All times are EasternTime (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | PowerBASIC BASIC Compilers

Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.


Ultimate Bulletin Board 5.45c