Jump to content

Recommended Posts

Posted

Problem:

 image.png.fcda2af36d5ca2fa3384e73ea4658a60.png

When creating a win32-darkmode menu bar, it is ownerdrawn and one of the known problems is that it creates a white line at the bottom. My understanding is that the white line and the menubar are both part of the non-client area.

Known solutions to this problem in C++ (https://github.com/notepad-plus-plus/notepad-plus-plus/blob/bab3573be708bb908b8080e3e2007ea78a7f1932/PowerEditor/src/NppDarkMode.cpp#L672) get the size, create a dark brush and fill that line with a dark brush. But that is an area in AutoIt that I am not familiar with at all.

Example:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <WinAPITheme.au3>
#include "GUIDarkMode_v0.02mod.au3"
#include "ModernMenuRaw.au3"

DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -4)

    _SetMenuBkColor(0x202020)
    _SetMenuIconBkColor(0x202020)
    _SetMenuIconBkGrdColor(0x202020)
    _SetMenuSelectBkColor(0x202020)
    _SetMenuSelectRectColor(0x202020)
    _SetMenuSelectTextColor(0xFFFFFF)
    _SetMenuTextColor(0xFFFFFF)

Example()

Func Example()
        $hGUI = GUICreate("My GUI", 300, 200)

        ;Local $idFileMenu = GUICtrlCreateMenu("&File")
        Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI)
        GUICtrlCreateMenuItem("&Open", $idFileMenu)
        GUICtrlCreateMenuItem("&Save", $idFileMenu)
        GUICtrlCreateMenuItem("", $idFileMenu)

        Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
        GUICtrlCreateMenuItem("View", $idOptionsMenu)
        GUICtrlCreateMenuItem("", $idOptionsMenu)
        GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

        GUICtrlCreateMenuItem("", $idFileMenu)
        Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

        ;Local $idHelpMenu = GUICtrlCreateMenu("&?")
        Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI)
        Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

        Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

        GuiDarkmodeApply($hGUI)
        GUISetState(@SW_SHOW)

        Local $idMsg
        ; Loop until the user exits.
        While 1
                $idMsg = GUIGetMsg()

                Switch $idMsg
                        Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE
                                ExitLoop

                        Case $idAboutItem
                                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
                EndSwitch
        WEnd
EndFunc   ;==>Example

 

There are 2 UDFs that are required (at least in this example) to do the ownerdraw for the menubar and apply dark mode in the other parts of the menu items and GUI. Those are attached to this post.

The link (above) to the Notepad++ source code section that handles the filling of that white line will hopefully give someone an idea of how they solve that problem. I am hoping that someone can help with a solution in AutoIt to solve the filling of that white line. I just don't have the experience with non-client area or custom brushes, etc.

Thank you very much for your time. Always appreciated.

GUIDarkMode_v0.02mod.au3 ModernMenuRaw.au3

Posted

For the next version ( now in public beta ) you'll need to change this:

; #CONSTANTS# ===================================================================================================================
If Not IsDeclared("DWMWA_USE_IMMERSIVE_DARK_MODE") Then Global Const $DWMWA_USE_IMMERSIVE_DARK_MODE = (@OSBuild <= 18985) ? 19 : 20            ; before this build set to 19, otherwise set to 20, no thanks Windaube to document anything ??
; ===============================================================================================================================

 

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:

For the next version ( now in public beta ) you'll need to change this:

Thank you for the heads up. That reminds me that I should probably start testing the beta version as well. I did briefly check over the release notes a few days ago and there is a lot of nice changes in there.

Posted

Here is initial version. Coordinates are wrong. I need to do other things now.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <WinAPITheme.au3>
#include "GUIDarkMode_v0.02mod.au3"
#include "ModernMenuRaw.au3"

#include <GuiMenu.au3>
#include <Array.au3>
#include <WinAPIDiag.au3>
#include <WinAPIConv.au3>
#include <WinAPIGdiDC.au3>

DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "HWND", "DPI_AWARENESS_CONTEXT" - 4)

_SetMenuBkColor(0x202020)
_SetMenuIconBkColor(0x202020)
_SetMenuIconBkGrdColor(0x202020)
_SetMenuSelectBkColor(0x202020)
_SetMenuSelectRectColor(0x202020)
_SetMenuSelectTextColor(0xFFFFFF)
_SetMenuTextColor(0xFFFFFF)

Example()

Func Example()
    $hGUI = GUICreate("My GUI", 300, 200)

    ;Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI)
    GUICtrlCreateMenuItem("&Open", $idFileMenu)
    GUICtrlCreateMenuItem("&Save", $idFileMenu)
    GUICtrlCreateMenuItem("", $idFileMenu)

    Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
    GUICtrlCreateMenuItem("View", $idOptionsMenu)
    GUICtrlCreateMenuItem("", $idOptionsMenu)
    GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

    GUICtrlCreateMenuItem("", $idFileMenu)
    Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

    ;Local $idHelpMenu = GUICtrlCreateMenu("&?")
    Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI)
    Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

    Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

    GuiDarkmodeApply($hGUI)
    GUISetState(@SW_SHOW)

    $aMenuBarInfo = _GUICtrlMenu_GetMenuBarInfo($hGUI, 0, 1)
    _ArrayDisplay($aMenuBarInfo)
    $rcClient = _WinAPI_GetClientRect($hGUI)
    _WinAPI_DisplayStruct($rcClient, $tagRECT,"rcClinet before")

    ;CHAT GPT
    Local $aCall = DllCall("user32.dll", "int", "MapWindowPoints", _
            "hwnd", $hGUI, _ ; hWndFrom
            "hwnd", 0, _     ; hWndTo
            "ptr", DllStructGetPtr($rcClient), _
            "uint", 2)       ;number of points - 2 for RECT structure

    If @error Then
        MsgBox($MB_ICONERROR, "Error", @error)
        Exit
    EndIf
    _WinAPI_DisplayStruct($rcClient, $tagRECT,"rcClinet after")

    $rcWindow = _WinAPI_GetWindowRect($hGUI)

    _WinAPI_OffsetRect($rcClient, -$rcWindow.left, -$rcWindow.top)

    $rcAnnoyingLine = DllStructCreate($tagRECT)
    $rcAnnoyingLine.left = $rcClient.left
    $rcAnnoyingLine.top = $rcClient.top
    $rcAnnoyingLine.right = $rcClient.right
    $rcAnnoyingLine.bottom = $rcClient.bottom
;~  _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT)


    $rcAnnoyingLine.bottom = $rcAnnoyingLine.top
    $rcAnnoyingLine.top = $rcAnnoyingLine.top - 1
;~  _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT,"annoying line")

    $hDC = _WinAPI_GetDC($hGUI)
    $hSolidBrush=_WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF00FF)
    _WinAPI_FillRect($hDC, $rcAnnoyingLine, $hSolidBrush)
    _WinAPI_ReleaseDC($hGUI, $hDC)

    _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT,"annoying line")

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE
                _WinAPI_DeleteObject($hSolidBrush)
                ExitLoop

            Case $idAboutItem
                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
        EndSwitch
    WEnd
EndFunc   ;==>Example

 

Posted
4 hours ago, ahmet said:

Here is initial version. Coordinates are wrong. I need to do other things now.

Thank you for your time on this so far, it's very interesting. I am always quite amazed at what people are able to do with AutoIt. I am playing around with your code example. But I must admit, a lot of it is stuff that I have not learned yet.

Something that I just thought of also is whether or not a solution can be made that will adapt with a resizable window. What I mean is that if you resize the window, the line would stay along the bottom of the menubar.

Posted
On 7/17/2025 at 2:29 PM, ahmet said:

Coordinates are wrong.

I still haven’t figured out how to get the coordinates correct yet but also not sure how to manually paint the line over the non-client area.

Posted

:unsure:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <WinAPITheme.au3>
#include "GUIDarkMode_v0.02mod.au3"
#include "ModernMenuRaw.au3"

DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "HWND", "DPI_AWARENESS_CONTEXT" - 4)

_SetMenuBkColor(0x202020)
_SetMenuIconBkColor(0x202020)
_SetMenuIconBkGrdColor(0x202020)
_SetMenuSelectBkColor(0x202020)
_SetMenuSelectRectColor(0x202020)
_SetMenuSelectTextColor(0xFFFFFF)
_SetMenuTextColor(0xFFFFFF)

Example()

Func Example()
    $hGUI = GUICreate("My GUI", 300, 200)


    ;Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI)
    GUICtrlCreateMenuItem("&Open", $idFileMenu)
    GUICtrlCreateMenuItem("&Save", $idFileMenu)
    GUICtrlCreateMenuItem("", $idFileMenu)

    Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
    GUICtrlCreateMenuItem("View", $idOptionsMenu)
    GUICtrlCreateMenuItem("", $idOptionsMenu)
    GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

    GUICtrlCreateMenuItem("", $idFileMenu)
    Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

    ;Local $idHelpMenu = GUICtrlCreateMenu("&?")
    Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI)
    Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

    Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

    GuiDarkmodeApply($hGUI)

    GUISetState(@SW_SHOW)

    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
    $hGuiRect = GUICreate("", 300, 2, 0, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
    GUISetBkColor (0x202020)
    GUISetState(@SW_SHOW, $hGuiRect)
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE
                ExitLoop

            Case $idAboutItem
                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
        EndSwitch
    WEnd
EndFunc   ;==>Example

 

I know that I know nothing

Posted (edited)
...
;~     GUISetState(@SW_SHOW)

    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
    $hGuiRect = GUICreate("", 300, 2, 0, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
    GUISetBkColor (0x202020)
    GUISetState(@SW_SHOW, $hGuiRect)
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~

    GUISetState(@SW_SHOW, $hGUI)
...

..to avoid the flashing on load

Edit: It certainly needs more code:

Spoiler
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <WindowsConstants.au3>

#include <WinAPITheme.au3>
#include "GUIDarkMode_v0.02mod.au3"
#include "ModernMenuRaw.au3"

DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "HWND", "DPI_AWARENESS_CONTEXT" - 4)

_SetMenuBkColor(0x202020)
_SetMenuIconBkColor(0x202020)
_SetMenuIconBkGrdColor(0x202020)
_SetMenuSelectBkColor(0x202020)
_SetMenuSelectRectColor(0x202020)
_SetMenuSelectTextColor(0xFFFFFF)
_SetMenuTextColor(0xFFFFFF)

Example()

Func Example()
    $hGUI = GUICreate("My GUI", 300, 200, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
;~     $hGUI = GUICreate("My GUI", 300, 200)


    ;Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI)
    GUICtrlCreateMenuItem("&Open", $idFileMenu)
    GUICtrlCreateMenuItem("&Save", $idFileMenu)
    GUICtrlCreateMenuItem("", $idFileMenu)

    Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
    GUICtrlCreateMenuItem("View", $idOptionsMenu)
    GUICtrlCreateMenuItem("", $idOptionsMenu)
    GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

    GUICtrlCreateMenuItem("", $idFileMenu)
    Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

    ;Local $idHelpMenu = GUICtrlCreateMenu("&?")
    Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI)
    Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

    Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

    GuiDarkmodeApply($hGUI)

;~     GUISetState(@SW_SHOW)

    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~     $hGuiRect = GUICreate("", 300, 2, 0, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) ; for no resize
    $hGuiRect = GUICreate("", 301, 2, -5, -6, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) ;   for resize
;~     GUISetBkColor (0x202020) ; default
    GUISetBkColor (0xFF00FF) ; glow in the dark  =D
    GUISetState(@SW_SHOW, $hGuiRect)
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~

    GUISetState(@SW_SHOWMAXIMIZED, $hGUI)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE
                ExitLoop

            Case $idAboutItem
                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
        EndSwitch
    WEnd
EndFunc   ;==>Example

but, it could work. =/

Edited by argumentum
more

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

Posted
3 hours ago, ioa747 said:

:unsure:

Thank you for the example. I've never experimented with child GUI before, so this is really quite neat. It's a very creative technique to cover up the line. I'm going to continue trying some ideas based on your example.

One downside that I notice is that when you move the GUI around on the screen, it will occasionally show a flicker of the white line. I don't think that GuiCreate has any kind of double-buffer option to prevent flicker but I will try a few things to see.

1 hour ago, argumentum said:

Edit: It certainly needs more code:

Thank you for your time as well. Yes, it looks like resize will definitely need some more code. There might be some differences depending on user systems' titlebar size (varying from resize and non-resize) and possibly some differences varying with DPI. I will see what I can do to measure those things.

  • 2 weeks later...
Posted
On 7/17/2025 at 2:29 PM, ahmet said:

Here is initial version. Coordinates are wrong. I need to do other things now.

So I decided to come back to this _WinAPI_FillRect method to see if I could figure out the coordinates and also learn more about RECT because I had no experience with that. But I really need to solve this problem so that I can finish this project. I don't need resize, so static size/placement is fine.

I ended up manually inputting the coordinates that I needed for $rcAnnoyingLine.left, $rcAnnoyingLine.top, etc. just to see if it would work for what I needed.

This was neat because I could play around with different coordinates and place the line in different areas.

However, I realized very quickly that I could put it anywhere in the client area but it was not going over any of the non-client area which is where that white line is. Even with $rcAnnoyingLine.top = -1 or any other negative values, it was not touching the non-client area.

  • Solution
Posted

Here is new script. It is neccessary to catch WM_NCPAINT and do drawing there. Coordinates are issue again.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <WinAPITheme.au3>
#include "GUIDarkMode_v0.02mod.au3"
#include "ModernMenuRaw.au3"

#include <GuiMenu.au3>
#include <Array.au3>
#include <WinAPIDiag.au3>
#include <WinAPIConv.au3>
#include <WinAPIGdiDC.au3>

;~ DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "HWND", "DPI_AWARENESS_CONTEXT" - 4)

_SetMenuBkColor(0x202020)
_SetMenuIconBkColor(0x202020)
_SetMenuIconBkGrdColor(0x202020)
_SetMenuSelectBkColor(0x202020)
_SetMenuSelectRectColor(0x202020)
_SetMenuSelectTextColor(0xFFFFFF)
_SetMenuTextColor(0xFFFFFF)

Example()

Func Example()
    $hGUI = GUICreate("My GUI", 300, 200)

    ;Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI)
    GUICtrlCreateMenuItem("&Open", $idFileMenu)
    GUICtrlCreateMenuItem("&Save", $idFileMenu)
    GUICtrlCreateMenuItem("", $idFileMenu)

    Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
    GUICtrlCreateMenuItem("View", $idOptionsMenu)
    GUICtrlCreateMenuItem("", $idOptionsMenu)
    GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

    GUICtrlCreateMenuItem("", $idFileMenu)
    Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

    ;Local $idHelpMenu = GUICtrlCreateMenu("&?")
    Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI)
    Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

    Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

    Global $hSolidBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF00FF)

    GUIRegisterMsg($WM_NCPAINT, WM_NCPAINT)
;~  GUIRegisterMsg($WM_ERASEBKGND,WM_ERASEBKGND)
;~  GUIRegisterMsg($WM_PAINT,WM_PAINT)
;~  GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM2)
    GuiDarkmodeApply($hGUI)
    GUISetState(@SW_SHOW)
    ;_drawUAHMenuNCBottomLine($hGUI)


    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE
                _WinAPI_DeleteObject($hSolidBrush)
                ExitLoop

            Case $idAboutItem
                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_DRAWITEM2($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("WM_DRAWITEM" & @CRLF)
    ConsoleWrite("$hwnd=" & $hWnd & @CRLF)
;~  ConsoleWrite("$hDC=" & $wParam & @CRLF)
    WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam)
;~  _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
;~  _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
;~  _drawUAHMenuNCBottomLine($hWnd)
    Return True
EndFunc   ;==>WM_NCPAINT


Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("WM_PAINT" & @CRLF)
    ConsoleWrite("$hwnd=" & $hWnd & @CRLF)
;~  ConsoleWrite("$hDC=" & $wParam & @CRLF)
    _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hWnd)
    Return 0
EndFunc   ;==>WM_NCPAINT

Func WM_ERASEBKGND($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("WM_ERASEBKGND" & @CRLF)
    ConsoleWrite("$hwnd=" & $hWnd & @CRLF)
    ConsoleWrite("$hDC=" & $wParam & @CRLF)
    ;_WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hWnd)
    Return 1
EndFunc   ;==>WM_NCPAINT

Func WM_NCPAINT($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("$hwnd=" & $hWnd & @CRLF)
    ConsoleWrite("$wParam=" & $wParam & @CRLF)
    _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hWnd)
    Return 0
EndFunc   ;==>WM_NCPAINT

Func _drawUAHMenuNCBottomLine($hWnd)
    $aMenuBarInfo = _GUICtrlMenu_GetMenuBarInfo($hWnd, 0, 1)
    ;_ArrayDisplay($aMenuBarInfo)
    $rcClient = _WinAPI_GetClientRect($hWnd)
    ;_WinAPI_DisplayStruct($rcClient, $tagRECT, "rcClinet before")

    ;CHAT GPT
    Local $aCall = DllCall("user32.dll", "int", "MapWindowPoints", _
            "hwnd", $hWnd, _ ; hWndFrom
            "hwnd", 0, _     ; hWndTo
            "ptr", DllStructGetPtr($rcClient), _
            "uint", 2)       ;number of points - 2 for RECT structure

    If @error Then
        ;MsgBox($MB_ICONERROR, "Error", @error)
        Exit
    EndIf
    ;_WinAPI_DisplayStruct($rcClient, $tagRECT, "rcClinet after")

    $rcWindow = _WinAPI_GetWindowRect($hWnd)

    _WinAPI_OffsetRect($rcClient, -$rcWindow.left, -$rcWindow.top)

    $rcAnnoyingLine = DllStructCreate($tagRECT)
    $rcAnnoyingLine.left = $rcClient.left
    $rcAnnoyingLine.top = $rcClient.top
    $rcAnnoyingLine.right = $rcClient.right
    $rcAnnoyingLine.bottom = $rcClient.bottom
;~  _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT)

    $rcAnnoyingLine.bottom = $rcAnnoyingLine.top
    $rcAnnoyingLine.top = $rcAnnoyingLine.top - 1
;~  _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT,"annoying line")


;~  $rcAnnoyingLine.left = 0
;~  $rcAnnoyingLine.top = 0
;~  $rcAnnoyingLine.right = 100
;~  $rcAnnoyingLine.bottom = 200

    $hRgn=_WinAPI_CreateRectRgn(0,0,1000,500)

;~  $hDC = _WinAPI_GetDC($hWnd)
    $hDC=_WinAPI_GetDCEx($hWnd,$hRgn, BitOR($DCX_WINDOW,$DCX_INTERSECTRGN))
    If $hDC=0 Then
        ConsoleWrite("hDC=0" & @CRLF)
    EndIf
    _WinAPI_FillRect($hDC, $rcAnnoyingLine, $hSolidBrush)
    _WinAPI_ReleaseDC($hWnd, $hDC)

    ;_WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT, "annoying line")
EndFunc   ;==>_drawUAHMenuNCBottomLine

 

Posted
18 hours ago, ahmet said:

Here is new script. It is neccessary to catch WM_NCPAINT and do drawing there. Coordinates are issue again

 

I am trying a few different ways to do coordinates in a different way with success. Although it is tricky because each DPI scaling setting makes coordinates different. But I can definitely work with this.

I also added a function to paint the line anytime the app loses focus.

The best part about your solution is that it works when applying backdrop materials line Mica and Acrylic. The painted line also accepts the backdrop which is perfect. The solution with the child GUI could not do that.

I am going to mark your post as solution because it works well enough for my needs. If you ever feel the need to improve it, please feel free to update the code in the post marked as solution.

Thank you so much. :)

  • 2 months later...
Posted
On 7/19/2025 at 3:20 PM, argumentum said:

Edit: It certainly needs more code:

I added some resize code this morning that seems to work well.

There are still going to be some differences depending on what DPI scaling the user has set on their system. So I still have to factor DPI into the code at some point.

Example with resize:

Spoiler
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <WindowsConstants.au3>

#include <WinAPITheme.au3>
#include "include\GUIDarkMode_v0.02mod.au3"
#include "include\ModernMenuRaw.au3"

DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "HWND", "DPI_AWARENESS_CONTEXT" - 4)

Global $hGUI, $hGuiRect

_SetMenuBkColor(0x202020)
_SetMenuIconBkColor(0x202020)
_SetMenuIconBkGrdColor(0x202020)
_SetMenuSelectBkColor(0x202020)
_SetMenuSelectRectColor(0x202020)
_SetMenuSelectTextColor(0xFFFFFF)
_SetMenuTextColor(0xFFFFFF)

Example()

Func Example()
    $hGUI = GUICreate("My GUI", 300, 200, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP))
;~     $hGUI = GUICreate("My GUI", 300, 200)


    ;Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI)
    GUICtrlCreateMenuItem("&Open", $idFileMenu)
    GUICtrlCreateMenuItem("&Save", $idFileMenu)
    GUICtrlCreateMenuItem("", $idFileMenu)

    Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
    GUICtrlCreateMenuItem("View", $idOptionsMenu)
    GUICtrlCreateMenuItem("", $idOptionsMenu)
    GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

    GUICtrlCreateMenuItem("", $idFileMenu)
    Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

    ;Local $idHelpMenu = GUICtrlCreateMenu("&?")
    Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI)
    Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

    Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

    GuiDarkmodeApply($hGUI)

;~     GUISetState(@SW_SHOW)

    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~     $hGuiRect = GUICreate("", 300, 2, 0, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) ; for no resize
    $hGuiRect = GUICreate("", 300, 2, -6, -7, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) ;   for resize
;~     GUISetBkColor (0x202020) ; default
    GUISetBkColor (0xFF00FF) ; glow in the dark  =D
    GUISetState(@SW_SHOW, $hGuiRect)
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")

    GUISetState(@SW_SHOW, $hGUI)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE
                ExitLoop

            Case $idAboutItem
                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    ;#forceref $iMsg, $wParam, $lParam

    Local $aSize = WinGetClientSize($hGUI)
    Local $aGuiRectPos = WinGetPos($hGuiRect)
    WinMove($hGuiRect, "", $aGuiRectPos[0], $aGuiRectPos[1], $aSize[0], 2)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

 

 

Posted
On 8/2/2025 at 4:31 PM, ahmet said:

Here is new script. It is neccessary to catch WM_NCPAINT and do drawing there. Coordinates are issue again.

Thanks to @ioa747 for help with the WM_ACTIVATE function, part of this problem is solved. Coordinates are still going to be an issue for different DPI scaling settings which I will try to figure out later. But the issue with the painted line disappearing anytime the GUI loses and/or gains focus is fixed now.

For what it's worth, I had my own solution to this earlier but my method made the line flicker which was not great. This WM_ACTIVATE function seems to be much faster and I haven't noticed any flicker at all.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <WinAPITheme.au3>
#include "GUIDarkMode_v0.02mod.au3"
#include "ModernMenuRaw.au3"

#include <GuiMenu.au3>
#include <Array.au3>
#include <WinAPIDiag.au3>
#include <WinAPIConv.au3>
#include <WinAPIGdiDC.au3>

; WA_ACTIVATE constants
Global Const $WA_INACTIVE = 0x0000
Global Const $WA_ACTIVE = 0x0001
Global Const $WA_CLICKACTIVE = 0x0002
Global $hGUI

;~ DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "HWND", "DPI_AWARENESS_CONTEXT" - 4)

_SetMenuBkColor(0x202020)
_SetMenuIconBkColor(0x202020)
_SetMenuIconBkGrdColor(0x202020)
_SetMenuSelectBkColor(0x202020)
_SetMenuSelectRectColor(0x202020)
_SetMenuSelectTextColor(0xFFFFFF)
_SetMenuTextColor(0xFFFFFF)

Example()

Func Example()
    $hGUI = GUICreate("My GUI", 300, 200)

    ;Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI)
    GUICtrlCreateMenuItem("&Open", $idFileMenu)
    GUICtrlCreateMenuItem("&Save", $idFileMenu)
    GUICtrlCreateMenuItem("", $idFileMenu)

    Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
    GUICtrlCreateMenuItem("View", $idOptionsMenu)
    GUICtrlCreateMenuItem("", $idOptionsMenu)
    GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

    GUICtrlCreateMenuItem("", $idFileMenu)
    Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

    ;Local $idHelpMenu = GUICtrlCreateMenu("&?")
    Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI)
    Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

    Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

    Global $hSolidBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF00FF)

    GUIRegisterMsg($WM_NCPAINT, "WM_NCPAINT")
    GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE_Handler")
;~  GUIRegisterMsg($WM_ERASEBKGND,WM_ERASEBKGND)
;~  GUIRegisterMsg($WM_PAINT,WM_PAINT)
;~  GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM2)
    GuiDarkmodeApply($hGUI)
    GUISetState(@SW_SHOW)
    ;_drawUAHMenuNCBottomLine($hGUI)


    Local $idMsg
    ; Loop until the user exits.
    While 1
        ;Sleep(20)
        ;If Not WinActive($hGUI) Then _drawUAHMenuNCBottomLine($hGUI)
        ;_drawUAHMenuNCBottomLine($hGUI)
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE
                _WinAPI_DeleteObject($hSolidBrush)
                ExitLoop

            Case $idAboutItem
                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_DRAWITEM2($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("WM_DRAWITEM" & @CRLF)
    ConsoleWrite("$hwnd=" & $hWnd & @CRLF)
;~  ConsoleWrite("$hDC=" & $wParam & @CRLF)
    WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam)
;~  _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
;~  _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
;~  _drawUAHMenuNCBottomLine($hWnd)
    Return True
EndFunc   ;==>WM_DRAWITEM2

Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("WM_PAINT" & @CRLF)
    ConsoleWrite("$hwnd=" & $hWnd & @CRLF)
;~  ConsoleWrite("$hDC=" & $wParam & @CRLF)
    _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hWnd)
    Return 0
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("WM_ERASEBKGND" & @CRLF)
    ConsoleWrite("$hwnd=" & $hWnd & @CRLF)
    ConsoleWrite("$hDC=" & $wParam & @CRLF)
    ;_WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hWnd)
    Return 1
EndFunc   ;==>WM_ERASEBKGND

Func WM_NCPAINT($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("$hwnd=" & $hWnd & @CRLF)
    ConsoleWrite("$wParam=" & $wParam & @CRLF)
    _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hWnd)
    Return 0
EndFunc   ;==>WM_NCPAINT

Func _drawUAHMenuNCBottomLine($hWnd)
    $aMenuBarInfo = _GUICtrlMenu_GetMenuBarInfo($hWnd, 0, 1)
    ;_ArrayDisplay($aMenuBarInfo)
    $rcClient = _WinAPI_GetClientRect($hWnd)
    ;_WinAPI_DisplayStruct($rcClient, $tagRECT, "rcClinet before")

    ;CHAT GPT
    Local $aCall = DllCall("user32.dll", "int", "MapWindowPoints", _
            "hwnd", $hWnd, _ ; hWndFrom
            "hwnd", 0, _     ; hWndTo
            "ptr", DllStructGetPtr($rcClient), _
            "uint", 2)       ;number of points - 2 for RECT structure

    If @error Then
        ;MsgBox($MB_ICONERROR, "Error", @error)
        Exit
    EndIf
    ;_WinAPI_DisplayStruct($rcClient, $tagRECT, "rcClinet after")

    $rcWindow = _WinAPI_GetWindowRect($hWnd)

    _WinAPI_OffsetRect($rcClient, -$rcWindow.left, -$rcWindow.top)

    $rcAnnoyingLine = DllStructCreate($tagRECT)
    $rcAnnoyingLine.left = $rcClient.left
    $rcAnnoyingLine.top = $rcClient.top
    $rcAnnoyingLine.right = $rcClient.right
    $rcAnnoyingLine.bottom = $rcClient.bottom
;~  _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT)

    $rcAnnoyingLine.bottom = $rcAnnoyingLine.top
    $rcAnnoyingLine.top = $rcAnnoyingLine.top - 1
;~  _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT,"annoying line")


;~  $rcAnnoyingLine.left = 0
;~  $rcAnnoyingLine.top = 0
;~  $rcAnnoyingLine.right = 100
;~  $rcAnnoyingLine.bottom = 200

    $hRgn=_WinAPI_CreateRectRgn(0,0,1000,500)

;~  $hDC = _WinAPI_GetDC($hWnd)
    $hDC=_WinAPI_GetDCEx($hWnd,$hRgn, BitOR($DCX_WINDOW,$DCX_INTERSECTRGN))
    If $hDC=0 Then
        ConsoleWrite("hDC=0" & @CRLF)
    EndIf
    _WinAPI_FillRect($hDC, $rcAnnoyingLine, $hSolidBrush)
    _WinAPI_ReleaseDC($hWnd, $hDC)

    ;_WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT, "annoying line")
EndFunc   ;==>_drawUAHMenuNCBottomLine

; ioa747
Func WM_ACTIVATE_Handler($hWnd, $MsgID, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hGUI)
    #cs
    #forceref $MsgID, $wParam, $lParam

    Switch $WParam
        Case $WA_INACTIVE ; 0x0000
            _drawUAHMenuNCBottomLine($hGUI)

        Case $WA_ACTIVE ; 0x0001
            _drawUAHMenuNCBottomLine($hGUI)

        Case $WA_CLICKACTIVE ; 0x0002
            _drawUAHMenuNCBottomLine($hGUI)

        Case Else
            _drawUAHMenuNCBottomLine($hGUI)
    EndSwitch
    #ce

    Return $GUI_RUNDEFMSG
EndFunc

 

Posted

@argumentum @ioa747

I believe that I have the WM_NCPAINT / _WinAPI_FillRect solution from @ahmet working now to remove the line at all DPI scaling that I could test (no scaling, 100%, 125%, 150% and 175%) and with a fully resizable GUI.

First of all, I apologize for tagging you are directly. But if you have a moment, I am hoping that you can test this to see if the line is gone for you under various DPI scaling settings. I figure the more different computer systems that confirm it, the better.

We are just checking to ensure that there is no white line. You can resize the GUI, change DPI, etc. It is possible that there may be a slight flicker of the white line sometimes but I am not worried too much about that as long as that white line disappears.

You only need the ModernMenuRaw.au3 UDF from the first post. I replaced the GUIDarkMode_v0.02mod.au3 UDF with the Dark Mode functions that @UEZ posted just recently in the Snippets section to keep things smaller and simpler.

Thank you, by the way. I really appreciate your time as always. :)

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include <WinAPITheme.au3>
;#include "GUIDarkMode_v0.02mod.au3"
#include "ModernMenuRaw.au3"

#include <WinAPIGdi.au3>
#include <WinAPISysWin.au3>

#include <GuiMenu.au3>
#include <Array.au3>
#include <WinAPIDiag.au3>
#include <WinAPIConv.au3>
#include <WinAPIGdiDC.au3>

; WA_ACTIVATE constants
Global Const $WA_INACTIVE = 0x0000
Global Const $WA_ACTIVE = 0x0001
Global Const $WA_CLICKACTIVE = 0x0002
Global $hGUI

;Coded by UEZ build 2025-10-10
;IMMERSIVE_HC_CACHE_MODE
Enum $IHCM_USE_CACHED_VALUE, $IHCM_REFRESH
Enum $Default, $AllowDark, $ForceDark, $ForceLight, $Max ;$iPreferredAppMode
;~ Enum $DWMWA_USE_IMMERSIVE_DARK_MODE = (@OSBuild <= 18985) ? 19 : 20

DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "HWND", "DPI_AWARENESS_CONTEXT" - 4)

_SetMenuBkColor(0x000000)
_SetMenuIconBkColor(0x000000)
_SetMenuIconBkGrdColor(0x000000)
_SetMenuSelectBkColor(0x202020)
_SetMenuSelectRectColor(0x202020)
_SetMenuSelectTextColor(0xFFFFFF)
_SetMenuTextColor(0xFFFFFF)

Example()

Func Example()
    $hGUI = GUICreate("My GUI", 600, 400, -1, -1,  $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX)
    GUISetBkColor(0x000000)
    ;Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI)
    GUICtrlCreateMenuItem("&Open", $idFileMenu)
    GUICtrlCreateMenuItem("&Save", $idFileMenu)
    GUICtrlCreateMenuItem("", $idFileMenu)

    Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
    GUICtrlCreateMenuItem("View", $idOptionsMenu)
    GUICtrlCreateMenuItem("", $idOptionsMenu)
    GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

    GUICtrlCreateMenuItem("", $idFileMenu)
    Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

    ;Local $idHelpMenu = GUICtrlCreateMenu("&?")
    Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI)
    Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

    Global $hSolidBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0x000000)

    GUIRegisterMsg($WM_NCPAINT, "WM_NCPAINT")
    GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE_Handler")
    ;GuiDarkmodeApply($hGUI)
    _WinAPI_AllowDarkModeForApp(True)
    _WinAPI_RefreshImmersiveColorPolicyState()
    _WinAPI_FlushMenuThemes()
    _WinAPI_DwmSetWindowAttribute__($hGUI, 20, 1)
    ;_WinAPI_DwmSetWindowAttribute__($hGUI, 38, 4)
    _WinAPI_DwmExtendFrameIntoClientArea($hGUI, _WinAPI_CreateMargins(-1, -1, -1, -1))
    GUISetState(@SW_SHOW)


    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idExitItem, $GUI_EVENT_CLOSE
                _WinAPI_DeleteObject($hSolidBrush)
                ExitLoop

            Case $idAboutItem
                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NCPAINT($hWnd, $iMsg, $wParam, $lParam)
    _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hWnd)
    Return 0
EndFunc   ;==>WM_NCPAINT

Func _drawUAHMenuNCBottomLine($hWnd)
    $aMenuBarInfo = _GUICtrlMenu_GetMenuBarInfo($hWnd, 0, 1)
    ;_ArrayDisplay($aMenuBarInfo)
    $rcClient = _WinAPI_GetClientRect($hWnd)
    ;_WinAPI_DisplayStruct($rcClient, $tagRECT, "rcClinet before")

    ;CHAT GPT
    Local $aCall = DllCall("user32.dll", "int", "MapWindowPoints", _
            "hwnd", $hWnd, _ ; hWndFrom
            "hwnd", 0, _     ; hWndTo
            "ptr", DllStructGetPtr($rcClient), _
            "uint", 2)       ;number of points - 2 for RECT structure

    If @error Then
        ;MsgBox($MB_ICONERROR, "Error", @error)
        Exit
    EndIf
    ;_WinAPI_DisplayStruct($rcClient, $tagRECT, "rcClinet after")

    $rcWindow = _WinAPI_GetWindowRect($hWnd)

    _WinAPI_OffsetRect($rcClient, -$rcWindow.left, -$rcWindow.top)

    $rcAnnoyingLine = DllStructCreate($tagRECT)
    $rcAnnoyingLine.left = $rcClient.left
    $rcAnnoyingLine.top = $rcClient.top
    $rcAnnoyingLine.right = $rcClient.right
    $rcAnnoyingLine.bottom = $rcClient.bottom
;~  _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT)

    $rcAnnoyingLine.bottom = $rcAnnoyingLine.top
    $rcAnnoyingLine.top = $rcAnnoyingLine.top - 1
;~  _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT,"annoying line")


;~  $rcAnnoyingLine.left = 0
;~  $rcAnnoyingLine.top = 0
;~  $rcAnnoyingLine.right = 100
;~  $rcAnnoyingLine.bottom = 200

    $hRgn=_WinAPI_CreateRectRgn(0,0,8000,8000)

;~  $hDC = _WinAPI_GetDC($hWnd)
    $hDC=_WinAPI_GetDCEx($hWnd,$hRgn, BitOR($DCX_WINDOW,$DCX_INTERSECTRGN))
    _WinAPI_FillRect($hDC, $rcAnnoyingLine, $hSolidBrush)
    _WinAPI_ReleaseDC($hWnd, $hDC)

    ;_WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT, "annoying line")
EndFunc   ;==>_drawUAHMenuNCBottomLine

; ioa747
Func WM_ACTIVATE_Handler($hWnd, $MsgID, $wParam, $lParam)
    _drawUAHMenuNCBottomLine($hGUI)

    Return $GUI_RUNDEFMSG
EndFunc

; UEZ
Func _WinAPI_ShouldAppsUseDarkMode()
    Local $aResult = DllCall("UxTheme.dll", "bool", 132)
    If @error Then Return SetError(1, 0, False)
    Return ($aResult[0] <> 0)
EndFunc   ;==>_WinAPI_ShouldAppsUseDarkMode

Func _WinAPI_AllowDarkModeForWindow($hWND, $bAllow = True)
    Local $aResult = DllCall("UxTheme.dll", "bool", 133, "hwnd", $hWND, "bool", $bAllow)
    If @error Then Return SetError(1, 0, False)
    Return ($aResult[0] <> 0)
EndFunc   ;==>_WinAPI_AllowDarkModeForWindow

Func _WinAPI_AllowDarkModeForApp($bAllow = True) ;Windows 10 Build 17763
    Return _WinAPI_SetPreferredAppMode($bAllow ? 1 : 0) ; 1 = AllowDark, 0 = Default
EndFunc   ;==>_WinAPI_AllowDarkModeForApp

Func _WinAPI_SetPreferredAppMode($iPreferredAppMode) ;Windows 10 Build 18362+
    Local $aResult = DllCall("UxTheme.dll", "long", 135, "long", $iPreferredAppMode)
    If @error Then Return SetError(1, 0, False)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_SetPreferredAppMode

Func _WinAPI_FlushMenuThemes()
    Local $aResult = DllCall("UxTheme.dll", "none", 136)
    If @error Then Return SetError(1, 0, False)
    Return True
EndFunc   ;==>_WinAPI_FlushMenuThemes

Func _WinAPI_RefreshImmersiveColorPolicyState()
    Local $aResult = DllCall("UxTheme.dll", "none", 104)
    If @error Then Return SetError(1, 0, False)
    Return True
EndFunc   ;==>_WinAPI_RefreshImmersiveColorPolicyState

Func _WinAPI_IsDarkModeAllowedForWindow($hWND)
    Local $aResult = DllCall("UxTheme.dll", "bool", 137, "hwnd", $hWND)
    If @error Then Return SetError(1, 0, False)
    Return ($aResult[0] <> 0)
EndFunc   ;==>_WinAPI_IsDarkModeAllowedForWindow

Func _WinAPI_GetIsImmersiveColorUsingHighContrast($iIMMERSIVE_HC_CACHE_MODE)
    Local $aResult = DllCall("UxTheme.dll", "bool", 106, "long", $iIMMERSIVE_HC_CACHE_MODE)
    If @error Then Return SetError(1, 0, False)
    Return ($aResult[0] <> 0)
EndFunc   ;==>_WinAPI_GetIsImmersiveColorUsingHighContrast

Func _WinAPI_OpenNcThemeData($hWND, $tClassList)
    Local $aResult = DllCall("UxTheme.dll", "hwnd", 49, "hwnd", $hWND, "struct*", $tClassList)
    If @error Then Return SetError(1, 0, False)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_OpenNcThemeData

Func _WinAPI_ShouldSystemUseDarkMode()
    Local $aResult = DllCall("UxTheme.dll", "bool", 138)
    If @error Then Return SetError(1, 0, False)
    Return ($aResult[0] <> 0)
EndFunc   ;==>_WinAPI_ShouldSystemUseDarkMode

Func _WinAPI_IsDarkModeAllowedForApp()
    Local $aResult = DllCall("UxTheme.dll", "bool", 139)
    If @error Then Return SetError(1, 0, False)
    Return ($aResult[0] <> 0)
EndFunc   ;==>_WinAPI_IsDarkModeAllowedForApp

Func _WinAPI_DwmSetWindowAttribute__($hwnd, $attribute = 34, $value = 0x00FF00, $valLen = 4)
    Local $aCall = DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $attribute, 'dword*', $value, 'dword', $valLen)
    If @error Then Return SetError(@error, @extended, 0)
    If $aCall[0] Then Return SetError(10, $aCall[0], 0)
    Return 1
EndFunc   ;==>_WinAPI_DwmSetWindowAttribute__

 

Posted

AutoIt Version..: 3.3.16.1   Win10 22H2 

with the window everything is fine, there is no white line, no flickering


⚠  - 0 error(s), 7 warning(s) 
 warning: $NIF_ICON: possibly used before declaration
warning: $NIF_MESSAGE: possibly used before declaration.
warning: $NIM_ADD: possibly used before declaration.
warning: $NIM_MODIFY: possibly used before declaration.
warning: $NIF_TIP: possibly used before declaration.
warning: $NIF_INFO: possibly used before declaration.

I had to add
#include <APIShellExConstants.au3> ;  <<<
in ModernMenuRaw.au3

and all is well  :thumbsup:

I know that I know nothing

Posted
1 hour ago, ioa747 said:

AutoIt Version..: 3.3.16.1   Win10 22H2 

with the window everything is fine, there is no white line, no flickering

That's great news. I didn't have a Win10 VM handy so I hadn't tested there. Thanks for confirming.

 

1 hour ago, ioa747 said:

I had to add
#include <APIShellExConstants.au3> ;  <<<
in ModernMenuRaw.au3

Thanks for the heads up on this simple fix as well. I don't think that ModernMenuRaw UDF had been updated in about a decade, so I think a lot has been changed in AutoIt since that time. It's nice that this was as simple as adding one include file.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...