开发者

C# creating a form for given size

开发者 https://www.devze.com 2023-02-24 07:20 出处:网络
I want to draw a rectangle on the screen. I guess the most appropriate way is use a form without boarder.

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?


Use the ClientSize property instead of Size:

frm.ClientSize = new Size(101,30);


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号