Graphics.FromHdc メソッド (IntPtr)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文Dim hdc As IntPtr Dim returnValue As Graphics returnValue = Graphics.FromHdc(hdc)
戻り値
このメソッドは、指定のデバイス コンテキストの新しい Graphics を返します。
解説FromHdc メソッドによって作成された Graphics および 関連リソースを解放するには、必ず Dispose メソッドを呼び出す必要があります。
表示デバイスに対応する ICM カラー プロファイルがある場合でも、GDI+ の既定では、そのプロファイルは使用されません。ICM を Graphics に対して有効にするには、SetICMMode 関数に HDC (および ICM_ON) を渡し、その HDC から Graphics を作成します。その後、Graphics によって行われるすべての描画処理は、表示デバイスに対応する ICM プロファイルに従って調整されます。ICM を有効にすると、パフォーマンスは低下します。
FromHdc を呼び出す時点でのデバイス コンテキストの状態 (マッピング モード、論理単位など) によって、Graphics によるレンダリング処理が変わることがあります。
使用例次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードでは次のアクションを実行します。
<System.Security.Permissions.SecurityPermission( _ System.Security.Permissions.SecurityAction.LinkDemand, Flags := _ System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _ Public Sub FromHdcHdc(ByVal e As PaintEventArgs) ' Get handle to device context. Dim hdc As IntPtr = e.Graphics.GetHdc() ' Create new graphics object using handle to device context. Dim newGraphics As Graphics = Graphics.FromHdc(hdc) ' Draw rectangle to screen. newGraphics.DrawRectangle(New Pen(Color.Red, 3), 0, 0, 200, 100) ' Release handle to device context and dispose of the Graphics ' object e.Graphics.ReleaseHdc(hdc) newGraphics.Dispose() End Sub
[System.Security.Permissions.SecurityPermission( System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)] public void FromHdcHdc(PaintEventArgs e) { // Get handle to device context. IntPtr hdc = e.Graphics.GetHdc(); // Create new graphics object using handle to device context. Graphics newGraphics = Graphics.FromHdc(hdc); // Draw rectangle to screen. newGraphics.DrawRectangle(new Pen(Color.Red, 3), 0, 0, 200, 100); // Release handle to device context and dispose of the // Graphics object e.Graphics.ReleaseHdc(hdc); newGraphics.Dispose(); }
プラットフォームWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照Graphics.FromHdc メソッド
オーバーロードの一覧| 名前 | 説明 |
|---|---|
| Graphics.FromHdc (IntPtr) | デバイス コンテキストを識別する指定のハンドルから新しい Graphics を作成します。 .NET Compact Framework によってサポートされています。 |
| Graphics.FromHdc (IntPtr, IntPtr) | デバイス コンテキストを識別する指定のハンドルと、デバイスを識別する指定のハンドルから、新しい Graphics を作成します。 |
参照Graphics.FromHdc メソッド (IntPtr, IntPtr)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文Dim hdc As IntPtr Dim hdevice As IntPtr Dim returnValue As Graphics returnValue = Graphics.FromHdc(hdc, hdevice)
戻り値
このメソッドは、指定のデバイス コンテキストおよびデバイスの新しい Graphics を返します。
解説Graphics メソッドによって作成された Dispose および 関連リソースを解放するには、必ず FromHdc メソッドを呼び出す必要があります。
表示デバイスに対応する ICM カラー プロファイルがある場合でも、GDI+ の既定では、そのプロファイルは使用されません。ICM を Graphics に対して有効にするには、SetICMMode 関数に HDC (および ICM_ON) を渡し、その HDC から Graphics を作成します。その後、Graphics によって行われるすべての描画処理は、表示デバイスに対応する ICM プロファイルに従って調整されます。ICM を有効にすると、パフォーマンスは低下します。
FromHdc を呼び出す時点でのデバイス コンテキストの状態 (マッピング モード、論理単位など) によって、Graphics によるレンダリング処理が変わることがあります。
.NET Framework のセキュリティ
プラットフォーム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.FromHdcを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からGraphics.FromHdc
を検索
- Graphics.FromHdcのページへのリンク