gibt es eine Möglichkeit, das sich das Splash-Fenster automatisch an die Schriftgröße anpasst?
Also gerade so groß ist das der Text hineinpasst?
SplashTextOn - Fenster automatisch an Schriftgröße anpassen
-
- [ offen ]
-
Bitboy -
8. Januar 2010 um 10:44 -
Geschlossen -
Erledigt
-
-
Hallo Bitboy,
meines Wissens nach nein, aber schau dir doch einmal Splash - GUI Generator von BugFix an,
mfg (Ato)Bert
-
Nee, damit geht es leider auch nicht
Mist, wenn man einstellt, dass der Text vertial zentriert angezeigt werden soll, dann funktioniert nichtmal mehr der automatische zeilenumbruch
-
hilft diese Funktion vielleicht weiter?
[autoit]Func _GetTextSize($nText, $iFontSize = 8.5, $sFont = 'Microsoft Sans Serif', $iFontAttributes = 0)
[/autoit]
;Author: Bugfix
;Modified: funkey
If $nText = '' Then Return
$hOld = GUISwitch($DUMMY)
Local $hGUI = GUICreate("Textmeter by Bugfix")
_GDIPlus_Startup()
Local $hFormat = _GDIPlus_StringFormatCreate(0)
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iFontAttributes, 3)
Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)
Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
Local $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
Local $aSize[2] = [$iWidth, $iHeight]
GUISwitch($hOld)
Return $aSize
EndFunc ;==>_GetTextSize -
Ich habe daraus mal ein Beispiel geschrieben, weil ich testen wollte, ob man die Funktion brauchen kann.
Beispiel zu _GetTextSize
[autoit]#Include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]$sText = "Splash-Demo-Text"
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$aTextSize = _GetTextSize($sText,36,'Times New Roman')
SplashTextOn("", $sText, $aTextSize[0] + 6, $aTextSize[1] + 20, -1, -1, -1, "Times New Roman", 36)
Sleep(5000)
SplashOff()Func _GetTextSize($nText, $iFontSize = 8.5, $sFont = 'Microsoft Sans Serif', $iFontAttributes = 0)
[/autoit]
;Author: Bugfix
;Modified: funkey
Local $DUMMY
If $nText = '' Then Return
$hOld = GUISwitch($DUMMY)
Local $hGUI = GUICreate("Textmeter by Bugfix")
_GDIPlus_Startup()
Local $hFormat = _GDIPlus_StringFormatCreate(0)
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iFontAttributes, 3)
Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)
Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
Local $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
Local $aSize[2] = [$iWidth, $iHeight]
GUISwitch($hOld)
Return $aSize
EndFunc ;==>_GetTextSize -
Hab mal versucht die funktion so zu ändern dass automatisch die Zeile umgebrochen wird wenn die Länge zu groß ist
aber irgendwie funktioniert es nicht richtig. Ich finde auch den Fehler auf anhieb nicht. Hat jemand eine idee?EDIT: Nochmal etwas geändert, der Code für den Zeilenumbruch ist wohl noch etwas wackelig, aber sonst gehts schon ganz gut
Spoiler anzeigen
[autoit]Func _GetTextSize($nText, $AutoCRLFWidth=0, $iFontSize = 12, $sFont = 'Microsoft Sans Serif', $iFontAttributes = 0)
[/autoit] [autoit][/autoit] [autoit]
Local $DUMMY, $ainfo, $iWidth, $iHeight, $retArr[4]
Local $WordArr[1][1], $tmpArr, $SpaceSize, $WordSize, $CRLFString, $LineSize=0, $lines=0If $sFont = "" Then $sFont = 'Microsoft Sans Serif'
[/autoit] [autoit][/autoit] [autoit]
;Author: Bugfix
;Modified: funkey
If $nText = '' Then Return
$hOld = GUISwitch($DUMMY)
Local $hGUI = GUICreate("Textmeter by Bugfix")
_GDIPlus_Startup()
Local $hFormat = _GDIPlus_StringFormatCreate(0)
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iFontAttributes, 3)
Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0)
Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI);Zeilenumbrüche einfügen
[/autoit] [autoit][/autoit] [autoit]
If $AutoCRLFWidth > 0 Then
$tmpArr = StringSplit($nText, " ")
Redim $WordArr[$tmpArr[0]+1][2]
;_ArrayDisplay($tmpArr);Daten übertragen
[/autoit] [autoit][/autoit] [autoit]
$WordArr[0][0] = $tmpArr[0]
For $i = 1 To $tmpArr[0]
$WordArr[$i][0] = $tmpArr[$i]
Next
;_ArrayDisplay($WordArr);Breite eines Leerzeichens
[/autoit] [autoit][/autoit] [autoit]
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, " ", $hFont, $tLayout, $hFormat)
$SpaceSize = Ceiling(DllStructGetData($aInfo[0], "Width"))For $i = 1 To $WordArr[0][0]
[/autoit] [autoit][/autoit] [autoit]
;Länge der einzelnen Wörter ausrechnen
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $WordArr[$i][0], $hFont, $tLayout, $hFormat)
$WordArr[$i][1] = Ceiling(DllStructGetData($aInfo[0], "Width"));Falls erforderlich Zeilenumbruch einfügen
[/autoit] [autoit][/autoit] [autoit]
If $Linesize + $WordArr[$i][1] + $SpaceSize > $AutoCRLFWidth Then
$CRLFString = $CRLFString & @CRLF & $WordArr[$i][0]
$LineSize = $WordArr[$i][1]
$lines = $lines + 1
Else
$CRLFString = $CRLFString & " " & $WordArr[$i][0]
$LineSize = $LineSize + $WordArr[$i][1] + $SpaceSize
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $LineSize = ' & $LineSize & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
EndIf
Next
;unnötige Leerzeichen entfernen
$CRLFString = StringStripWS($CRLFString, 3)
$nText=$CRLFString
EndIf$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)
[/autoit] [autoit][/autoit] [autoit]
$iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
$iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))
Msgbox(0,"debug", $nText);Ressourcen freigeben
[/autoit] [autoit][/autoit] [autoit]
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
$retArr[0] = $iWidth
$retArr[1] = $iHeight
$retArr[2] = $lines + 1
$retArr[3] = $nText
GUISwitch($hOld)
Return $retArr
EndFunc ;==>_GetTextSizeFunc AutoSizeSplash($Title, $Content, $Width=500, $xpos=-1, $ypos=-1, $opt=32, $fontname="", $fontsize=12)
[/autoit] [autoit][/autoit] [autoit]
Local $SizeArr = _GetTextSize($Content, $Width, $fontsize, $fontname)
If $SizeArr[3] = "" Then $SizeArr[3] = $Content
If $SizeArr[0] > $Width Then $Width = $SizeArr[0]
_ArrayDisplay($SizeArr)
SplashTextOn($Title, $SizeArr[3], $Width, $SizeArr[1] + 30, $xpos, $ypos, $opt, $fontname, $fontsize)
EndFunc#include <gdiplus.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <array.au3>AutoSizeSplash("Hallo Welt", "Das ist ein ganz ganz langer text mit vielen" & @CRLF & @CRLF & "vielen Wörtern zum Gucken ob es funktioniert." & _
[/autoit]
" Deswegen kommen jetzt noch ein paar mehr Zeichen und hier ist schließlich Ende.", 600 ,-1,-1, 33, "", 14)
Sleep(5000)
SplashOff() -
Hatte das Problem daß der Text bei unterschiedlichen Anzeigeeinstellungen plötzlich nicht mehr ins SplashText Fenster passen wollte!
[autoit]
Folgendes Script brachte die Lösung:
Bleibt das Textfeld immer gleich groß, so kann mit der einfachen Funktion: _WinAPI_TwipsPerPixel() die Fenstergrösse an die Anzeigeeinstellungen (z.B.: in Windows 7: Systemsteuerung\Darstellung und Anpassung\Anzeige: Kleiner, Mittel oder Größer) angepasst werden!
[/autoit]
#include <WinAPI.au3>
$TwipsX = _WinAPI_TwipsPerPixelX()
$FontHight = 14
;Korrekturfaktor damit der Text ins Fenster passt (experimentell ermitteln...)
$CF = 25
; Fenster z.B.: im 16:9 Kinoformat
$SpW= 16 * $CF / $TwipsX * $FontHight
$SpH= 9 * $CF / $TwipsX * $FontHight
SplashTextOn("Bitte warten", "Überschrift" & @CRLF & @CRLF & "Bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten, bitte warten Ende ",$SpW,$SpH, -1, -1, 21, "", $FontHight)
sleep(5000) -
- Offizieller Beitrag
Du "Leichenschänder"
Zitat von letzter BeitragSamstag, 9. Januar 2010, 18:52
-
Warum Leichenschänder???
Der Thread ist noch offen - und wenn es jemanden hilft - warum nicht mal was neues!
Ausserdem macht mein Script auch genau was verlangt wird - man kann auch die Schriftgrösse ($FontHight) ändern und das Fenster passt sich ebenfalls an!
Sonst müsste es ja heissen:
SplashTextOn - Fenster automatisch an Textlänge anpassen
Übrigens wäre das einen Verbesserungsvorschlag für Autoit Wert, daß dies ein zusätzlicher SplashTextOn Parameter wird (autoscalierung oder so...)