How to detect overlapping windows
-
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
-
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
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
-
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
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
-
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
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[^]
-
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[^]
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