Hallo,
in dieser GUI werden installierte Schriftarten angezeigt, aber ich bekomms nicht hin das die versch. Buchstaben in den versch. Schriftarten im Ausgabefenster zentriert sind!
Wie bekomme ich jeden Buchstaben in die Mitte des Fensters??
*Zeile mit _GDIPlus_RectFCreate!?!
Spoiler anzeigen
#include <File.au3>
#include <Array.au3>
#include <RegFunc.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <UpDownConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
;Data
$dString = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z'
$aString = StringSplit($dString, ',')
Local $data[2][$aString[0] + 1]
For $i = 1 to $aString[0]
$data[0][$i] = $aString[$i]
$data[1][$i] = $i
Next
$data[0][0] = (UBound($data, 2) - 1)
;_ArrayDisplay($data, -1, -1, 1)
$cDataCount = 1 ;Letter Stellenzähler
$capi = 0 ;Gross- und Kleinschreibung
$FontList = _FileListToArray(@WindowsDir & '\Fonts', '*.ttf', 1);Schriftarten aus Windows Fonts Ordner holen
If @error = 1 Then
MsgBox(0, "", "No Folders Found.")
cleanup()
Exit
EndIf
If @error = 4 Then
MsgBox(0, "", "No Files Found.")
cleanup()
Exit
EndIf
$var = _GetRegValues('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts');Schriftartennamen aus Windows Registry holen
Dim $aItems[($FontList[0] + 1)]
$x = 1
Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $aInfo
;Arrays anzeigen
;~ _ArrayDisplay($FontList, "$FileList")
;~ _ArrayDisplay($var)
;GUI erstellen
$msg = GUICreate("Installierte Schriftarten", 400, 500)
$listview = GUICtrlCreateListView("Nr.|Datei|Name", 10, 10, 380, 150, $LVS_SINGLESEL)
$button = GUICtrlCreateButton("OK", 20, 170, 70, 20)
$gWin = GUICtrlCreateGraphic(20, 200, 100, 100)
$iLetter = GUICtrlCreateInput ("a", 100, 170, 20, 20, $ES_CENTER)
GUICtrlCreateLabel('Schriftgrösse: ', 140, 170, 65, 20)
$SchriftG = GUICtrlCreateInput('12', 210, 170, 36, 20)
$updwnSGR = GUICtrlCreateUpdown($SchriftG)
$gross = GUICtrlCreateButton('', 121, 170, 10, 10)
$klein = GUICtrlCreateButton('', 121, 180, 10, 10)
$bUp = GUICtrlCreateButton('Up', 121, 200, 24, 50)
$bDown = GUICtrlCreateButton('Dwn', 121, 250, 24, 50)
GUICtrlSetBkColor($gWin, 0xffffff)
GUICtrlSetBkColor($klein, 0x00ff00)
GUICtrlSetBkColor($gross, 0x8B0000)
GUICtrlSetColor($gWin, 0)
GUICtrlSetLimit($iLetter, 1)
GUICtrlSetLimit($listview, 1)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUICtrlSetOnEvent($button, "button")
GUICtrlSetOnEvent($bUp, "UP")
GUICtrlSetOnEvent($bDown, "DOWN")
GUICtrlSetOnEvent($gross, "gross")
GUICtrlSetOnEvent($klein, "klein")
GUICtrlSetOnEvent($updwnSGR, "SchriftGR")
_GUICtrlListView_SetSelectionMark($listview, 1)
$sTrim = _GUICtrlListView_GetSelectionMark($listview)
;GUI Liste schreiben
For $a = 1 To UBound($var)
If StringRight($var[$a - 1][2], 3) = 'ttf' Then
$aItems[$x] = GUICtrlCreateListViewItem($x & '|' & $var[$a - 1][2] & '|' & $var[$a - 1][0], $listview)
GUICtrlSetOnEvent($aItems[$x], "HandleClicks")
$x = $x + 1
EndIf
Next
Drawing()
[/autoit] [autoit][/autoit] [autoit];GUI loop
While 1
$rAktList = GUICtrlRead($listview)
WEnd
;Funktionen
;SpecialEvents
Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
cleanup()
Exit
EndSelect
EndFunc
;HandleClicks
Func HandleClicks()
$aktSel = GUICtrlRead(GUICtrlRead($listview))
$aList = StringSplit($aktSel,'|')
$sTrim = StringTrimRight($aList[3], 11)
Drawing()
EndFunc
;button()
Func button()
$rInput = GUICtrlRead($iLetter)
MsgBox(0, 'Schriftart', GUICtrlRead(GUICtrlRead($listview)), 2)
Drawing()
EndFunc
;UP()
Func UP()
If $cDataCount < $aString[0] Then
$cDataCount = $cDataCount + 1
EndIf
If $capi = 0 Then
$new = StringLower($aString[$cDataCount])
Else
$new = StringUpper($aString[$cDataCount])
EndIf
GUICtrlSetData($iLetter, $new)
Drawing()
EndFunc
;DOWN()
Func DOWN()
If $cDataCount >= 2 Then
$cDataCount = $cDataCount - 1
EndIf
If $capi = 1 Then
gross()
EndIf
If $capi = 0 Then
$new = StringLower($aString[$cDataCount])
Else
$new = StringUpper($aString[$cDataCount])
EndIf
GUICtrlSetData($iLetter, $new)
Drawing()
EndFunc
Func gross()
$capi = 1
$rInput = GUICtrlRead($iLetter)
$new = StringUpper($rInput)
GUICtrlSetData($iLetter, $new)
GUICtrlSetBkColor($gross, 0x00ff00)
GUICtrlSetBkColor($klein, 0x8B0000)
Drawing()
EndFunc
Func klein()
$capi = 0
$rInput = GUICtrlRead($iLetter)
$new = StringLower($rInput)
GUICtrlSetData($iLetter, $new)
GUICtrlSetBkColor($klein, 0x00ff00)
GUICtrlSetBkColor($gross, 0x8B0000)
Drawing()
EndFunc
Func SchriftGR()
$sgr = GUICtrlRead($SchriftG)
If $sgr <= 2 Then
GUICtrlSetData($SchriftG, 2)
EndIf
If $sgr >= 80 Then
GUICtrlSetData($SchriftG, 80)
EndIf
Drawing()
EndFunc
Func Drawing()
GUICtrlSetColor($gWin, 0)
$rInput = GUICtrlRead($iLetter)
$sgr = GUICtrlRead($SchriftG)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($msg)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
$hFormat = _GDIPlus_StringFormatCreate()
_GDIPlus_StringFormatSetAlign($hFormat, 1)
$hFamily = _GDIPlus_FontFamilyCreate($sTrim)
$hFont = _GDIPlus_FontCreate($hFamily, $sgr, 0, 2)
$tLayout = _GDIPlus_RectFCreate(0, 50 - ($sgr / 2), 100, 100)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $rInput, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hGraphic, $rInput, $hFont, $aInfo[0], $hFormat, $hBrush)
EndFunc
; Clean up resources
Func cleanup()
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc
;Ende
cleanup()
Exit
Wer sonst noch Tipps zur Verbesserung hat, her damit!
Danke!
Edit: Hab jetzt die Zeilen
$tLayout = _GDIPlus_RectFCreate(0, 50 - ($sgr / 2), 100, 100)
_GDIPlus_StringFormatSetAlign($hFormat, 1)
eingefügt, aber nicht alle Schriftarten passen!! Ist das normal??