Reputation: 375
I want to draw a rectangle on the screen. I guess the most appropriate way is use a form without boarder.
Form frm = new Form();
frm.StartPosition = FormStartPosition.Manual;
frm.Location = new Point(GlobalPosX, GlobalPosY);
frm.Size = new Size(101, 30);
frm.BackColor = System.Drawing.Color.Yellow;
frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
frm.Show();
The created from is not as the given size. It's size is similar to the window having boarder. The displayed window is bit larger as I given and the position is also moved little bit upper and left. Is there another way to achieve my goal?
Upvotes: 0
Views: 165
Reputation: 99957
Use the ClientSize
property instead of Size
:
frm.ClientSize = new Size(101,30);
Upvotes: 2
Reputation: 1075
If you want to draw rectangle on the screen, you can draw it directly: http://bytes.com/topic/c-sharp/answers/263740-draw-directly-screen
Upvotes: 1
Reputation: 7259
Drawing C# graphics without using Windows Forms
That like talks about making a border-less window. From there, just use the Graphics object to draw whatever you'd like
Upvotes: 0