Ich habe gerade eine tolle Funktion im engl. Forum gefunden (_GUICtrlStatusBar_SetFont).
Vielleicht kennt ihr die ja schon, aber ich habe trotzdem mal ein Beispiel-Script erstellt, mit dem man die Schriftgröße der Statusbar während der Laufzeit ändern kann.
Das brauchte ich für ein anderes Projekt und dachte, dass es der Ein oder Andere auch gebrauchen kann.
AutoIt
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <SendMessage.au3>
#include <WinAPIConv.au3>
#include <WinAPIGdiInternals.au3>
#include <WinAPIHObj.au3>
#include <WindowsConstants.au3>
Global $g_iFontSize = 18, $g_iFontWeight = 400, $g_iFontStyle = 2, $g_sFontname = 'Times New Roman'
Global $g_hGui = GUICreate('Statusbar change fontsize', 800, 200)
GUISetState(@SW_SHOW, $g_hGui)
GUISetBkColor(0xCCCCCC)
Global $g_hFont, $g_aParts[] = [120, -1], $g_aText[] = [$g_iFontSize & 'px', '<STRG> & Mousewheel to change']
Global $g_hStatus = _GUICtrlStatusBar_Create($g_hGui, $g_aParts, $g_aText)
_GUICtrlStatusBar_SetMinHeight($g_hStatus, $g_iFontSize)
_GUICtrlStatusBar_SetFont($g_hStatus, $g_iFontSize, $g_iFontWeight, $g_iFontStyle, $g_sFontname)
GUISetState(@SW_SHOW, $g_hGui)
GUIRegisterMsg($WM_MOUSEWHEEL, '_WM_MOUSEWHEEL')
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
If $g_hFont Then _WinAPI_DeleteObject($g_hFont)
Exit
EndSwitch
WEnd
Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $lParam
Local Const $iWheelDelta = 120, $MK_CONTROL = 0x0008, $iMinSize = 10, $iMaxSize = 48
Local $iWheel, $iVKey
Local Static $iOldSize = $g_iFontSize
$iWheel = _WinAPI_HiWord($wParam) / $iWheelDelta ; down = -1, up = 1
$iVKey = _WinAPI_LoWord($wParam)
If BitAND($iVKey, $MK_CONTROL) Then ; if pressed [STRG/CTRL]
$g_iFontSize += $iWheel
If $g_iFontSize < $iMinSize Then $g_iFontSize -= $iWheel
If $g_iFontSize > $iMaxSize Then $g_iFontSize -= $iWheel
If $g_iFontSize <> $iOldSize Then
$iOldSize = $g_iFontSize
_GUICtrlStatusBar_SetMinHeight($g_hStatus, $g_iFontSize)
_GUICtrlStatusBar_SetText($g_hStatus, $g_iFontSize & 'px')
_GUICtrlStatusBar_SetFont($g_hStatus, $g_iFontSize, $g_iFontWeight, $g_iFontStyle, $g_sFontname)
EndIf
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_MOUSEWHEEL
; from rasim (https://www.autoitscript.com/forum/topic/88063-_guictrlstatusbar_settext/?do=findComment&comment=632524)
Func _GUICtrlStatusBar_SetFont($hWnd, $iSize = 15, $iWeight = 400, $iAttr = 0, $sFontName = "Arial")
If $g_hFont Then _WinAPI_DeleteObject($g_hFont)
$g_hFont = _WinAPI_CreateFont($iSize, 0, 0, 0, $iWeight, _
BitAND($iAttr, 2), BitAND($iAttr, 4), BitAND($iAttr, 8), _
$DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, _
$CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, _
0, $sFontName)
_SendMessage($hWnd, $WM_SETFONT, $g_hFont, 1)
EndFunc ;==>_GUICtrlStatusBar_SetFont
Alles anzeigen