Make control draw on top of other forms
-
I have a main form that uses AddOwnedForm to allow these forms to draw on top of the main form. The problem I am having is with a control that I created by inheriting from System.Windows.Forms.Control. When I display this control, which belongs to the main form, it will draw properly until it tries to write on top of an area occupied by an owned form. Is there a way to allow a control to draw on top of anything. I tried using SetTopLevel but that seems to turn it into a form and puts a forms border around it. I have seen the build in ComboBox control pop up its listbox over anything so I figure it must be possible. Does anyone have any ideas? Thanks, Jay
-
I have a main form that uses AddOwnedForm to allow these forms to draw on top of the main form. The problem I am having is with a control that I created by inheriting from System.Windows.Forms.Control. When I display this control, which belongs to the main form, it will draw properly until it tries to write on top of an area occupied by an owned form. Is there a way to allow a control to draw on top of anything. I tried using SetTopLevel but that seems to turn it into a form and puts a forms border around it. I have seen the build in ComboBox control pop up its listbox over anything so I figure it must be possible. Does anyone have any ideas? Thanks, Jay
Try overridding the
CreateParams
property and doing something like so:protected virtual System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams parms = base.CreateParams;
parms.Style |= WS_POPUP; // Defined as 0x80000000
return parms;
}
}I'm not totally positive this will work, but it's worth a try.
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Try overridding the
CreateParams
property and doing something like so:protected virtual System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams parms = base.CreateParams;
parms.Style |= WS_POPUP; // Defined as 0x80000000
return parms;
}
}I'm not totally positive this will work, but it's worth a try.
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
Unfortunately that did not work the way I needed. When you modify a control to have the WS_POPUP style it no longer acts as a child on the form and processing of other controls does not work. Thanks for the suggestion.