#include <File.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <RegFunc.au3>
#include <UpDownConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.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
;Schriftarten aus Windows Fonts Ordner holen
$FontList = _FileListToArray(@WindowsDir & '\Fonts', '*.ttf', 1)

;Fehlerabfrage
If @error = 1 Then
	MsgBox(0, "", "No Folders Found.")
	Exit
EndIf
If @error = 4 Then
	MsgBox(0, "", "No Files Found.")
	Exit
EndIf
;
$var = _GetRegValues('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts')
;Deklarationen
Dim $aItems[($FontList[0] + 1)]
$x = 1
;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)
GUICtrlSetBkColor($gWin, 0xffffff)
GUICtrlSetColor($gWin, 0)
$iLetter = GUICtrlCreateInput ("A", 100, 170, 20, 20, $ES_CENTER)
GUICtrlSetLimit($iLetter, 1)
GUICtrlSetLimit($listview, 1)
$bUp = GUICtrlCreateButton('Up', 121, 200, 24, 50)
$bDown = GUICtrlCreateButton('Dwn', 121, 250, 24, 50)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUICtrlSetOnEvent($button, "button")
GUISetOnEvent($bUp, "UP")
GUISetOnEvent($bDown, "DOWN")

;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

drawtype()

;GUI loop
While 1
	$rAktList = GUICtrlRead($listview)
WEnd

;Funktionen
;SpecialEvents
Func SpecialEvents()
    Select
		Case @GUI_CtrlId = $GUI_EVENT_CLOSE
			Exit
	EndSelect
EndFunc
;HandleClicks
Func HandleClicks()
	$aktSel = GUICtrlRead(GUICtrlRead($listview))
	$aList = StringSplit($aktSel,'|')
	$sTrim = StringTrimRight($aList[3], 11)
EndFunc
;button()
Func button()
	$rInput = GUICtrlRead($iLetter)
	MsgBox(0, 'Schriftart', GUICtrlRead(GUICtrlRead($listview)), 2)
	drawtype()
EndFunc
;UP()
Func UP()
	If $cDataCount < $aString[0] Then
		$cDataCount = $cDataCount + 1
	EndIf
	GUICtrlSetData($iLetter, $aString[$cDataCount])
	drawtype()
EndFunc
;DOWN()
Func DOWN()
	If $cDataCount >= 2 Then
		$cDataCount = $cDataCount - 1
	EndIf
	GUICtrlSetData($iLetter, $aString[$cDataCount])
	drawtype()
EndFunc
;drawtype()
Func drawtype()
	$rInput = GUICtrlRead($iLetter)
	; Draw a string
	_GDIPlus_Startup()
	GUICtrlSetColor($gWin, 0)
	$hGraphic = _GDIPlus_GraphicsCreateFromHWND($msg)
	_GDIPlus_GraphicsDrawString($hGraphic, $rInput, 40, 40, 'Arial', 20)
EndFunc
;Ende
Exit