Function Reference

_GDIPlus_GraphicsCreateFromHDC

デバイスコンテキスト(DC)からGraphicsオブジェクトを作成します。

#Include <GDIPlus.au3>
_GDIPlus_GraphicsCreateFromHDC($hDC)

 

パラメータ

$hDC デバイスコンテキスト

 

返し値

成功: Graphicsオブジェクトのハンドル
失敗:: 0

 

注意

Graphicsオブジェクトを使用した後は_GDIPlus_GraphicsDisposeを呼んでリソースを解放してください。

 

関連

_GDIPlus_GraphicsDispose

 

こちらも参照

MSDNライブラリでGdipCreateFromHDCを検索して下さい。

 


#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $hDC

    ; GUI作成
    $hGUI = GUICreate("GDI+", 400, 300)
    $hDC  = _WinAPI_GetWindowDC($hGUI)
    GUISetState()

    ; 文字列を描画
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHDC ($hDC)
    $hBrush = _GDIPlus_BrushCreateSolid (0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate ()
    $hFamily = _GDIPlus_FontFamilyCreate ("Arial")
    $hFont = _GDIPlus_FontCreate ($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate (140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx ($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; ユーザーが終了するまでループ
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; リソースを破棄
    _GDIPlus_FontDispose ($hFont)
    _GDIPlus_FontFamilyDispose ($hFamily)
    _GDIPlus_StringFormatDispose ($hFormat)
    _GDIPlus_BrushDispose ($hBrush)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _WinAPI_ReleaseDC($hGUI, $hDC)
    _GDIPlus_Shutdown ()

EndFunc   ;==>_Main