Jump to content

Recommended Posts

Posted
4 hours ago, WildByDesign said:

I would like to switch to using Base64 for these same PNG images so that we can have maximum sharpness

23 hours ago, argumentum said:

Base64:
"Base64 encoding works by converting binary data (like images, files) into a text format using 64 printable ASCII characters, allowing it to be safely sent over text-based systems (email, HTTP). It groups input data into 24-bit blocks (three 8-bit bytes), splits these into four 6-bit chunks, and maps each 6-bit value to a character from its 64-character set (A-Z, a-z, 0-9, +, /), adding padding ( == or = ) for incomplete blocks. "

Image with transparency:
"While standard RGB images use three channels (red, green, and blue) to display color, images with transparency add this fourth alpha channel that controls opacity. Each pixel in the alpha channel contains a value that determines how transparent that pixel should be, from completely invisible to fully opaque."

What is base64 to you ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
5 minutes ago, argumentum said:

What is base64 to you ?

To be completely honest, I don’t know much at all about Base64 and have zero experience with it.

I know that you quoted details about it, but even then I still don’t really understand it well.

Does that mean that I would lose any transparency?

Posted

Hi @WildByDesign,

base64 is a encoding schema which converts binary data to a readable string. It's encoding, not encryption.
Base64 doesn't effect the transparancy feature of a PNG image. So you basically create a "sharp" PNG file (which is stored as binary) and convert it to a string which can be processed in AutoIt for example.

So in case your source (origin) file is sharper as PNG, use it like you would use it as an ICO.
I didn't read the whole thread, so maybe I missed something, but as far as I could see, you're looking for a way to load the PNG file by GDIPlus? If so, you will find several examples in the forum 👍 .

Best regards
Sven

==> AutoIt related: 🔗 Organization AutoIt Community🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet🔗 autoit-webdriver-boilerplate

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Posted
2 hours ago, SOLVE-SMART said:

So in case your source (origin) file is sharper as PNG, use it like you would use it as an ICO.
I didn't read the whole thread, so maybe I missed something, but as far as I could see, you're looking for a way to load the PNG file by GDIPlus? If so, you will find several examples in the forum 👍 .

Yes, this is exactly it. Thank you. And you're right, there are many great examples throughout the forum. :)

Posted

@UEZ I might have an idea. We can actually draw these checkboxes from the theme. The size could be derived from DPI, but basically quite easy in general.

But the main question: Could we draw these checkbox states and store them into an ImageList?

The following will show dark mode checkboxes as long as the window has dark mode enabled:

DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2)

#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPIMisc.au3>
#include <WinAPISysWin.au3>
#include <WinAPITheme.au3>
#include <WindowsSysColorConstants.au3>

#include "GUIDarkTheme.au3"

_Example()

Func _Example()
    ; Create GUI
    Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 199)
    GUICtrlCreateLabel("test", 1, 1)
    _ApplyDarkTheme($hForm, True)
    #forceref $hForm
    Local $idPic = GUICtrlCreatePic('', 0, 0, 160, 199)
    Local $hPic = GUICtrlGetHandle($idPic)

    ; Create bitmap
    Local $hDev = _WinAPI_GetDC($hPic)
    Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
    Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 160, 199, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
    Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

    ; Draw objects
    Local $tRECT = _WinAPI_CreateRectEx(16, 16, 16, 16)
    Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'MS Shell Dlg')
    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    _WinAPI_SelectObject($hDC, $hFont)
    Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Button')
    If Not @error Then
        For $i = 1 To 11
            _WinAPI_DrawThemeBackground($hTheme, 3, $i, $hDC, $tRECT)
            ;_WinAPI_DrawThemeText($hTheme, 1, $i, $hDC, 'OK', $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER))
            _WinAPI_OffsetRect($tRECT, 0, 31)
        Next
        _WinAPI_CloseThemeData($hTheme)
    EndIf

    ; Merge bitmap
    Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 160, 199)
    _WinAPI_SelectObject($hDC, $hBitmap)
    _WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
    _WinAPI_ReleaseDC($hPic, $hDev)
    _WinAPI_SelectObject($hDC, $hSv)
    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteDC($hDC)

    ; Set bitmap to control
    _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
    Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
    If $hObj <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf

    GUISetState(@SW_SHOW)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Example

 

Posted

I changed in my example the drawing from GDI to GDI+ completely.

 

Func _GDIPlus_DrawRoundRect($hGfx, $iX, $iY, $iW, $iH, $iDiameter, $iBrushARGB, $iPenARGB, $fPenWidth = 1.0)
    Local Const $hPath = _GDIPlus_PathCreate()
       
    ; Top-left arc
    _GDIPlus_PathAddArc($hPath, $iX, $iY, $iDiameter, $iDiameter, 180, 90)
    ; Top-right arc
    _GDIPlus_PathAddArc($hPath, $iX + $iW - $iDiameter, $iY, $iDiameter, $iDiameter, 270, 90)
    ; Bottom-right arc
    _GDIPlus_PathAddArc($hPath, $iX + $iW - $iDiameter, $iY + $iH - $iDiameter, $iDiameter, $iDiameter, 0, 90)
    ; Bottom-left arc
    _GDIPlus_PathAddArc($hPath, $iX, $iY + $iH - $iDiameter, $iDiameter, $iDiameter, 90, 90)

    _GDIPlus_PathCloseFigure($hPath)

    If $iBrushARGB <> 0 Then 
        Local Const $hBrush = _GDIPlus_BrushCreateSolid($iBrushARGB)
        _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush)
        _GDIPlus_BrushDispose($hBrush)
    EndIf
    
    If $iPenARGB <> 0 Then
        Local Const $hPen = _GDIPlus_PenCreate($iPenARGB, $fPenWidth)
        _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen)
        _GDIPlus_PenDispose($hPen)
    EndIf

    _GDIPlus_PathDispose($hPath)
EndFunc   ;==>_GDIPlus_DrawRoundRect

Func _SetDarkTreeViewCheckboxes($hTreeView, $iW = 16, $iH = 16)
    Local $hImageList = _GUIImageList_Create($iW, $iH, 5, 3)

    Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

    ; --- Index 0: Unchecked ---
    _GDIPlus_GraphicsClear($hGfx, 0xFF000000 + $COLOR_EDIT_BG)
    _GDIPlus_DrawRoundRect($hGfx, 2 / 16 * $iW, 2 / 16 * $iH, 12 / 16 * $iW, 12 / 16 * $iH, 3, 0, 0xFF000000 + $COLOR_BORDER2, 1.5)

    Local $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp, 0)
    _GUIImageList_Add($hImageList, $hBmp_GDI)
    _WinAPI_DeleteObject($hBmp_GDI)

    ; --- Index 1: Checked ---
    _GDIPlus_GraphicsClear($hGfx, 0xFF000000 + $COLOR_EDIT_BG)
    _GDIPlus_DrawRoundRect($hGfx, 2 / 16 * $iW, 2 / 16 * $iH, 12 / 16 * $iW, 12 / 16 * $iH, 3, 0xFF60CDFF, 0xFF60CDFF, 1.0)

    Local $hCheckPen = _GDIPlus_PenCreate(0xFF0F2028, 1.5)
    _GDIPlus_GraphicsDrawLine($hGfx, 5 / 16 * $iW,  8 / 16 * $iH,  7 / 16 * $iW, 10 / 16 * $iH, $hCheckPen)
    _GDIPlus_GraphicsDrawLine($hGfx, 7 / 16 * $iW, 10 / 16 * $iH, 11 / 16 * $iW,  6 / 16 * $iH, $hCheckPen)

    $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp, 0)
    _GUIImageList_Add($hImageList, $hBmp_GDI)
    _WinAPI_DeleteObject($hBmp_GDI)

    ; --- Cleanup ---
    _GDIPlus_PenDispose($hCheckPen)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_ImageDispose($hBmp)
    _GUICtrlTreeView_SetStateImageList($hTreeView, $hImageList)

    Return True
EndFunc   ;==>_SetDarkTreeViewCheckboxes

It gives much more smoother drawings with aa.

 

To your new idea - I like it. You can draw to a GDI bitmap and add it to ImageList. Let me check it and add it to the example...

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)
2 hours ago, WildByDesign said:

@UEZ I might have an idea. We can actually draw these checkboxes from the theme. The size could be derived from DPI, but basically quite easy in general.

But the main question: Could we draw these checkbox states and store them into an ImageList?

The following will show dark mode checkboxes as long as the window has dark mode enabled:

DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2)

#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPIMisc.au3>
#include <WinAPISysWin.au3>
#include <WinAPITheme.au3>
#include <WindowsSysColorConstants.au3>

#include "GUIDarkTheme.au3"

_Example()

Func _Example()
    ; Create GUI
    Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 199)
    GUICtrlCreateLabel("test", 1, 1)
    _ApplyDarkTheme($hForm, True)
    #forceref $hForm
    Local $idPic = GUICtrlCreatePic('', 0, 0, 160, 199)
    Local $hPic = GUICtrlGetHandle($idPic)

    ; Create bitmap
    Local $hDev = _WinAPI_GetDC($hPic)
    Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
    Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 160, 199, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
    Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

    ; Draw objects
    Local $tRECT = _WinAPI_CreateRectEx(16, 16, 16, 16)
    Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'MS Shell Dlg')
    _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    _WinAPI_SelectObject($hDC, $hFont)
    Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Button')
    If Not @error Then
        For $i = 1 To 11
            _WinAPI_DrawThemeBackground($hTheme, 3, $i, $hDC, $tRECT)
            ;_WinAPI_DrawThemeText($hTheme, 1, $i, $hDC, 'OK', $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER))
            _WinAPI_OffsetRect($tRECT, 0, 31)
        Next
        _WinAPI_CloseThemeData($hTheme)
    EndIf

    ; Merge bitmap
    Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 160, 199)
    _WinAPI_SelectObject($hDC, $hBitmap)
    _WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
    _WinAPI_ReleaseDC($hPic, $hDev)
    _WinAPI_SelectObject($hDC, $hSv)
    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteDC($hDC)

    ; Set bitmap to control
    _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
    Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
    If $hObj <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf

    GUISetState(@SW_SHOW)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Example

 

This works in my example:
 

Func _SetDarkTreeViewCheckboxes($hTreeView)
    Local $hImageList = _GUIImageList_Create(16, 16, 5, 3)

    Local $hBmp_GDI = _WinAPI_ExtractThemeBackground($g_hGUI, 2) ;thanks to WildByDesign for the idea!
    _GUIImageList_Add($hImageList, $hBmp_GDI)
    _WinAPI_DeleteObject($hBmp_GDI)

    $hBmp_GDI = _WinAPI_ExtractThemeBackground($g_hGUI, 5)
    _GUIImageList_Add($hImageList, $hBmp_GDI)
    _WinAPI_DeleteObject($hBmp_GDI)

    _GUICtrlTreeView_SetStateImageList($hTreeView, $hImageList)

    Return True
EndFunc   ;==>_SetDarkTreeViewCheckboxes

Func _WinAPI_ExtractThemeBackground($hGUI, $iState, $iPart = 3, $iWidth = 16, $iHeight = 16)
    Local $hTheme = _WinAPI_OpenThemeData($hGUI, "DarkMode_DarkTheme::Button")
    If @error Then Return SetError(1, 0, 0)
    Local $hDC = _WinAPI_GetDC($hGUI)
    Local $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hObjOld = _WinAPI_SelectObject($hMemDC, $hHBitmap)
    Local $tRECT = _WinAPI_CreateRectEx(0, 0, $iWidth, $iHeight)
    _WinAPI_DrawThemeBackground($hTheme, $iPart, $iState, $hMemDC, $tRECT)
    If @error Then
        _WinAPI_CloseThemeData($hTheme)
        Return SetError(2, 0, 0)
    EndIf
    _WinAPI_SelectObject($hMemDC, $hObjOld)
    _WinAPI_ReleaseDC($hGUI, $hDC)
    _WinAPI_DeleteDC($hMemDC)
    _WinAPI_CloseThemeData($hTheme)
    Return $hHBitmap
EndFunc   ;==>_WinAPI_ExtractThemeBackground

Important is to use: "DarkMode_DarkTheme::Button"

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)
47 minutes ago, UEZ said:

Important is to use: "DarkMode_DarkTheme::Button

Your example works wonderfully. Sharp and perfectly matching the regular checkbox (button) control. Thank you. Now I should be able to get rid of the included png images.

By the way, I think we might need the newer function in AutoIt for OpenThemeDataForDpi for proper loading of resources. I’m not 100% sure, but the previous method may be resizing the resources.

 

Edited by WildByDesign
Posted

I put together the following (seems to work):

Func _WinAPI_OpenThemeDataForDpi($hWnd, $sClass, $iDPI)
    Local $sResult = DllCall('uxtheme.dll', 'handle', 'OpenThemeDataForDpi', 'hwnd', $hWnd, 'wstr', $sClass, "uint", $iDPI)
    If @error Then Return SetError(@error, @extended, 0)
    ; If Not $sResult[0] Then Return SetError(1000, 0, 0)

    Return $sResult[0]
EndFunc   ;==>_WinAPI_OpenThemeDataForDpi

For my monitor at 125%, I call it with:

_WinAPI_OpenThemeDataForDpi($hGUI, "DarkMode_DarkTheme::Button", 120)

A monitor at 100% would be:

_WinAPI_OpenThemeDataForDpi($hGUI, "DarkMode_DarkTheme::Button", 96)

And so on. That is so long as I did it right. It is working though.

This pairs nicely with @UEZ's _WinAPI_GetDpiForWindow() function since it returns in those exact DPI measurements.

Posted

@UEZ I was testing the DPI awareness of the checkboxes in your SampleControls for Dark Mode. If you drop the following code into your example, it gives perfect sharpness and size for the TreeView checkboxes:

Func _WinAPI_GetDpiForWindow($hWnd)
    Local $aResult = DllCall("user32.dll", "uint", "GetDpiForWindow", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support
    If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0)
    If Not $aResult[0] Then Return SetError(2, @extended, 0)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_GetDpiForWindow

Func _SetDarkTreeViewCheckboxes($hTreeView)
    Local $iSize
    Local $iDPI = _WinAPI_GetDpiForWindow($g_hGUI)
    Switch $iDPI
        Case 96
            $iSize = 13
        Case 120
            $iSize = 16
        Case 144
            $iSize = 20
        Case 192
            $iSize = 26
        Case 240
            $iSize = 32
        Case 288
            $iSize = 40
        Case 384
            $iSize = 52
        Case Else
            $iSize = 16 ; this would need to stretch
    EndSwitch

    Local $hImageList = _GUIImageList_Create($iSize, $iSize, 5, 3)

    Local $hBmp_GDI = _WinAPI_ExtractThemeBackground($g_hGUI, 2, 3, $iSize, $iSize, $iDPI) ;thanks to WildByDesign for the idea!
    _GUIImageList_Add($hImageList, $hBmp_GDI)
    _WinAPI_DeleteObject($hBmp_GDI)

    $hBmp_GDI = _WinAPI_ExtractThemeBackground($g_hGUI, 5, 3, $iSize, $iSize, $iDPI)
    _GUIImageList_Add($hImageList, $hBmp_GDI)
    _WinAPI_DeleteObject($hBmp_GDI)

    _GUICtrlTreeView_SetStateImageList($hTreeView, $hImageList)

    Return True
EndFunc   ;==>_SetDarkTreeViewCheckboxes

Func _WinAPI_ExtractThemeBackground($hGUI, $iState, $iPart = 3, $iWidth = 16, $iHeight = 16, $iDPI = 96)
    ;Local $hTheme = _WinAPI_OpenThemeData($hGUI, "DarkMode_DarkTheme::Button")
    Local $hTheme = _WinAPI_OpenThemeDataForDpi($hGUI, "DarkMode_DarkTheme::Button", $iDPI)
    If @error Then Return SetError(1, 0, 0)
    Local $hDC = _WinAPI_GetDC($hGUI)
    Local $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hObjOld = _WinAPI_SelectObject($hMemDC, $hHBitmap)
    Local $tRECT = _WinAPI_CreateRectEx(0, 0, $iWidth, $iHeight)
    _WinAPI_DrawThemeBackground($hTheme, $iPart, $iState, $hMemDC, $tRECT)
    If @error Then
        _WinAPI_CloseThemeData($hTheme)
        Return SetError(2, 0, 0)
    EndIf
    _WinAPI_SelectObject($hMemDC, $hObjOld)
    _WinAPI_ReleaseDC($hGUI, $hDC)
    _WinAPI_DeleteDC($hMemDC)
    _WinAPI_CloseThemeData($hTheme)
    Return $hHBitmap
EndFunc   ;==>_WinAPI_ExtractThemeBackground

Func _WinAPI_OpenThemeDataForDpi($hWnd, $sClass, $iDPI)
    Local $sResult = DllCall('uxtheme.dll', 'handle', 'OpenThemeDataForDpi', 'hwnd', $hWnd, 'wstr', $sClass, "uint", $iDPI)
    If @error Then Return SetError(@error, @extended, 0)
    ; If Not $sResult[0] Then Return SetError(1000, 0, 0)

    Return $sResult[0]
EndFunc   ;==>_WinAPI_OpenThemeDataForDpi

 

If there is not a match for the DPI (some sort of in between size) it would hit Case Else and that part would potentially need extra work to stretch the checkbox image to fit.

Posted

GUIDarkTheme 0.9.2:

  • TreeView/ListView checkboxes are now drawn from theme (thanks to @UEZ for help on this)
    • No more ICO/PNG resources
  • Switched from WM_NCPAINT to WM_WINDOWPOSCHANGED for overpainting white line
    • WM_NCPAINT was not necessary and had potential conflicts

Next I am going to add the ability to change the font family and font size used in the menubar.

GUIDarkTheme-0.9.2.7z

Posted

I was able to go through and confirm some of the sizes for various DPI scaling. It seems that the theming engine does not stretch the resources at all. For the in between scaling (eg. 175%, 225%, etc.) they use the next closest resource size.

For example, a regular checkbox size on my 150% scaled monitor is 20px. There is no specific resource size for 175%, so they use 20px as well. Then 26px for 200% which they do have a resource for.

Here is the updated Switch Case where I commented what is confirmed (either by testing or by msstyles info). My main monitor does not have 200% and above. So if anyone can test the in between sizes which do not have a resource available, please confirm. You just have to get the pixel measurement of the main checkbox(button) control. Then I use that to determine the sizes for the TreeView/ListView checkbox sizes.

Switch $iDPI            ; Scaling:
        Case 96             ; 100% - confirmed (13px)
            $iSize = 13
        Case 120            ; 125% - confirmed (16px)
            $iSize = 16
        Case 144            ; 150% - confirmed (20px)
            $iSize = 20
        Case 168            ; 175% - confirmed (20px)
            $iSize = 20
        Case 192            ; 200% - confirmed (26px)
            $iSize = 26
        Case 216            ; 225% - (?px)
            $iSize = 26
        Case 240            ; 250% - confirmed (32px)
            $iSize = 32
        Case 264            ; 275% - (?px)
            $iSize = 32
        Case 288            ; 300% - confirmed (40px)
            $iSize = 40
        Case 312            ; 325% - (?px)
            $iSize = 40
        Case 336            ; 350% - (?px)
            $iSize = 40
        Case 360            ; 375% - (?px)
            $iSize = 40
        Case 384            ; 400% - confirmed (52px)
            $iSize = 52
        Case Else
            $iSize = 16 ; this would need to stretch
        ; NOTE: msstyles resources do not contain resources above 400% scaling at this time
    EndSwitch

 

Posted

I didn't have the right values in for all of those in between sizes on that release. I have to go out right now for a few hours. But if you have a moment, you could try adding:

Case 168            ; 175% - confirmed (20px)
    $iSize = 20

Otherwise I will have to update them when I get home anyway. I'll have to see at which point this could be failing.

Posted
...
        $iDPI = __WinAPI_GetDpiForWindow($hGUI)
        ConsoleWrite('"GUIDarkTheme.au3"(' & @ScriptLineNumber & ') : $iDPI = ' & $iDPI & @CRLF)
        Switch $iDPI
            Case 96
                $iSize = 13
            Case 120
                $iSize = 16
            Case 144, 168
                $iSize = 20
...
"GUIDarkTheme.au3"(1888) : $iDPI = 0
"GUIDarkTheme.au3"(1858) : $iDPI = 0

$iSize = 16 ; this would need to stretch
...are you cheating 🤔

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
11 minutes ago, argumentum said:

$iSize = 16 ; this would need to stretch
...are you cheating 🤔

Not sure about that part yet.

Can you please let me know the pixel size of your regular checkbox from the button control?

You may have to copy screenshot into image editing program and manually measure height and width of checkbox.

There must be more to the resource sizing than just the DPI. I am guessing the bigger resolution must play a role too.

Thank you. :)

Posted
#EndRegion Enable GUI LIGHTMODE

Func _GUIDarkThemeDebugOnOff($bTrueFalse = Default)
    If IsKeyword($bTrueFalse) Then ; return state
        Return _GUIDarkThemeDebug("", "", 0, 0, -10)
    ElseIf $bTrueFalse Then ; debug ON
        Return _GUIDarkThemeDebug("", "", 0, 0, -12)
    Else ; debug OFF
        Return _GUIDarkThemeDebug("", "", 0, 0, -11)
    EndIf
EndFunc   ;==>_GUIDarkThemeDebugOnOff

Func _GUIDarkThemeDebug($sStr, $sScript = '"GUIDarkTheme.au3"', $iErr = @error, $iExt = @extended, $iLine = @ScriptLineNumber)
    Local Static $bDebug = False
    Switch $iLine
        Case -10
            Return $bDebug
        Case -11
            $bDebug = False
            Return $bDebug
        Case -12
            $bDebug = True
            Return $bDebug
    EndSwitch
    If Not $bDebug Then Return SetError($iErr, $iExt, 0)
    Local $iRet = ConsoleWrite($sScript & '(' & $iLine & ') : ' & $iErr & '/' & $iExt & ' - ' & $sStr)
    Return SetError($iErr, $iExt, $iRet)
EndFunc   ;==>_GUIDarkThemeDebug

This goes at the bottom of your UDF

And this in you test script

...
; this must be set after DPI
#include "GUIDarkTheme.au3"
;~ _GUIDarkThemeDebugOnOff(True)
...

..and that way you can ask users to test and return the console reading by uncommenting one line:

"GUIDarkTheme.au3"(1888) : 2/0 - $iDPI = 0
"GUIDarkTheme.au3"(1858) : 2/0 - $iDPI = 0

And there you'll see an @error = 2 from the prior line.

..or continue sharpening your graphics using Bas64 😒

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
1 hour ago, argumentum said:

..or continue sharpening your graphics using Bas64 😒

No way. 😁

1 hour ago, argumentum said:

..and that way you can ask users to test and return the console reading by uncommenting one line:

"GUIDarkTheme.au3"(1888) : 2/0 - $iDPI = 0
"GUIDarkTheme.au3"(1858) : 2/0 - $iDPI = 0

And there you'll see an @error = 2 from the prior line.

This is a smart idea. Thank you. Especially good while trying to get this all figured out.

Does it do ConsoleWrite only in the case of error?

I assume that is the case because mine is not showing any output from it. But maybe that is because it is working properly on my system.

From your output, it seems to show that it's failing to get the DPI on your system and showing 0. If that is the case, that would explain the problem because it would then be creating a checkbox sized 0x0.

I need to get to the bottom of this. I promise you it looks sharp and awesome! (when it works) 😆

Maybe I can get the proper size (DPI and all) from getting the size of the already created ImageList. I will try that first.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...