Jump to content

UEZ

MVPs
  • Posts

    7,467
  • Joined

  • Last visited

  • Days Won

    94

UEZ last won the day on February 27

UEZ had the most liked content!

About UEZ

  • Birthday 12/03/2007

Profile Information

  • Member Title
    Never say never
  • Location
    Germany
  • Interests
    Computer, watching movies, football (soccer), being lazy :-)

Recent Profile Visitors

11,056 profile views

UEZ's Achievements

  1. To handle all headers generically you need something like my _SubclassProc() and NM_CUSTOMDRAW notification to manage ListView headers. Since $hWndFrom contains the actual handle of the sending control, the StringLower(_WinAPI_GetClassName($hWndFrom)) = "sysheader32" check automatically matches all ListView headers regardless of how many ListViews you have. If you need per-ListView differentiation, you can check the header's parent: Case "sysheader32" ; Optionally identify which ListView this header belongs to: Local $hParentListView = _WinAPI_GetParent($hFrom) ; Apply different colors per ListView if needed ; Otherwise the generic class name check handles all of them uniformly I hope it helps you.
  2. You can overpaint the size grips in edit, listvew and treeview. I used in my example $WM_PAINT in _SubclassProc function: ... Case $WM_PAINT Local $sClass = StringLower(_WinAPI_GetClassName($hWnd)) If $sClass = "syslistview32" Or $sClass = "systreeview32" Or $sClass = "edit" Then ; hide Sizegrip boxes Local $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) ; Overpaint sizegrip boxes if visible Local $iWinStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) If BitAND($iWinStyle, $WS_HSCROLL) And BitAND($iWinStyle, $WS_VSCROLL) Then Local $hDC = _WinAPI_GetWindowDC($hWnd) ; GetWindowDC statt GetDC! Local $tWnd = _WinAPI_GetWindowRect($hWnd) Local $tClient = _WinAPI_GetClientRect($hWnd) Local $iScrollW = _WinAPI_GetSystemMetrics($SM_CXVSCROLL) Local $iScrollH = _WinAPI_GetSystemMetrics($SM_CYHSCROLL) ; convert client-area to Window coordinates Local $tPt = DllStructCreate($tagPOINT) $tPt.X = $tClient.right $tPt.Y = $tClient.bottom DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hWnd, "struct*", $tPt) ; direct relativ coordinates Local $tCorner = DllStructCreate($tagRECT), $delta = (_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) And $WS_EX_CLIENTEDGE ? 4 : 1) $tCorner.left = $tClient.right + $delta $tCorner.top = $tClient.bottom + $delta $tCorner.right = $tCorner.left + $iScrollW $tCorner.bottom = $tCorner.top + $iScrollH Local $hBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_TITLE_DARK)) _WinAPI_FillRect($hDC, $tCorner, $hBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hWnd, $hDC) EndIf Return $iRet Else Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndIf ... I didn't test it for DPI <> 1 aka 96 if $tCorner is properly calculated.
  3. It seems to work also for child windows: ;Coded by UEZ #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> AutoItSetOption("GuiOnEventMode", 1) Global Const $DWMWA_REDIRECTIONBITMAP_ALPHA = 39 _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Torus.png") Global $iW = _GDIPlus_ImageGetWidth($hImage) Global $iH = _GDIPlus_ImageGetHeight($hImage) Global $hGfx = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, $GDIP_TEXTRENDERINGHINTANTIALIAS) Global $hBrush = _GDIPlus_BrushCreateSolid(0xA0FFFFFF) Global $hFormat = _GDIPlus_StringFormatCreate() Global $hFamily = _GDIPlus_FontFamilyCreate("Arial") Global $hFont = _GDIPlus_FontCreate($hFamily, 30) Global $tLayout = _GDIPlus_RectFCreate(0, $iH - 100, $iW, 32) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_GraphicsDrawStringEx($hGfx, "Hello world", $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGfx) Global $hGUI = GUICreate("Parent", 200, 150, 300, 200) Global $hChild = GUICreate("Child", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW, $hGUI) Global $aCall = DllCall("dwmapi.dll", "long", "DwmSetWindowAttribute", _ "hwnd", $hChild, _ "dword", $DWMWA_REDIRECTIONBITMAP_ALPHA, _ "bool*", True, _ "dword", 4) GUIRegisterMsg($WM_PAINT, "_WM_PAINT") GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hChild) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") Do Until Not Sleep(100) Func _WM_PAINT($hWnd, $iMsg, $wParam, $lParam) If $hWnd <> $hChild Then Return $GUI_RUNDEFMSG Local $tPS = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPS) Local $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC) _GDIPlus_GraphicsSetCompositingMode($hGfx, $GDIP_COMPOSITINGMODESOURCECOPY) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage, 0, 0, $iW, $iH) _GDIPlus_GraphicsDispose($hGfx) _WinAPI_EndPaint($hWnd, $tPS) Return 0 EndFunc Func _Quit() GUIRegisterMsg($WM_PAINT, "") _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() GUIDelete($hGUI) GUIDelete($hChild) Exit EndFunc
  4. Seem that it can display GUI with 32bit image with transparency without using WS_EX_LAYERED: ;Coded by UEZ #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> AutoItSetOption("GuiOnEventMode", 1) Global Const $DWMWA_REDIRECTIONBITMAP_ALPHA = 39 _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Torus.png") Global $iW = _GDIPlus_ImageGetWidth($hImage) Global $iH = _GDIPlus_ImageGetHeight($hImage) Global $hGUI = GUICreate(" DWMWA_REDIRECTIONBITMAP_ALPHA Test", $iW, $iH, -1, -1, $WS_POPUP) Global $aCall = DllCall("dwmapi.dll", "long", "DwmSetWindowAttribute", _ "hwnd", $hGUI, _ "dword", $DWMWA_REDIRECTIONBITMAP_ALPHA, _ "bool*", True, _ "dword", 4) GUISetState() GUIRegisterMsg($WM_PAINT, "_WM_PAINT") GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") _WinAPI_InvalidateRect($hGUI, 0, True) Do Until Not Sleep(100) Func _WM_PAINT($hWnd, $iMsg, $wParam, $lParam) If $hWnd <> $hGUI Then Return $GUI_RUNDEFMSG Local $tPS = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPS) Local $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC) _GDIPlus_GraphicsSetCompositingMode($hGfx, $GDIP_COMPOSITINGMODESOURCECOPY) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage, 0, 0, $iW, $iH) _GDIPlus_GraphicsDispose($hGfx) _WinAPI_EndPaint($hWnd, $tPS) Return 0 EndFunc Func _Quit() GUIRegisterMsg($WM_PAINT, "") _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit EndFunc
  5. Looks good now - no x64 crash and DPI seems to work, too.
  6. Can somebody test if this works? SciTeTabHook (I create two small DLLs (x86/x64) to hook SciTE which is apparently not possible using Autoit due to Memory Barrier / Local Address limits) It should work with SciTE x86/x64. It is important to run AutoIt on the same architecture as SciTE! Tray icon can be used to close Autoit script. Thx. @ioa747 sorry for hijacking your thread, but this fits in well here.
  7. I'm using the x64 version of SciTE -> Version 5.5.8 Scintilla:5.5.8 Lexilla:5.4.6 Jan 12 2026 12:26:07 Autoit: 3.3.18.0 Win: 24H2
  8. I'm getting a crash AutoIt3 ended. rc:-1073740940 when starting it as x64 execution. x86 runs properly. I must add a Sleep(10) to the _ManageOverlay() function. I don't know why but the Tab blue rectangle was topmost painted althouth SciTE was in the background. Just wondering why SciTE doesn't have this feature already onboard...
  9. Many new filters added and made some speed improvement. See post#1 for details and image gallery.
  10. I did some modifications -> It gets more and more complicated and I'm loosing the overview of all stuff.... Very good - seems to be more stable and the behaviour is same as MsgBox() - thanks.
  11. Just add #include <WinAPIGdi.au3> and it should do the job.
  12. Very good. You may add an entry to the tray menu to reset the position of the clock for the case it is out of the screen on next startup.
  13. Thanks for the hint @MattyD - it fixed the focus crash. This seems to work - please test: ;Coded by UEZ build 2026-03-19 beta #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so #Au3Stripper_Ignore_Funcs=_TimerProc #include <ButtonConstants.au3> #include <Timers.au3> #include <WinAPIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> #include <WinAPISysWin.au3> #include <WinAPITheme.au3> #include <WindowsConstants.au3> Global Const $BS_PUSHBUTTON = 0x000000 Global Const $COLOR_BG_DARK = 0x202020 Global Const $COLOR_TEXT_LIGHT = 0xF0F0F0 Global Const $COLOR_HOTTRACK_MENU = 0x3A3A3A Global Const $COLOR_TITLE_DARK = 0x181818 Const $HCBT_CREATEWND = 3, $HCBT_DESTROYWND = 4, $HCBT_ACTIVATE = 5, $g_iFlagDefault = BitOR($MB_TOPMOST, $MB_ICONINFORMATION) Global $g_hMsgBoxHook, $g_hSubMsgBox, $g_idTImer, $g_sBtn1_Txt = "Close", $g_sBtn2_Txt, $g_sBtn3_Txt Global $g_Timeout = 0, $g_hMsgBoxOldProc, $g_hMsgBoxBrush, $g_hMsgBoxBtn = 0, $g_bMsgBoxClosing = False, $g_bNCLButtonDown = False, $g_bMsgBoxInitialized = False Global $g_hMsgBoxSubProc = DllCallbackRegister("_MsgBoxProc", "lresult", "hwnd;uint;wparam;lparam") Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdlgitemtextw Local $aRet = DllCall("user32.dll", "int", "SetDlgItemText", "hwnd", $hDlg, "int", $nIDDlgItem, "str", $lpString) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText Func _WinAPI_FindWindowEx($hParent, $sClass, $sTitle = "", $hAfter = 0) Local $ret = DllCall("user32.dll", "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx Func _ColorToCOLORREF($iColor) ;RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF Func _MsgBoxProc($hWnd, $iMsg, $wParam, $lParam) If Not $g_hMsgBoxOldProc Then Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) If $g_Timeout < 0 Or Not _WinAPI_IsWindow($hWnd) Then Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_CTLCOLORSTATIC, $WM_CTLCOLORDLG, $WM_CTLCOLORBTN If Not $g_hMsgBoxBrush Then Return _WinAPI_CallWindowProc($g_hMsgBoxOldProc, $hWnd, $iMsg, $wParam, $lParam) _WinAPI_SetTextColor($wParam, _ColorToCOLORREF($COLOR_TEXT_LIGHT)) _WinAPI_SetBkColor($wParam, _ColorToCOLORREF($COLOR_BG_DARK)) Return $g_hMsgBoxBrush Case $WM_ERASEBKGND If Not $g_hMsgBoxBrush Then Return _WinAPI_CallWindowProc($g_hMsgBoxOldProc, $hWnd, $iMsg, $wParam, $lParam) Local $tRECT = _WinAPI_GetClientRect($hWnd) _WinAPI_FillRect($wParam, $tRECT, $g_hMsgBoxBrush) Return 1 Case $WM_PAINT Local $iRet = _WinAPI_CallWindowProc($g_hMsgBoxOldProc, $hWnd, $iMsg, $wParam, $lParam) Local $hDC = _WinAPI_GetDC($hWnd) Local $tRECT = _WinAPI_GetClientRect($hWnd) If $g_hMsgBoxBtn Then Local $tBtnRect = _WinAPI_GetWindowRect($g_hMsgBoxBtn) Local $tPoint = DllStructCreate($tagPOINT) $tPoint.x = $tBtnRect.left $tPoint.y = $tBtnRect.top _WinAPI_ScreenToClient($hWnd, $tPoint) $tRECT.top = $tPoint.y - 10 EndIf Local $hBrushFooter = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_HOTTRACK_MENU)) _WinAPI_FillRect($hDC, $tRECT, $hBrushFooter) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_DeleteObject($hBrushFooter) Return $iRet Case $WM_COMMAND If $g_bNCLButtonDown And (BitAND($wParam, 0xFFFF) = $IDOK) Then $g_bMsgBoxClosing = True Return 0 EndIf Return _WinAPI_CallWindowProc($g_hMsgBoxOldProc, $hWnd, $iMsg, $wParam, $lParam) Case $WM_NCLBUTTONDOWN $g_bNCLButtonDown = True Local $iRet = _WinAPI_CallWindowProc($g_hMsgBoxOldProc, $hWnd, $iMsg, $wParam, $lParam) $g_bNCLButtonDown = False If $g_bMsgBoxClosing Then _WinAPI_PostMessage($hWnd, $WM_COMMAND, $IDOK + 1, 0) EndIf Return $iRet Case $WM_CLOSE If $g_idTImer Then _Timer_KillTimer($hWnd, $g_idTImer) $g_idTImer = 0 EndIf Case $WM_NCDESTROY _WinAPI_SetWindowLong($hWnd, $GWL_WNDPROC, $g_hMsgBoxOldProc) Local $hBrush = $g_hMsgBoxBrush $g_hMsgBoxBrush = 0 If $hBrush Then _WinAPI_DeleteObject($hBrush) EndIf Case $WM_DESTROY If $g_idTImer Then _Timer_KillTimer($hWnd, $g_idTImer) $g_idTImer = 0 EndIf Return _WinAPI_CallWindowProc($g_hMsgBoxOldProc, $hWnd, $iMsg, $wParam, $lParam) EndSwitch Return _WinAPI_CallWindowProc($g_hMsgBoxOldProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc Func _TimerProc($hWnd, $iMsg, $wParam, $lParam) If Not _WinAPI_IsWindow($hWnd) Or $g_bMsgBoxClosing Then Return If $g_Timeout <= 1 Then $g_bMsgBoxClosing = True _Timer_KillTimer($hWnd, $g_idTImer) $g_idTImer = 0 If Not $g_bNCLButtonDown Then _WinAPI_PostMessage($hWnd, $WM_COMMAND, $IDOK + 1, 0) Return EndIf $g_Timeout -= 1 _WinAPI_SetDlgItemText($hWnd, $IDOK + 1, $g_sBtn1_Txt & " [" & $g_Timeout & "]") EndFunc Func _CBTHookProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam) Local Const $hHWND = HWnd($wParam) Switch $nCode Case $HCBT_ACTIVATE If _WinAPI_GetClassName($hHWND) = "#32770" Then If $g_bMsgBoxInitialized Then Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam) $g_bMsgBoxInitialized = True If $g_Timeout Then $g_idTImer = _Timer_SetTimer($hHWND, 1000, "_TimerProc") _WinAPI_SetDlgItemText($wParam, $IDOK, $g_Timeout ? $g_sBtn1_Txt & " [" & $g_Timeout & "]" : $g_sBtn1_Txt) ; Title bar dark _WinAPI_DwmSetWindowAttribute($hHWND, $DWMWA_USE_IMMERSIVE_DARK_MODE, True) ; Dark title + caption colors _WinAPI_DwmSetWindowAttribute($hHWND, 20, True) ; immersive dark ; optional: remove bright border _WinAPI_DwmSetWindowAttribute($hHWND, $DWMWA_BORDER_COLOR, _ColorToCOLORREF(0x303030)) ; caption color _WinAPI_DwmSetWindowAttribute($hHWND, $DWMWA_CAPTION_COLOR, _ColorToCOLORREF($COLOR_TITLE_DARK)) ; caption text _WinAPI_DwmSetWindowAttribute($hHWND, $DWMWA_TEXT_COLOR, _ColorToCOLORREF($COLOR_TEXT_LIGHT)) Local $i, $iStyle For $i = 0 To 7 $hBtn = _WinAPI_GetDlgItem($hHWND, $i) If $hBtn Then $g_hMsgBoxBtn = $hBtn _WinAPI_SetWindowTheme($hBtn, "DarkMode_Explorer", 0) _WinAPI_AllowDarkModeForWindow($hBtn, True) EndIf Next ; Dark theme for static controls (text + icon) Local $hStatic = _WinAPI_FindWindowEx($hHWND, "Static") While $hStatic _WinAPI_AllowDarkModeForWindow($hStatic, True) $hStatic = _WinAPI_FindWindowEx($hHWND, "Static", "", $hStatic) WEnd $g_hMsgBoxBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BG_DARK)) $g_hMsgBoxOldProc = _WinAPI_SetWindowLong($hHWND, $GWL_WNDPROC, DllCallbackGetPtr($g_hMsgBoxSubProc)) _WinAPI_RedrawWindow($hHWND, 0, 0, BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_ALLCHILDREN)) EndIf Case $HCBT_DESTROYWND If _WinAPI_GetClassName($hHWND) = "#32770" Then $g_bMsgBoxInitialized = False _Timer_KillTimer($hHWND, $g_idTImer) EndIf EndSwitch Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam) EndFunc ;==>_CBTHookProc Func MsgBoxEx($sText, $sTitle = Default, $iTimeout = 0, $iFlag = Default, $sBtn_Txt = Default, $hParentHWND = "") $g_hMsgBoxBtn = 0 $g_bMsgBoxClosing = False $g_bNCLButtonDown = False $g_bMsgBoxInitialized = False If $sBtn_Txt <> Default Then $g_sBtn1_Txt = $sBtn_Txt If $iFlag = Default Then $iFlag = $g_iFlagDefault $g_Timeout = $iTimeout Local $hMsgProc = DllCallbackRegister("_CBTHookProc", "int", "uint;wparam;lparam") Local Const $hThreadID = _WinAPI_GetCurrentThreadId() $g_hMsgBoxHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hMsgProc), Null, $hThreadID) If $sTitle = Default Then $sTitle = "Information" Local Const $iReturn = MsgBox($iFlag, $sTitle, $sText, 0, $hParentHWND) If $g_hMsgBoxHook Then _WinAPI_UnhookWindowsHookEx($g_hMsgBoxHook) DllCallbackFree($hMsgProc) Return $iReturn EndFunc ;==>MsgBoxEx 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 ConsoleWrite(MsgBoxEx("This is a test", "Information", 5) & @CRLF)
  14. Yes. 👍
  15. 1) disadvantage of this technigue is always the aa quality and with the other technigue you can achive better quality 2) _StringTitleCase() works properly 3) yes, but when I think about it, there will always be a situation where even this doesn't work propely 4) that was new to me, too. 😄
×
×
  • Create New...