Systembedingte Text-Vergrößerung 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?

    mfg. Jam00

  • 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%)

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    über mich...

    ich habe meine Erfahrungen hauptsächlich gesammelt in (grobe Übersicht):

    - RibbonBar Automation
    - MySQL Nutzung
    - GUIs in vielerlei Ausprägung
    - Nutzung von Powershell / Batch in AutoIt
    - Windows Automatisierung

    außerhalb von AutoIt:

    - Sprachen: PS, Batch, php, html(5), javascript, (perl eingeschränkt), vbs
    - Powershell (AD, WPF inkl. Multi-Threading, ...)
    - Deployment-Automatisierung ohne SCCM
    - Office-Nutzung mit COM-Object (AutoIt, PowerShell)
    - ActiveDirectory und alles was damit zusammenhängt
    - Hyper-V Clustering (Converged / Hyper Converged)
    - Serverhardware (Konfiguration, Aufbau, Architektur, Betrieb)

    Lieblingsthema:

    günstige Automatisierung von Vorgängen, für die andere Firmen viel Geld nehmen

    more to come ...

    Einmal editiert, zuletzt von Schnuffel (7. Juli 2011 um 08:13)

  • 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!

    Spoiler anzeigen
    [autoit]

    #include <GDIP.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    $iW = 600
    $iH = 600

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Test", $iW, $iH)
    GUISetOnEvent(-3, "_Exit")

    [/autoit] [autoit][/autoit] [autoit]

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00AA00)
    $hPenG = _GDIPlus_PenCreate(0xFF00FF00, 2)
    $hPenR = _GDIPlus_PenCreate(0xFFFF0000, 1)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $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)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CreateStringPath($hGraphics, $sString, $fX, $fY, $fW, $fH, $sFont = "Arial")
    Local $hPath = _GDIPlus_PathCreate()

    [/autoit] [autoit][/autoit] [autoit]

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 0, 100, $hFormat)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    Local $fMX = $fW / $aBounds[2]
    Local $fMY = $fH / $aBounds[3]

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    Return $hPath
    EndFunc ;==>_CreateStringPath

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit]

    E