Re: Usable ClientRectangle for Form

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Form.ClientRectangle is what you are after.
personally I would do

Rectangle client = ClientRectangle;
e.Graphics.SetClip(client);
e.Graphics.TranslateTransform(client.X, client.Y);


"Bit Twiddler" <bittwiddler35@xxxxxxxxxxx> wrote in message
news:uhQc7XWhFHA.2424@xxxxxxxxxxxxxxxxxxxxxxx
>I don't know if this is the proper solution, but I ended up using a
>transform on the graphics object to translate the drawing so that that is
>automatically occurs UNDER the status bar:
>
> private void Form1_Paint(object sender, PaintEventArgs e)
> {
> Graphics g = e.Graphics;
>
> // Start drawing BELOW the statusbar
> Matrix matrix = new Matrix();
> matrix.Translate(0, menuStrip1.Height);
> g.Transform = matrix;
>
> // Now (0,0) is below the statusbar
> g.DrawRectangle(Pens.Red, 0, 0, ...);
> ...
>
>
> "Bit Twiddler" <bittwiddler35@xxxxxxxxxxx> wrote in message
> news:ew5xOHWhFHA.1244@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi,
>>
>> I am performing drawing directly on the surface of a WinForm (double
>> buffering).
>>
>> My form has a menu, statusbar, etc.
>>
>> The ClientRectangle of my form includes the areas taken up by the menu,
>> statusbar, etc. What I want to get is a rectangle that represents the
>> area of the form where I need to do my drawing. Is there an easy way to
>> get his rectangle or do I have to calculate it myself all the time?
>>
>> Thanks,
>> BT
>>
>
>


.



Relevant Pages

  • Re: Usable ClientRectangle for Form
    ... transform on the graphics object to translate the drawing so that that is ... // Start drawing BELOW the statusbar ... What I want to get is a rectangle that represents the ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Usable ClientRectangle for Form
    ... buffering). ... My form has a menu, statusbar, etc. ... The ClientRectangle of my form includes the areas taken up by the menu, ... What I want to get is a rectangle that represents the area ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: dashed line not displaying
    ... tab> Object> Create from File> MO Visio Drawing. ... I am unable to use the pencil tool (to resize in any ... the invisible rectangle as I mentioned in my last post. ...
    (microsoft.public.visio.general)
  • Re: dashed line not displaying
    ... the dashed rectangle is the "outer most ... step of opening the pasted drawing and "re-triggering" the dashed lines. ... One other thought, using your approach, when you open the placed Visio ... and then close the Visio edit window. ...
    (microsoft.public.visio.general)
  • Re: dashed line not displaying
    ... it to Word due the following in Visio. ... Delete the dashed shape and replace it with a rectangle. ... Save your drawing. ... I am unable to use the pencil tool (to resize in any ...
    (microsoft.public.visio.general)