Autoscroll oversized userControl in panel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?TmV3YnJv?=

    #1

    Autoscroll oversized userControl in panel

    I have this program running on PDA compact framework in which it will receive
    paint message from server's networkstream and updates the client's screen by
    drawing on this custom 'Draw' userControl.

    Now on the PDA this 'Draw' userControl has a size of 480 x 320.
    This control is added to a panel with autoscroll set to true. Since the PDA
    screen has a size of 320 x 240, scroll will always be visible and show the
    left top sectionof the userControl.

    The program can receive paint message and update the PDA screen just fine by
    drawing on this userControl, however at some point if the draw point if
    outside of the current clientRectangle , I want to scroll this point before
    drawing on the userControl. However I'm not sure how to do that. Since
    clientRectangle can only be read, I've tried us this.Bounds or similar
    functions but doesn't seem to do the job.

    Any ideas would be great, Thanks in advanced
  • Peter Duniho

    #2
    Re: Autoscroll oversized userControl in panel

    On Tue, 04 Mar 2008 17:28:00 -0800, Newbro
    <Newbro@discuss ions.microsoft. comwrote:
    [...]
    The program can receive paint message and update the PDA screen just
    fine by
    drawing on this userControl, however at some point if the draw point if
    outside of the current clientRectangle , I want to scroll this point
    before
    drawing on the userControl. However I'm not sure how to do that. Since
    clientRectangle can only be read, I've tried us this.Bounds or similar
    functions but doesn't seem to do the job.
    >
    Any ideas would be great, Thanks in advanced
    Well, the first thing that comes to mind is the DisplayRectangl e and
    AutoScrollPosit ion properties. Changing either of them affects what is
    shown in the ScrollableContr ol (which Panel inherits). If I recall
    correctly, changing DisplayRectangl e won't update the scroll bars
    automatically (there's another method to do that), so probably you want to
    set AutoScrollPosit ion.

    That said, I'm also a bit confused by your description. Your post says
    that you are drawing into a custom UserControl. However, typically a
    UserControl is used for composition of other controls. If you're
    compositing other controls, then it seems to me that your panel should
    instead be a UserControl and should directly contain the other controls
    you want. If that's the case, then you can just use the
    ScrollControlIn toView() method to show whatever needs to be shown.

    On the other hand, if you're not compositing and you're doing all the
    drawing yourself, it seems like the custom control should just be derived
    from Control directly. Using a UserControl is overkill in that
    situation. Alternatively, your custom control can inherit
    ScrollableContr ol. That would provide the flattest control hierarchy; I
    don't see any reason to nest controls when you don't need to. Just draw
    whatever you're drawing into the DisplayRectangl e, which will be updated
    according to the scroll position. Set the AutoScrollPosit ion as necessary
    to ensure that the "draw point" is within the viewable area.

    Pete

    Comment

    Working...