Morrison Posted September 18, 2011 Share Posted September 18, 2011 Hi! I´m working on a Font-Tool, but I don´t know how to center the letters in GUICtrlCreateEdit. Does anyone know? Please help! expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <File.au3> #include <Array.au3> #include <ListviewConstants.au3> #include <RegFunc.au3> #include <GuiComboBox.au3> #include <ScreenCapture.au3> #Include <GuiButton.au3> Global $fDblClk = False Dim $aItems[1500] Dim $aktFontNames[1500] Dim $Fonts[1500] Dim $FontDatName[1500] Dim $arrays[1500][3] Dim $result[1000] $abc = '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' $abcSplit = StringSplit($abc, ',', 1) $FontList = _FileListToArray(@WindowsDir & '\Fonts', '*.ttf', 1) ;_ArrayDisplay($abcSplit) $f = 1 $x = 1 Local $sText 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') ;_ArrayDisplay($FontList, "$FileList") ;_ArrayDisplay($var) #region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\schlafzimmergabi\desktop\form1_1.kxf $Form1_1 = GUICreate("Font Tool", 550, 190, 250, 159) $Datei = GUICtrlCreateMenu("&Datei") $MenuItem1 = GUICtrlCreateMenuitem("Optionen" & @TAB & "", $Datei) $MenuItem2 = GUICtrlCreateMenuitem("Exit" & @TAB & "", $Datei) $Hilfe = GUICtrlCreateMenu("&Hilfe") $Edit1 = GUICtrlCreateEdit("", 16, 56, 70, 70, BitOR($ES_CENTER, $ES_READONLY, $ES_WANTRETURN, $WS_BORDER, $ES_UPPERCASE), BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE)) GUICtrlSetData($Edit1, "A") GUICtrlSetFont($Edit1, 32, 400, 0, "font") $Edit2 = GUICtrlCreateEdit("", 89, 56, 70, 70, BitOR($ES_CENTER, $ES_READONLY, $ES_WANTRETURN, $WS_BORDER, $ES_LOWERCASE), BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE)) GUICtrlSetData($Edit2, "a") GUICtrlSetFont($Edit2, 32, 400, 0, "font") $ButtonFont = GUICtrlCreateButton(@WindowsDir & '\Fonts', 16, 6, 144, 18) $Progress1 = GUICtrlCreateProgress(16, 130, 144, 8) $Combo1 = GUICtrlCreateCombo("Alle", 16, 30, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO, $WS_BORDER)) ;GUICtrlSetData($Combo1, "Arial|Comic Sans MS|Courier New|Lucida Sans") $Button1 = GUICtrlCreateButton("Start", 24, 144, 57, 17) $Button2 = GUICtrlCreateButton("Abbruch", 97, 144, 57, 17) $listview = GUICtrlCreateListView("Nr.|Datei|Name", 175, 5, 360, 145) $hLV_Handle = GUICtrlGetHandle($listview) _GUICtrlListView_SetColumnWidth($listview, 0, 28) _GUICtrlListView_SetColumnWidth($listview, 2, 215) ;$List1 = GUICtrlCreateList("", 168, 24, 137, 110, BitOR($LBS_NOTIFY,$LBS_SORT,$LBS_MULTICOLUMN,$WS_BORDER)) GUICtrlSetData($listview, "") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY") For $a = 1 To UBound($var) If StringRight($var[$a - 1][2], 3) = 'ttf' Then ;MsgBox(0, "Found", $var[$a - 1][2]) $aItems[$x] = GUICtrlCreateListViewItem($x & '|' & $var[$a - 1][2] & '|' & $var[$a - 1][0], $listview) $arrays[$x][0] = $x $arrays[$x][1] = $var[$a - 1][0] $arrays[$x][2] = $var[$a - 1][2] ;_ArrayDisplay($arrays) $FontDatName[$x] = $var[$a - 1][0] $Fonts[$x] = $var[$a - 1][2] $aktFontNames[$x] = GUICtrlSetData($Combo1, $var[$a - 1][0]) ;MsgBox(0, "Clicked", $Fonts[$x]) $x = $x + 1 EndIf Next ;_ArrayDisplay($arrays) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $MenuItem2 Exit Case $ButtonFont $fod = FileSelectFolder('Fontordner wählen', '') GUICtrlSetData($ButtonFont, $fod) If _GUICtrlButton_GetText($ButtonFont) = '' Then GUICtrlSetData($ButtonFont, @WindowsDir & '\Fonts') EndIf _GUICtrlListView_DeleteAllItems($listview) $FontList = _FileListToArray($fod, '*.ttf', 1) Case $Combo1 If _GUICtrlComboBox_GetEditText($Combo1) <> 'Alle' Then ;MsgBox(0, "Clicked", _GUICtrlComboBox_GetEditText($Combo1)) $results = StringTrimRight(_GUICtrlComboBox_GetEditText($Combo1), 11) $iIndex = _ArraySearch($arrays, _GUICtrlComboBox_GetEditText($Combo1), 0, 0, 0, 1, 1) ;MsgBox(0, "Gefunden an Stelle", $iIndex) ;MsgBox(0, "Font Name", $arrays[$iIndex][1]) $result = StringTrimRight($arrays[$iIndex][1], 11) GUICtrlSetFont($Edit1, 32, 400, 0, $result) GUICtrlSetFont($Edit2, 32, 400, 0, $result) EndIf Case $Button1 If _GUICtrlComboBox_GetEditText($Combo1) == 'Alle' Then For $z = 1 To $x Sleep(10) $res = StringTrimRight($arrays[$z][1], 11) GUICtrlSetFont($Edit1, 32, 400, 0, $res) GUICtrlSetFont($Edit2, 32, 400, 0, $res) GUICtrlSetData($Combo1, $arrays[$z][1]) GUICtrlSetData($Progress1, $z / $x * 100) For $s = 1 To $abcSplit[0] Sleep(10) GUICtrlSetData($Edit1, $abcSplit[$s]) GUICtrlSetData($Edit2, $abcSplit[$s]) $hMenu1 = GUICtrlGetHandle($Edit1) $hMenu2 = GUICtrlGetHandle($Edit2) $SsTake1 = _ScreenCapture_CaptureWnd('', $hMenu1, 4, 4, 66, 66) $SsTake2 = _ScreenCapture_CaptureWnd('', $hMenu2, 4, 4, 66, 66) _ScreenCapture_SaveImage(@DesktopDir & '\pics\Pic_big_' & $res & '_' & $s & '.jpg', $SsTake1) _ScreenCapture_SaveImage(@DesktopDir & '\pics\Pic_small_' & $res & '_' & $s & '.jpg', $SsTake2) Next $s = 1 GUICtrlSetData($Edit1, 'A') GUICtrlSetData($Edit2, 'a') Next Else $res = StringTrimRight(_GUICtrlComboBox_GetEditText($Combo1), 11) GUICtrlSetFont($Edit1, 32, 400, 0, $res) GUICtrlSetFont($Edit2, 32, 400, 0, $res) For $s = 1 To $abcSplit[0] GUICtrlSetData($Progress1, $s / $abcSplit[0]*100) $hMenu1 = GUICtrlGetHandle($Edit1) $hMenu2 = GUICtrlGetHandle($Edit2) GUICtrlSetData($Edit1, $abcSplit[$s]) GUICtrlSetData($Edit2, $abcSplit[$s]) $SsTake1 = _ScreenCapture_CaptureWnd('', $hMenu1, 4, 4, 66, 66) $SsTake2 = _ScreenCapture_CaptureWnd('', $hMenu2, 4, 4, 66, 66) _ScreenCapture_SaveImage(@DesktopDir & '\pics\Pic_big_' & $res & '_' & $s & '.jpg', $SsTake1) _ScreenCapture_SaveImage(@DesktopDir & '\pics\Pic_small_' & $res & '_' & $s & '.jpg', $SsTake2) Next $s = 1 GUICtrlSetData($Edit1, 'A') GUICtrlSetData($Edit2, 'a') EndIf EndSwitch If $fDblClk Then $fDblClk = False $aItem = _GUICtrlListView_GetItemTextArray($hLV_Handle) For $i = 1 To $aItem[0] $sText &= StringFormat("spalte[%2d] %s", $i, $aItem[$i]) & @LF Next ;~ MsgBox(4160, "Information", 'Text von Item' & @LF & @LF & $sText) ;~ MsgBox(0, "Double Clicked", _GUICtrlListView_GetItemText($hLV_Handle, _GUICtrlListView_GetSelectedIndices($hLV_Handle))) ;~ MsgBox(0, "Clicked", $aItem[3]) ;MsgBox(0, "Name", $aItem[2]) $result = StringTrimRight($aItem[3], 11) GUICtrlSetData($Combo1, $aItem[3]) GUICtrlSetFont($Edit1, 32, 400, 0, $result) GUICtrlSetFont($Edit2, 32, 400, 0, $result) $sText = '' EndIf WEnd ; React to double clicks on ListView Func MY_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tNMHDR, 1) = $hLV_Handle Then If DllStructGetData($tNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True EndIf $tNMHDR = 0 Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_NOTIFY Link to comment Share on other sites More sharing options...
JollyFace Posted October 4, 2011 Share Posted October 4, 2011 I may be of no help, but if I extract and run this part of your code, it is in fact centered. Maybe I don't quite understand what you are asking. $Edit1 = GUICtrlCreateEdit("", 16, 56, 70, 70, BitOR($ES_CENTER, $ES_READONLY, $ES_WANTRETURN, $WS_BORDER, $ES_UPPERCASE), BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE)) GUICtrlSetData($Edit1, "A") Link to comment Share on other sites More sharing options...
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