WildByDesign Posted yesterday at 12:19 PM Posted yesterday 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 21 hours ago Posted 21 hours ago 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 20 hours ago Author Posted 20 hours ago 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 19 hours ago Posted 19 hours ago 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 WildByDesign and argumentum 2
WildByDesign Posted 15 hours ago Author Posted 15 hours ago 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.
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