WildByDesign Posted Thursday at 12:19 PM Posted Thursday at 12:19 PM Problem: 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: expandcollapse popup#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
argumentum Posted Thursday at 04:56 PM Posted Thursday at 04:56 PM 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 ?? ; =============================================================================================================================== WildByDesign 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
WildByDesign Posted Thursday at 05:57 PM Author Posted Thursday at 05:57 PM 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. argumentum 1
ahmet Posted Thursday at 06:29 PM Posted Thursday at 06:29 PM Here is initial version. Coordinates are wrong. I need to do other things now. expandcollapse popup#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 argumentum and WildByDesign 2
WildByDesign Posted Thursday at 11:05 PM Author Posted Thursday at 11:05 PM 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.
ahmet Posted Friday at 06:42 PM Posted Friday at 06:42 PM That line needs to be redrawn even on restore from minimize state. Once you find out when an update is neccessary you draw the line again. WildByDesign 1
WildByDesign Posted Saturday at 03:01 PM Author Posted Saturday at 03:01 PM 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.
ioa747 Posted Saturday at 05:37 PM Posted Saturday at 05:37 PM expandcollapse popup#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 argumentum and WildByDesign 1 1 I know that I know nothing
argumentum Posted Saturday at 07:20 PM Posted Saturday at 07:20 PM (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 expandcollapse popup#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 Saturday at 07:40 PM by argumentum more WildByDesign and ioa747 2 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
WildByDesign Posted Saturday at 09:11 PM Author Posted Saturday at 09:11 PM 3 hours ago, ioa747 said: 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. ioa747 and argumentum 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now