Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8038573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:16:43+00:00 2026-06-05T03:16:43+00:00

I am not really sure how to accurately word this question, but you will

  • 0

I am not really sure how to accurately word this question, but you will understand after I explain what the problem is.

I have a winform on which I draw shapes like rectangle, oval, line, etc just like the winform below. After that, I save those shapes into a binary file.

enter image description here

However, if you notice that when my program starts up and I open the saved shapes, for some odd reason the winform is keeping its design-time width and height to display the shapes that the shapes look chopped off even though winform has plenty of paint area to draw all the shapes completely.

Furthermore, if I reload the winform, it uses its current width and height to draw the shapes. Thus, the winform looks like the way I am expecting it too as below.

enter image description here

What am I missing or need to do? So, the winform will update to its current width and height during runtime all the time.

UPDATE:

Here is a code for drawing Rectangle. Rectangle is an object of a class in my program design. Thus, each object has its own draw method. So, within paint event all the objects in a list calls draw method as follows.

method ViewFrmpas.ViewFrmpas_Paint(sender: System.Object; e: System.Windows.Forms.PaintEventArgs);
begin
     myObjects.Draw;
end;

Here is my actual draw method for drawing Rectangle on a winform.

method TMakerRect.Draw;
var
  outpoints:Array of point;
  inpoints:Array of point;
  r,fr:Rectangle;
  midx,midy:integer;
  theBrush1:HatchBrush;
  theBrush2:SolidBrush;
begin
  r := bounds;
  fr := bounds;

  if (theBrushStyle = HatchStyle.Wave) then
     theBrush1 := new HatchBrush(theBrushStyle,Color.Transparent,color.Transparent)
  else if (theBrushStyle = HatchStyle.ZigZag) then
     thebrush2 := new SolidBrush(FillColor)
  else
     theBrush1 := new HatchBrush(theBrushStyle,FillColor,color.Transparent);

  if (thePen.DashStyle = DashStyle.Custom) then
    thepen.Color := Color.Transparent;

  outpoints := new point[5];
  inpoints := new point[4];
  with r do
  begin
    midx := ((right - left) div 2) + left;
    midy := ((bottom - top) div 2) + top;
    inpoints[0].x := left; inpoints[0].y := top;
    inpoints[1].x := right; inpoints[1].y := top;
    inpoints[2].x := right; inpoints[2].y := bottom;
    inpoints[3].x := left; inpoints[3].y := bottom;
  end;

  if Active then
  begin
    Fill(var fr);
    with fr do
    begin
      outpoints[0].x := r.Left; outpoints[0].y := r.Top;
      outpoints[1].x := left; outpoints[1].y := top;
      outpoints[2].x := right; outpoints[2].y := top;
      outpoints[3].x := right; outpoints[3].y := bottom;
      outpoints[4].x := left; outpoints[4].y := bottom;
    end;

    Scale(var inpoints,4,midx,midy);
    Rotate( var inpoints,4,midx,midy);
    Translate(var inpoints,4);

    Scale(var outpoints,5,midx,midy);
    Rotate( var outpoints,5,midx,midy);
    Translate(var outpoints,5);

    if Visible then
    begin    
        if theBrushStyle = HatchStyle.ZigZag then
            g.FillPolygon(theBrush2,inpoints)
        else 
            g.FillPolygon(thebrush1,inpoints);

      g.DrawPolygon(thepen,outpoints);
    end;
  end
  else
  begin
      outpoints[0].x := r.Left; outpoints[0].y := r.Top;
      outpoints[1].x := r.left; outpoints[1].y := r.top;
      outpoints[2].x := r.right; outpoints[2].y := r.top;
      outpoints[3].x := r.right; outpoints[3].y := r.bottom;
      outpoints[4].x := r.left; outpoints[4].y := r.bottom;

    if theBrushStyle = HatchStyle.ZigZag then
        g.FillPolygon(thebrush2,inpoints)
    else
        g.FillPolygon(theBrush1,inpoints);

    g.DrawPolygon(thepen,outpoints);
  end;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:16:45+00:00Added an answer on June 5, 2026 at 3:16 am
          g.FillPolygon(theBrush2,inpoints)
    

    The g variable fell from the sky, it is unclear where it came from. But judging from the outcome, you probably made the mistake of initializing it early, possibly by using CreateGraphics(). This does not work properly, the Graphics object will be initialized from the window’s device context that represents the size of the window at the time you created it. Resizing the window cannot change the Graphics.ClipBounds anymore.

    It is essential that you use the e.Graphics object that was passed in the Paint event handler. Simply pass it as an argument to Draw(). Not just to ensure the clip bounds are correct, it is also very important to make double-buffering work properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not really sure how to explain this but on my UITableView I have a
I'm not really sure how to ask this question, but I'll do my best.
I am not really sure how to word this question, so I did the
Not really sure how to phrase this question so it's generic enough. (and will
I'm not really sure how to ask this question. Suppose I have a class
Not really sure why I am getting this error but I have looked in
Not really sure how to explain this but how can I make 2 fragments
I'm not really sure how to explain this but basically I want a fluid
I'm not really sure where to start on this, but I have a menu
I'm not really sure if there is a single problem here or I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.