Hallo,
Ich habe das Problem das wenn ich mit GDIPlus eine Schrift Zeichne, dass wenn z.B. bei Windows 7 die Schrift auf 120% gestellt ist das die dann auch im Programm größer wird, aber das darf nicht, kann ich das Irgendwie verhindern?
Hallo,
Ich habe das Problem das wenn ich mit GDIPlus eine Schrift Zeichne, dass wenn z.B. bei Windows 7 die Schrift auf 120% gestellt ist das die dann auch im Programm größer wird, aber das darf nicht, kann ich das Irgendwie verhindern?
Ich könnte mir vorstellen, dass man die 120% irgendwo auslesen kann und dann die Schriftarten im eigenen Programm dementsprechend kleiner zeichnet. Die Frage ist nur, wo liest man diese Einstellung aus?
Hi Jam00,
dieser Reg-Key könnte helfen:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager\SizeName
100% sollte sein: NormalSize
120% sollte sein: LargeSize (oder so ähnlich)
Nachtrag für Win7:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager\LastLoadedDPI
andert sich von 96 (100%) bis hin zu 144(150%)
Wenn du erreichen willst, daß ein Text immer die selbe Größe hat, bzw. immer ein gleich großes Rechteck darstellt, dann könntest du es so machen:
Achtung: benötigt GDIp.au3!
#include <GDIP.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$iW = 600
$iH = 600
$hGui = GUICreate("Test", $iW, $iH)
GUISetOnEvent(-3, "_Exit")
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
$hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF00AA00)
$hPenG = _GDIPlus_PenCreate(0xFF00FF00, 2)
$hPenR = _GDIPlus_PenCreate(0xFFFF0000, 1)
GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUISetState()
$hPath = _CreateStringPath($hGfxBuffer, "Test String", 100, 100, 300, 50, "Arial")
_GDIPlus_GraphicsDrawRect($hGfxBuffer, 100, 100, 300, 50, $hPenR)
_GDIPlus_GraphicsFillPath($hGfxBuffer, $hPath, $hBrush)
_GDIPlus_GraphicsDrawPath($hGfxBuffer, $hPath, $hPenG)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
While 1
Sleep(100)
WEnd
Func _CreateStringPath($hGraphics, $sString, $fX, $fY, $fW, $fH, $sFont = "Arial")
Local $hPath = _GDIPlus_PathCreate()
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
_GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 0, 100, $hFormat)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
Local $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
Local $fMX = $fW / $aBounds[2]
Local $fMY = $fH / $aBounds[3]
Local $hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, $fX - $aBounds[0] * $fMX, $fY - $aBounds[1] * $fMY)
_GDIPlus_MatrixScale($hMatrix, $fMX, $fMY)
_GDIPlus_PathTransform($hPath, $hMatrix)
_GDIPlus_MatrixDispose($hMatrix)
Return $hPath
EndFunc ;==>_CreateStringPath
Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_PAINT
Func _Exit()
_GDIPlus_PathDispose($hPath)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_PenDispose($hPenR)
_GDIPlus_PenDispose($hPenG)
_GDIPlus_GraphicsDispose($hGfxBuffer)
_GDIPlus_BitmapDispose($hBmpBuffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
E