잊지 않겠습니다.

Graphics object

.NET Framework 2009. 1. 7. 11:08

GDI에서의 DC 값과는 다르게, Graphics 객체는 따로 생성하는 방법이 존재하지 않는다. 거의 '얻어오는' 방법만이 존재할뿐   

: 틀린 내용이다. 각 Graphics 객체를 갖는 object들은 모두 CreateGraphics() 함수를 가지고 있다. 이는 Thread에 안전한 method로 WinForm 디자인시에 매우 편하다.


  • OnPaint 이벤트 핸들러의 경우, Graphics 객체는 PaintEventArgs의 Property로 전달
  • Control이나 Form에서 그려질때에, CreateGraphic 함수를 이용해서 얻을수 있다. 그러나, 이의 경우에는 반드시 Dispose 함수를 이용해서 제거해줘야지 된다.
  • Printer의 경우에는 PrintPage 이벤트 핸들러에서 얻어지는 값에서 Printer에서 얻어진 Graphics 객체를 포함한다.
  • owner draw 기능의 경우에는 MeasureItem, DrawItem 이벤트에서 각각의 Graphics 객체를 가지고 있다.
  • Image를 얻어서 이를 나타내는 경우에는 Graphics.FromImage를 호출함으로서 Graphics 객체를 얻을수있다.
  • Printer의 경우, PrintSetting 클래스의 CreateMeasurementGraphics 메서드에서 Graphics 객체를 얻는것이 가능하다.
  • Win32 code를 이용해서 Graphics.FromHwnd, Graphics.FromHdc를 이용해서 Graphics 객체를 이용 가능하다.
Posted by Y2K
,