Graphics.FromHwnd メソッド
ウィンドウを識別する指定のハンドルから新しい Graphics を作成します。
名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
Dim hwnd As IntPtr Dim returnValue As Graphics returnValue = Graphics.FromHwnd(hwnd)


次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse と、たとえば Form などの thisForm が必要です。このコードは次のアクションを実行します。
Public Sub FromHwndHwnd(ByVal e As PaintEventArgs) ' Get handle to form. Dim hwnd As IntPtr = Me.Handle ' Create new graphics object using handle to window. Dim newGraphics As Graphics = Graphics.FromHwnd(hwnd) ' Draw rectangle to screen. newGraphics.DrawRectangle(New Pen(Color.Red, 3), 0, 0, 200, 100) ' Dispose of new graphics. newGraphics.Dispose() End Sub
public void FromHwndHwnd(PaintEventArgs e) { // Get handle to form. IntPtr hwnd = this.Handle; // Create new graphics object using handle to window. Graphics newGraphics = Graphics.FromHwnd(hwnd); // Draw rectangle to screen. newGraphics.DrawRectangle(new Pen(Color.Red, 3), 0, 0, 200, 100); // Dispose of new graphics. newGraphics.Dispose(); }

- SecurityPermission (アンマネージ コードへのアクセスに必要なアクセス許可)。UnmanagedCode (関連する列挙体)

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からGraphics.FromHwnd メソッドを検索する場合は、下記のリンクをクリックしてください。

- Graphics.FromHwnd メソッドのページへのリンク