rootx Posted December 15, 2015 Posted December 15, 2015 (edited) expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <file.au3> #include <array.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include<ComboConstants.au3> #include <GUIComboBox.au3> $Form1 = GUICreate("Form1", 300, 200, -1, -1) $Combo1 = GUICtrlCreateCombo("Select Font", 25, 64, 250, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_DROPDOWNLIST)) $s_FontList = _FileListToArray(@WindowsDir & "\Fonts\","*.ttf") $NFontList = UBound($s_FontList)-1 For $ff = 1 to $NFontList GUICtrlSetData($Combo1, StringTrimRight($s_FontList[$ff],4)) Next Global $hGraphic GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Combo1 EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo If Not IsHWnd($combo1) Then $hWndCombo = GUICtrlGetHandle($Combo1) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case $combo1, $hWndCombo Switch $iCode ; no return value Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box _DebugPrint("$CBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) _GDIPlus_GraphicsDrawString($hGraphic, "Hello world", 10, 10,GUICtrlRead($Combo1),10) ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND functia de autocomplete la combo Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrintWhen I change the font I would also update the gui, but the fonts are overwritten without refreshing the gui, could someone tell me what is wrong.THX Edited December 16, 2015 by rootx
InunoTaishou Posted December 15, 2015 Posted December 15, 2015 _GDIPlus_GraphicsClear($form1, 0xFFF0F0F0) Will clear the image you already drew and then allow you to draw on a blank canvas.
rootx Posted December 16, 2015 Author Posted December 16, 2015 _GDIPlus_GraphicsClear($form1, 0xFFF0F0F0)...APPCRASHautoit3.exe3.3.14.2gdiplus.dll6.3.9600.18123I tried but I get the following error.THX InunoTaishou
UEZ Posted December 16, 2015 Posted December 16, 2015 (edited) You are disposing the old graphic handle which causes the crash!Try this:expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <file.au3> #include <array.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include<ComboConstants.au3> #include <GUIComboBox.au3> $Form1 = GUICreate("Form1", 300, 200, -1, -1) $iPic = GUICtrlCreatePic("", 0, 0, 300, 60) $hPic = GUICtrlGetHandle($iPic) $Combo1 = GUICtrlCreateCombo("Select Font", 25, 64, 250, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_DROPDOWNLIST)) $s_FontList = _FileListToArray(@WindowsDir & "\Fonts\","*.ttf") $NFontList = UBound($s_FontList)-1 For $ff = 1 to $NFontList GUICtrlSetData($Combo1, StringTrimRight($s_FontList[$ff],4)) Next Global $hGraphic GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hPic) _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit Case $Combo1 EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo If Not IsHWnd($combo1) Then $hWndCombo = GUICtrlGetHandle($Combo1) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case $combo1, $hWndCombo Switch $iCode ; no return value Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box _DebugPrint("$CBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) $sFont = GUICtrlRead($Combo1) $sFontname = _WinAPI_GetFontResourceInfo(@WindowsDir & "\Fonts\" & $sFont & ".ttf") _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) _GDIPlus_GraphicsDrawString($hGraphic, $sFontname, 10, 10, $sFontname, 24) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND functia de autocomplete la combo Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint Edited December 16, 2015 by UEZ rootx 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now