Windows Forms 응용 프로그램을 만들고 있습니다. Windows 양식의 크기를 어떻게 캡처합니까?Windows Form의 크기 가져 오기
PictureBox display = new PictureBox();
display.Width = 360;
display.Height = 290;
this.Controls.Add(display);
display.Image = bmp;
하지만, 내 디스플레이의 크기가 하드 코딩 된 특정 값입니다 :
현재 내 코드에서 다음과 같습니다 뭔가가있다.
내가 알고 내가 다시 크기를 나는 이런 식으로 뭔가를 사용하여 사각형 그릴하려는 경우 :
private Rectangle PlotArea;
private int offset = 30;
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
//// Calculate the location and size of the plot area
//// within which we want to draw the graphics:
Rectangle ChartArea = ClientRectangle;
PlotArea = new Rectangle(ChartArea.Location, ChartArea.Size);
PlotArea.Inflate(-offset, -offset);
Draw PlotArea:
g.DrawRectangle(Pens.Black, PlotArea);
}
날 방법 중 하나를 사용하여 폼의 크기를 잡아 할 수있는 방법이 있나요을 높이와 너비?
ClientRectangle.Width
에 나는 다음과 같은 코드를 시도했지만, 그것이 작동하지 않습니다
...
PictureBox display = new PictureBox();
display.Width = ClientRectangle.Y;
display.Height = ClientRectangle.X;
this.Controls.Add(display);
display.Image = bmp;
흠 ... 나는 이것을 시도했지만 양식을 다시 크기 때 줄을 다시하지 않습니다 ... – BigBug
고마워요! 그게 도움이되었다 .. upvoted – BigBug