Board index » cppbuilder » Two more StringGrid questions

Two more StringGrid questions


2005-10-29 08:54:04 PM
cppbuilder78
Hi again,
1. Why when i try to scroll my StringGrid up and down at runtime
the StringGrid scolls only when i release my finger from the
mouse left button? I whould like to see the scrolling at real
time while i'm holding the scroll bar and scrolling it up and
down, just like what i see in a ListBox, how can i do that?
2. I set 'FixedCols' and 'FixedRows' to 1, the help says that
it means that they cannot be scrolled, then why when i run my
application and try to scroll up and down i see that the first
column and the first row are scrolled also?
Thanks.
 
 

Re:Two more StringGrid questions

"Ramy" < XXXX@XXXXX.COM >wrote:
Quote


[...] at runtime the StringGrid scolls only when i release
my finger from the mouse left button?
It doesn't do that for me. You'll need to be more specific
about what you're observing.
Quote
I set 'FixedCols' and 'FixedRows' to 1, the help says that
it means that they cannot be scrolled, [...]
If you scroll the rows, the fixed rows do not scroll. If you
scroll the columns, the fixed columns do not scroll. However,
if you scroll the rows up or down, the fixed columns will
scroll with the row that they are assigned to. The same is
true for the fixed rows.
~ JD
 

Re:Two more StringGrid questions

Quote
It doesn't do that for me. You'll need to be more specific
about what you're observing.
Using Builder 4.0, i opened a new project and put StringGrid
on it set it to 100 columns & 100 rows, at runtime, when i
hold the scrolling bar and start dragging it up and down, up
and down, i don't see any change in the StringGrid untill i
release the mouse button, only then i see a change. Why?
For example it doesn't happen to me with a ListBox, when i try
it on a ListBox the strings are scrooled WHILE i'm dragging
the scroll bar
Quote
If you scroll the rows......... However,
if you scroll the rows up or down....
What's the different between the first sentence and the second
one? i did not understand what you mean.
 

{smallsort}

Re:Two more StringGrid questions

"Ramy" < XXXX@XXXXX.COM >wrote:
Quote

[...] when i hold the scrolling bar and start dragging [...]
That would be dragging the thumb.
Quote
it doesn't happen to me with a ListBox,
For what ever the reason, the VCL doesn't impliment that
functionality (probably because of all of the repainting)
but you are free to add it yourself.
You'll need to subclass (or override) it's WndProc method
and intercept WM_VSCROLL and WM_HSCROLL. Check the win32 help
file for particulars. If you search the archives, there's most
like sample code ready to cut & paste.
Quote
>If you scroll the rows......... However,
>if you scroll the rows up or down....

What's the different between the first sentence and the second
one?
If you have FixedCols and FixedRows, what ever number you
specify for each, that's how many will always be displayed
on screen. IOW, they will not scroll off screen. However,
they will scroll to keep in sync with the data column and
rows.
If you scroll the rows up or down, the fixed columns will
scroll up or down with the data rows. However, the fixed
rows do not move. In the same fashion, if you scroll the
columns left or right, the fixed rows will also scroll left
or right but the fixed columns do not move.
Try thinking of the fixed cells as headers that stay in sync
with the column or row that they are assigned to. If you take
your test and itterate the cells, assigning the column and row
number to each cell and then play with scrolling the grid, you
should get the idea.
~ JD
 

Re:Two more StringGrid questions

Thanks, i'm reading some stuff about it right now.
 

Re:Two more StringGrid questions

What do i have to do after i intercept the WM_VSCROLL and the
WM_HSCROLL messages? what do i have to write? Refresh() ?
 

Re:Two more StringGrid questions

"Ramy" < XXXX@XXXXX.COM >wrote:
Quote

What do i have to do after i intercept the WM_VSCROLL
and the WM_HSCROLL messages?
Test the nScrollCode for SB_THUMBTRACK. When you find it,
act on it. Otherwise, do nothing. You may need to swallow
the message then as well by not passing onto the base class
handler.
Quote
what do i have to write? Refresh() ?
Just set the TopRow or LeftCol property.
~ JD
 

Re:Two more StringGrid questions

Thanks Very Much :-)
"JD" < XXXX@XXXXX.COM >wrote:
Quote

Test the nScrollCode for SB_THUMBTRACK. When you find it,
act on it. Otherwise, do nothing. You may need to swallow
the message then as well by not passing onto the base class
handler.

Just set the TopRow or LeftCol property.

~ JD
 

Re:Two more StringGrid questions

JD wrote:
Quote
Test the nScrollCode for SB_THUMBTRACK. When you find it,
act on it. Otherwise, do nothing. You may need to swallow
the message then as well by not passing onto the base class
handler.
JD, AFAIK you just need to set the goThumbTracking option in the Options
property. That takes care of it for you.
Jonathan
 

Re:Two more StringGrid questions

"Jonathan Benedicto" < XXXX@XXXXX.COM >wrote:
Quote

AFAIK you just need to set the goThumbTracking option in the
Options property.
That should do the trick.
Sorry for the extra work Ramy.
~ JD