Paint a rectangle [modified]
-
I have a custom control and am painting a custom border, how do i paint this outside of the bounds of the control from within the control itself. It's just a custom panel so its a straight rectangle.
Please check out my articles: The ANZAC's articles
-
I have a custom control and am painting a custom border, how do i paint this outside of the bounds of the control from within the control itself. It's just a custom panel so its a straight rectangle.
Please check out my articles: The ANZAC's articles
It's possible to do, but you shouldn't do that. The entire control is supposed to go inside the bounds of the control, including any border. The Graphics object that you get in the Paint event is clipped to the bounds of the control or the part of the control that needs redrawing. If you draw outside this clipping, you risk drawing on top of other windows.
Experience is the sum of all the mistakes you have done.
-
It's possible to do, but you shouldn't do that. The entire control is supposed to go inside the bounds of the control, including any border. The Graphics object that you get in the Paint event is clipped to the bounds of the control or the part of the control that needs redrawing. If you draw outside this clipping, you risk drawing on top of other windows.
Experience is the sum of all the mistakes you have done.
yes but because the control contains other controls the border appears under them, or how do i draw over the top of all controls in the control remaining inside the bounds.
Please check out my articles: The ANZAC's articles
-
yes but because the control contains other controls the border appears under them, or how do i draw over the top of all controls in the control remaining inside the bounds.
Please check out my articles: The ANZAC's articles
-
Override the OnPaint method so that you can do your drawing after you call the OnPaint method of the base class.
Experience is the sum of all the mistakes you have done.
Did that. Still not working. I can't seem to just draw a rectangle straight over the top of everything in my control, even if i paint it after on paint. How do i make things i paint out of the control's bounds visible?
Please check out my articles: The ANZAC's articles
-
Did that. Still not working. I can't seem to just draw a rectangle straight over the top of everything in my control, even if i paint it after on paint. How do i make things i paint out of the control's bounds visible?
Please check out my articles: The ANZAC's articles
Hi, have a look at the ControlPaint class, it allows you to paint anywhere on the screen! :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hi, have a look at the ControlPaint class, it allows you to paint anywhere on the screen! :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
Thankyou this was very useful. Now...you wouldn't happen to know the best way to change the client area would you?. I need it to behave similar to a form in the sense that we can't place a control on or under the title bar but we can put it anywhere else on the form. I need to just redefine the client area location and width. Howe can i achieve this?
Please check out my articles: The ANZAC's articles
-
Hi, have a look at the ControlPaint class, it allows you to paint anywhere on the screen! :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
As useful as this was it still doesn't let me draw outside the bounds of my control, it just cuts it off.
Please check out my articles: The ANZAC's articles
-
As useful as this was it still doesn't let me draw outside the bounds of my control, it just cuts it off.
Please check out my articles: The ANZAC's articles
I once tried ControlPaint.DrawReversibleLine and dropped it since it ignored all windowing, so when applied to a window that was partly covered by something else it was painting over that something else, what I did not want at the time. :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
I once tried ControlPaint.DrawReversibleLine and dropped it since it ignored all windowing, so when applied to a window that was partly covered by something else it was painting over that something else, what I did not want at the time. :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
Well i can't get it to paint outside my control, then again i am caling it from within my contro, don't know if this should make a difference, but i certainly can't draw anywhere on the screen.
Please check out my articles: The ANZAC's articles
-
Thankyou this was very useful. Now...you wouldn't happen to know the best way to change the client area would you?. I need it to behave similar to a form in the sense that we can't place a control on or under the title bar but we can put it anywhere else on the form. I need to just redefine the client area location and width. Howe can i achieve this?
Please check out my articles: The ANZAC's articles
Hi,
The ANZAC wrote:
I need to just redefine the client area location and width.
Well you can set a new ClientSize, but I guess it just resizes the entire Form. I have never tried to create a different Form layout. If I were to need such thing I would try this: - create MyForm class inheriting from Form; - probably select a very simple BorderStyle (maybe None); - organize the painting of the non-client area (border, title bar, close box, whatever); - override some properties such as ClientSize, ClientRectangle, ... (and maybe a whole lot more); - and hope the majority of properties and methods can remain unchanged. I do not plan to try this on XP. And I hope I will never need to do it on Vista, although I am pretty sure I will not like transparant title bars... :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hi,
The ANZAC wrote:
I need to just redefine the client area location and width.
Well you can set a new ClientSize, but I guess it just resizes the entire Form. I have never tried to create a different Form layout. If I were to need such thing I would try this: - create MyForm class inheriting from Form; - probably select a very simple BorderStyle (maybe None); - organize the painting of the non-client area (border, title bar, close box, whatever); - override some properties such as ClientSize, ClientRectangle, ... (and maybe a whole lot more); - and hope the majority of properties and methods can remain unchanged. I do not plan to try this on XP. And I hope I will never need to do it on Vista, although I am pretty sure I will not like transparant title bars... :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
well it's a panel not a form, problem is the clientsize is readonly and not overridable (i don't think) only overloadable. I wouldn't need to do this if i could just figure out how to paint outside my controls bounds.
Please check out my articles: The ANZAC's articles
-
Well i can't get it to paint outside my control, then again i am caling it from within my contro, don't know if this should make a difference, but i certainly can't draw anywhere on the screen.
Please check out my articles: The ANZAC's articles
There seem to be two kinds of drawing methods in ControlPaint: - the ones working on the screen, using screen coordinates, ignoring all windows, just painting everywhere; - the ones needing a Graphics; now a Graphics always has clipping built-in, that's one of its features (did you ever care about a DrawString exceeding the width of a Control?). As another reply already told you, you (theoretically) cannot make a Control's OnPaint paint outside the Control, i.e. you must set the Control's Size large enough so it contains all the areas where you want it to paint something (that's how non-rectangular Forms basically work, as far as I can tell from reading some articles, I am not really in to this). :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
There seem to be two kinds of drawing methods in ControlPaint: - the ones working on the screen, using screen coordinates, ignoring all windows, just painting everywhere; - the ones needing a Graphics; now a Graphics always has clipping built-in, that's one of its features (did you ever care about a DrawString exceeding the width of a Control?). As another reply already told you, you (theoretically) cannot make a Control's OnPaint paint outside the Control, i.e. you must set the Control's Size large enough so it contains all the areas where you want it to paint something (that's how non-rectangular Forms basically work, as far as I can tell from reading some articles, I am not really in to this). :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
ok thankyou.
Please check out my articles: The ANZAC's articles