Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to detect overlapping windows

How to detect overlapping windows

Scheduled Pinned Locked Moved C#
questionjsontutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pliu_2000
    wrote on last edited by
    #1

    Hi, I am writing an application that uses an extended listview. The extended listview is modified to reduce the flickering when being populated by only invalidating the single item being added. However, If another window is dragged to overlap my application while the listview is being populated, the listview does not redraw when the overlapping window is moved out of the way. Therefore, I think I need to capture the event when the window overlaps my control. How can I do this? I believe there is an win api that can flag this, but I am not sure which one. Anyone know or anyone have a better approach? Thanks in advance Peter

    J J 2 Replies Last reply
    0
    • P pliu_2000

      Hi, I am writing an application that uses an extended listview. The extended listview is modified to reduce the flickering when being populated by only invalidating the single item being added. However, If another window is dragged to overlap my application while the listview is being populated, the listview does not redraw when the overlapping window is moved out of the way. Therefore, I think I need to capture the event when the window overlaps my control. How can I do this? I believe there is an win api that can flag this, but I am not sure which one. Anyone know or anyone have a better approach? Thanks in advance Peter

      J Offline
      J Offline
      Jun Du
      wrote on last edited by
      #2

      You almost never have to detect overlappings. Windows handles the window stack and z-order automatically. When part of a window is covered, the covered portion won't be updated in the dark. If you force a update, the chances are you also bring that portion to the front at the same time. Note that this does not stop you from updating the data at any time you want. Windows only controls the rendering on the screen.

      Best, Jun

      P 1 Reply Last reply
      0
      • J Jun Du

        You almost never have to detect overlappings. Windows handles the window stack and z-order automatically. When part of a window is covered, the covered portion won't be updated in the dark. If you force a update, the chances are you also bring that portion to the front at the same time. Note that this does not stop you from updating the data at any time you want. Windows only controls the rendering on the screen.

        Best, Jun

        P Offline
        P Offline
        pliu_2000
        wrote on last edited by
        #3

        What I have done is set a flag while adding a new item. I have also overridden the WndProc to stop it erasing the background and invalidates the new items rectangle. When the flag is set, only the new items rectangle is repainted and not the whole control However, the effect when a window overlaps my control while this flag is set is that the background is not repainted as my WndProc prevents this. Therefore, I need to somehow detect when a window overlaps my control so that I can tell WndProc to allow the background to be repainted. I hope this explains my problem. Please feel free to make suggestions on how to do this or a better approach Thanks again Peter

        1 Reply Last reply
        0
        • P pliu_2000

          Hi, I am writing an application that uses an extended listview. The extended listview is modified to reduce the flickering when being populated by only invalidating the single item being added. However, If another window is dragged to overlap my application while the listview is being populated, the listview does not redraw when the overlapping window is moved out of the way. Therefore, I think I need to capture the event when the window overlaps my control. How can I do this? I believe there is an win api that can flag this, but I am not sure which one. Anyone know or anyone have a better approach? Thanks in advance Peter

          J Offline
          J Offline
          Josh Smith
          wrote on last edited by
          #4

          You can optimize the loading of items by calling BeginUpdate() on the ListView, then using the AddRange method on the Items collection, then call EndUpdate(). The Begin/EndUpdate methods prevent the control from redrawing while the items are populated. The AddRange ensures that the control suspends frivilous calculations when adding many items.

          :josh: My WPF Blog[^]

          P 1 Reply Last reply
          0
          • J Josh Smith

            You can optimize the loading of items by calling BeginUpdate() on the ListView, then using the AddRange method on the Items collection, then call EndUpdate(). The Begin/EndUpdate methods prevent the control from redrawing while the items are populated. The AddRange ensures that the control suspends frivilous calculations when adding many items.

            :josh: My WPF Blog[^]

            P Offline
            P Offline
            pliu_2000
            wrote on last edited by
            #5

            Hi, Thanks for the reply. I've already tried BeginUpdate/EndUpdate and AddRange. However, each of these still repaint the whole control causing a flicker. The setup I have is quite unusual. On a normal winform application both these approaches are successful. However, I have an activeX user control written in C# containing the listview and have exposed methods and events through COM. The activeX control is displayed on a web page using the tags. This has been successful using the BeginUpdate/EndUpdate approach and .NET 1.1 where only a slight flicker was visible. However, now we are updating our desktops to include .NET 2.0 and .NET 1.1. This seems to exagerate the flickering hence why I have take my approach to reduce the flickering. Thanks again Peter

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups