Paint out of window (and controls)

2019-08-11 00:39发布

问题:

I think that if I use image it would be best:

I need that my control could be out of window as datetimepicker calendar. I am using panelKalendar = new PanelDoubleBuffer(); then in method: void panelKalendar_Paint(object sender, PaintEventArgs e) I paint everything. But it´s painting to window and belov all other controls. How can I get "effect" that is use in DateTimePicker?

回答1:

The drop-down list of a combo box (and also possibly the drop-down panel of a calendar control) is a child window of the desktop. That's what you also have to do: nest your control inside a borderless form, and give that form a null parent, so that it is a top-level window, not a child of your application window.

Since your form will be a top-level window, its location will need to be specified in screen coordinates, not in coordinates local to your form. You can get those coordinates using the PointToScreen method.



回答2:

I'm afraid you can't achieve what you want with the child control of your form (that is what you're doing actually), cause it will be truncated by the parent (form) bounds.

Imo, you can try to use a seprate WidnowdForm control, that appears exactly in the place where the panel appears now.

Hope this helps.