473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Questions about ScrollableControl

Hi all,

I have a few questions on deriving from ScrollableControl that I hope
will be relatively easy to answer. I am using Visual Studio 2003, C# and
..Net 1.1.

I have this custom control I am making called ResourceView. It is
supposed to show a visual overview of resource usage over time. Time is
represented by the X axis, and the different resources (people,
equipment, rooms etc.) are in the Y axis. Usually one will view a
limited amount of resources (a logical group/unit for instance) and time
(a 24 hour period) at once, but it will be possible to display all
resources for an entire time period - this will naturally lead to a
large amount of items.

Currently I have one control which is made up of three ScrollableControl
objects (extended slightly to allow me to manually control scroll
positions and also set scroll positions) - on the top is the time ruler,
on the left is the vertical resource list, and the rest (except for the
empty top left corner) is occupied by the actual view. The view is
currently a large canvas where I paint the resource "events" as square
boxes that visually give you an idea how long they last and when they
start in relation to other resource events. Each of these boxes is
actually inside another control (one per resource) that spans the length
of the view and contains all the events of a single resource - I call
these ResourceStrips for now.

When you scroll the view horizontally, the time ruler is also made to
scroll the same amount of pixels, so that the events and their place in
time lines ut properly. Likewise, when the view is scrolled vertically,
the resource list on the left is manually scrolled to keep up.

So far, all is good. I put my ResourceView into a form and dock it to
fill the entire thing. In the controls' OnResize I manually resize the
time (top) and resource (left) controls to keep up - the built in
docking functionality does not work the way I need it to. So the control
resizes beautifully and it all seems relative light on resources.

However, there are a few issues (and finally he gets to the point..?);

1) When I resize the window, the scrollbars on the top and left controls
flash on and off; This seems to happen in the ScrollableControl OnLayout
method, but I am not sure. Can I get rid of this? If I override OnLayout
and don't let it call base.OnLayout(), it stops flashing but it also
stops doing much of anything else, including scrolling.

2) If I click in the main view, it will reset to horizontal position
zero, and scroll vertically so the entire "resource row" (i.e.
ResourceStrip control) is in view. I am guessing this is due to some
sort of EnsureVisible() thing on the ResourceStrip? I think it is worth
nothing that the scroll reset occurs on mousedown - it doesn't wait for
me to release the mouse button. Is this a focus thing? And more
importantly, can I get rid of it?

3) Currently, each resource event (i.e. the square boxes that make up
the contents of the ResourceStrips) is simply painted on - they are not
controls. These controls could get quite heavy, in theory 500-1000
events in one view. I will need these to react to clicks and mouseovers.
Is it better to create these as individual lightweight controls? Or
should I keep painting them as graphics on the ResourceStrips.

I hope some friendly soul can shed some light on this as my head is
almost out of hair..

Thank you very much in advance for the help!

Rune
Mar 22 '07 #1
2 5550
However, there are a few issues (and finally he gets to the point..?);

1) When I resize the window, the scrollbars on the top and left controls
flash on and off; This seems to happen in the ScrollableControl OnLayout
method, but I am not sure. Can I get rid of this? If I override OnLayout
and don't let it call base.OnLayout(), it stops flashing but it also stops
doing much of anything else, including scrolling.
use SuspendLayout and ResumeLayout when resizing everything.
>
2) If I click in the main view, it will reset to horizontal position zero,
and scroll vertically so the entire "resource row" (i.e. ResourceStrip
control) is in view. I am guessing this is due to some sort of
EnsureVisible() thing on the ResourceStrip? I think it is worth nothing
that the scroll reset occurs on mousedown - it doesn't wait for me to
release the mouse button. Is this a focus thing? And more importantly, can
I get rid of it?

3) Currently, each resource event (i.e. the square boxes that make up the
contents of the ResourceStrips) is simply painted on - they are not
controls. These controls could get quite heavy, in theory 500-1000 events
in one view. I will need these to react to clicks and mouseovers. Is it
better to create these as individual lightweight controls? Or should I
keep painting them as graphics on the ResourceStrips.
Every control requires an OS window, which won't be as efficient for
hit-testing as a binary search of a sorted list.

Just try and avoid painting areas that are scrolled off-screen, to keep
efficiency up. A resource that is partially visible can be totally painted,
using OS clipping, but if no part of the resource is visible, skip painting
it.

Your culling of off-screen resources will probably be more efficient if you
transform the current visible region back into the units of your x and y
axes (time I guess), instead of computing the screen coordinates for each
resource.
>
I hope some friendly soul can shed some light on this as my head is almost
out of hair..

Thank you very much in advance for the help!

Rune

Mar 22 '07 #2
Ben Voigt wrote:
>1) When I resize the window, the scrollbars on the top and left controls
flash on and off; This seems to happen in the ScrollableControl OnLayout
method, but I am not sure. Can I get rid of this? If I override OnLayout
and don't let it call base.OnLayout(), it stops flashing but it also stops
doing much of anything else, including scrolling.
use SuspendLayout and ResumeLayout when resizing everything.
Thanks for the suggestion - I was kicking myself that I didn't think of
this myself. However, in the "main" components OnResize() override, I
tried SuspendLayout() on the control itself, and around each of the
other ScrollableControl derived controls when their size was changed,
and when I resize the window now, I still see the scrollbar flashing.

It is perhaps worth noting that in the ScrollableControl's OnLayout
override, I have to call the Win32 function ShowScrollBar and set both
SB_HORZ and SB_VERT to false - otherwise the scrollbar will stay
visible. And I have to do it AFTER I do base.OnLayout(), otherwise the
same will happen again.

So I'm a bit stumped as to what I have to do to keep the control from
wanting to show me the scrollbars - it stops doing it when I set
AutoScroll to false, but then it also doesn't allow me to scroll the
contents anymore..
>2) If I click in the main view, it will reset to horizontal position zero,
and scroll vertically so the entire "resource row" (i.e. ResourceStrip
control) is in view. I am guessing this is due to some sort of
EnsureVisible() thing on the ResourceStrip? I think it is worth nothing
that the scroll reset occurs on mousedown - it doesn't wait for me to
release the mouse button. Is this a focus thing? And more importantly, can
I get rid of it?
Someone? Help!? ;)
Every control requires an OS window, which won't be as efficient for
hit-testing as a binary search of a sorted list.

Just try and avoid painting areas that are scrolled off-screen, to keep
efficiency up. A resource that is partially visible can be totally painted,
using OS clipping, but if no part of the resource is visible, skip painting
it.

Your culling of off-screen resources will probably be more efficient if you
transform the current visible region back into the units of your x and y
axes (time I guess), instead of computing the screen coordinates for each
resource.
Great tips, thank you very much!
Mar 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gates72 | last post by:
Hi Gurus, I am attempting to derive a User Control from the ScrollableControl class. I need to have control over which scrollbars get displayed. According to MSDN: "To manually override...
0
by: Bob | last post by:
I implemented a ScrollableControl and only want vertical scrolling. Every time I make the form smaller then the control the control has h scroll bars even though I set it to false. I have the...
0
by: softwareengineer2006 | last post by:
All Interview Questions And Answers 10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP) I have listed over 10000 interview questions asked in interview/placement test papers for...
6
by: Yehia A.Salam | last post by:
Hello, I'm trying to create my own control derived from ScrollableControl public partial class qViewer : ScrollableControl{ public qViewer() { VScroll = true; AutoScroll = true; } ... }
0
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
2
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate...
4
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for...
8
by: Krypto | last post by:
Hi, I have used Python for a couple of projects last year and I found it extremely useful. I could write two middle size projects in 2-3 months (part time). Right now I am a bit rusty and trying...
0
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.