Knowing which part of a Window is currently visible on the display

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ganesh

    Knowing which part of a Window is currently visible on the display

    Dear Experts,
    I have an application that has several graphical components on it.
    The state of these components is decided by some data which is
    available in some data store. The graphical components periodically go
    to the data base to see if the data has changed and accordingly change
    their display state. Now its wasteful for my application to update its
    graphical state if a particular component is not being visible
    (meaning that some other Window is hiding a part or full of my
    applications Window). I am trying to figure out which part of my
    applications Window is currently visible on my computers display. This
    way, my components can decided if they have to update themselves or
    not (they could sit idle if they are not visible or could periodically
    update their state if they are visible).
    Any idea on how I can check which region on my Window is
    currently visible on the display? Thanks.

    Regards,
    Ganesh Okade
    Sunlux Technologies Ltd.
  • Peter Duniho

    #2
    Re: Knowing which part of a Window is currently visible on the display

    On Wed, 12 Mar 2008 07:50:40 -0700, Ganesh <ganeshokade@gm ail.comwrote:
    [...]
    Any idea on how I can check which region on my Window is
    currently visible on the display? Thanks.
    Well, you can find out when your control/form is actually drawn by
    checking the ClipRectangle in the PaintEventArgs. You could also just
    compare the screen location with the screen boundary.

    But IMHO this is not something you want to do. While I understand the
    concern of not being "wasteful", in practice these sorts of optimizations
    can lead to poor performance when the optimization can't be used (e.g. the
    whole window is on-screen). I've been down that road, as well as know of
    others who have, and it usually doesn't work out.

    If there's a problem with performance when part of the window is
    off-screen, then there's a problem with performance when none of the
    window is off-screen. Your effort will be better invested addressing
    performance in a more general way so that performance is acceptable
    regardless of where the window is.

    Pete

    Comment

    Working...