473,399 Members | 2,858 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,399 software developers and data experts.

AutoScroll returning to 0,0 somewhere around focus

Not having much luck tracking this down...

I'm working with a form, Form1, which contains a panel called pnlParent.
Both Form1 and pnlParent have AutoScroll = False.

pnlParent contains a panel called pnlScroller. pnlScroller.AutoScroll =
True. Finally, pnlScroller contains a custom control I wrote (in which I
override OnPaint & paint entirely custom, if that matters). So in summary
there are 4 controls with the following parent/child heiarchy:

Form1 -> pnlParent -> pnlScroller (autoscrolls) -> myControl (custom
painted)

myControl is always bigger in dimensions than pnlScroller, so pnlScroller
always shows both vertical and horizontal scrollbars. At run time, if I
grab either of pnlScroller's scrollbars & move it anywhere, I can scroll
over myControl and it works as I would expect to "scroll over" myControl.
If I then "click away" from Form1 (say, to the desktop) so that Form1 looses
Focus, the scroll bars on pnlScroller remain where I left them.

However, clicking back (or, Alt+Tab) onto on to Form1 so that it regains
Focus causes the scrollbars on pnlScroller to both return to 0,0. This is
an undesired feature of my application, because I want pnlScroller's scroll
bars to remain stationary unless the user scrolls them (I do not want
application focus to alter the scroll position). I do not have any code in
the application that programatically sets the scroll position.

I have tried to trap where this is happening in some of the obvious places,
like Form1.GotFocus, Form1.Activated and pnlScroller.GotFocus but by the
time these events have fired, the scrollbars have already 'adjusted'
themselves to 0,0. Any advice on where I can set a trap to catch this as it
is happening? I believe that pnlScroller is attempting to perform some
logic where it tries to "fit" myControl into it's viewable area and the
scrolling to position 0,0 in an artifact of this attempt. But since this is
an impossible task (because myControl is always larger than pnlScroller), I
want to supress this behavior some how.
Nov 21 '05 #1
1 1950
"Workgroups" <no*****@domainless.com> schrieb
Not having much luck tracking this down...

I'm working with a form, Form1, which contains a panel called
pnlParent. Both Form1 and pnlParent have AutoScroll = False.

pnlParent contains a panel called pnlScroller. pnlScroller.AutoScroll =
True. Finally, pnlScroller contains a
custom control I wrote (in which I override OnPaint & paint entirely
custom, if that matters). So in summary there are 4 controls with
the following parent/child heiarchy:

Form1 -> pnlParent -> pnlScroller (autoscrolls) -> myControl (custom
painted)

myControl is always bigger in dimensions than pnlScroller, so
pnlScroller always shows both vertical and horizontal scrollbars. At run
time, if I grab either of pnlScroller's scrollbars & move it
anywhere, I can scroll over myControl and it works as I would expect
to "scroll over" myControl. If I then "click away" from Form1 (say,
to the desktop) so that Form1 looses Focus, the scroll bars on
pnlScroller remain where I left them.

However, clicking back (or, Alt+Tab) onto on to Form1 so that it
regains Focus causes the scrollbars on pnlScroller to both return to
0,0. This is an undesired feature of my application, because I want
pnlScroller's scroll bars to remain stationary unless the user
scrolls them (I do not want application focus to alter the scroll
position). I do not have any code in the application that programatically
sets the scroll position.

I have tried to trap where this is happening in some of the obvious
places, like Form1.GotFocus, Form1.Activated and
pnlScroller.GotFocus but by the time these events have fired, the
scrollbars have already 'adjusted' themselves to 0,0. Any advice on
where I can set a trap to catch this as it is happening? I believe
that pnlScroller is attempting to perform some logic where it tries
to "fit" myControl into it's viewable area and the scrolling to
position 0,0 in an artifact of this attempt. But since this is an
impossible task (because myControl is always larger than
pnlScroller), I want to supress this behavior some how.

I can reproduce this. I took a Button instead of a Usercontrol for
simplification - no difference. After debugging it seems that the method
ScrollControlIntoView is called whenever the control gets the focus.

Whenever the form is activated, it focusses it's active control. This is the
button. The button, when getting the focus, checks whether it is contained
by an instance of 'ContainerControl'. If it is, it calls it's Container's
method to activate the active control. This includes calling
ScrollControlIntoView.

Unfortunately I don't have a solution. I didn't find where to hook into this
process, but based on this information maybe you (or somebody else) can find
one on your own.
Armin

Nov 21 '05 #2

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

Similar topics

0
by: Alexander Brown | last post by:
I have a custom control inside a frame. The frame has autoscroll set to true. The control has its dock set to Fill, and anchose set to top and left. If i scroll around the control using the...
0
by: rawCoder | last post by:
If an item is added in a grid, then the grid scrolls automatically either to bring the selected or the last entered item in focus. Is there a way to disable this scrolling. Means, If I am...
0
by: 23s | last post by:
I have 2 rich textboxes within an auto-scrolling panel object. The textboxes aren't wider than the panel, so it never scrolls horizontally. But the combined height of both textboxes is taller than...
4
by: Sam | last post by:
Hi, I'm using the property autoscroll = true on my forms. I have to. But the issue is that I soon as you give the focus to, say a control in the middle of the form, the scrollbar will scroll down...
21
by: Sharon | last post by:
I have added an auto scroll feature to my DataGrid control like this: private void DoAutoScroll() { DataView dv = m_DataGrid.DataSource as DataView; DataGridCell cell = m_DataGrid.CurrentCell;...
0
by: eweaver | last post by:
Hello, I have a problem with getting an autoscrollbar to end up where I want it. Things to know about the prob: I have an imagebox inside of a Panel for (inheritance of) autoscroll capabilities....
6
by: student1976 | last post by:
All Beginner/Intermediate level question. I understand that returning ptr to local stack vars is bad. Is returning foo_p_B from fnB() reliable all the time, so that using foo_p_A does not...
5
by: sherifffruitfly | last post by:
Hi, I want to derive of of TextBox, and add on an auto-scroll-to-bottom boolean property. I can use a regular textbox (rich or otherwise) and get the effect by: mytextbox.append("my text");...
160
by: DiAvOl | last post by:
Hello everyone, Please take a look at the following code: #include <stdio.h> typedef struct person { char name; int age; } Person;
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.