Problems updating / reprogramming MDI child programs (C #, Winforms, .NET 2.0, VS2005, DevExpress 8.2)

Hiya - was pointed at you guys by my friend.

I have an MDI application (C #, Winforms, .NET 2.0, VS2005, DevExpress 8.2) and one of my forms is behaving very strangely - not repainting itself properly where it overlaps with another instance of the same form class.

Forms contain a custom control (which contains various DevExpress controls) and inherit from the base form (which itself is inherited).

Due to issues with form inheritance (that old chestnut tree) there is some control rebuilding going on in the constructor.

Problem 1 (minor): None of these swap / change control settings take effect unless the shape changes, so I push the width up and down one pixel after rearranging. Ugly, raucous, and I really wish I hadn't.

Issue 2 (Major): If forms are rendered and then attached to an MDI form using the SetParent API call, when I show the second instance, the different parts of these two forms are not drawn correctly where they overlap - the top-level bits are behind the existing one - and this problem gets worse when the molds are moved, making them mostly unusable. Other child forms (if any) of a different type seem to be unaffected ...

STOP PRESS: I have established that it should not be 2 instances of the child form. Only one problem remains - mainly around the edges of the form, for example, the area that is being updated is smaller than the form itself.

The problem does not occur if the parent is set using the .MDIParent property of the child form, but we cannot do that because the form can be rendered by a control hosted in a non.Net application. Also I need to display child forms not maximized even if existing children (of other type) are maximized, and this only happens with SetParent.

I tried Refresh () on all forms of this type (I have a controller that stores a list of them), but no joy. I tried to reproduce this effect from a base application with the same inheritance structure, but I cannot. It is clear that this is something like a form - since yesterday I recreated the form from scratch, and it should still be the same code, but what?

I'm not the hottest on form-related events etc., so am I missing something?


source to share

3 answers


I changed the FormBorderStyle in the code before showing the form. I removed this line and the problem went away ...

It will be for me. :-)



Yes, that would do it. Changing the FormBorderStyle requires Windows Forms to recreate the window from scratch, now using different style flags in the CreateWindowEx () call. This would make you completely forget about the parents that you set with SetParent () P / Invoke. There are many other properties that make this happen. Avoid the problems you run into by making these calls overriding the OnHandleCreated () method.

Better yet, avoid nasty APIs like SetParent () by completely placing all your controls and logic in the UserControl.



I know this is an old thread, but I fixed something for me. It might help someone with a similar problem.

My problem: We have an application in which we insert two external applications in a parent window, separated by a separator. It is used to display information from two applications side by side. The problem we ran into was that the two child windows were drawing very well in the parent window (using SetParent, SetWindowLong and MoveWindow), but when moving or doing operations on the child windows, they had paint / refresh issues (more specifically, the parent panel will be drawn above the child windows)

After reading a ton of articles about embedding windows, SetParent issues, MSDN page .85) .aspx gave me the key.

Solution: When using SetWindowLong (to set styles) use WS_CLIPCHILDREN style -



What this style does is it prevents the parent window from redrawing the area occupied by the child windows. This solved the problem completely for me.



All Articles