Nine Posted April 12 Posted April 12 One other note. When adding (which I usually do when I create a new project) : Opt("MustDeclareVars", True) It freezes the GUI. This is somewhat a known bug (at least for me). When subclassing, if a variable is not declared in the subclass proc, AutoIt freezes literally. You need to kill the process. Not so obvious when you are not aware of it. After a closer look at the subclass proc for it, I noticed that $tRectTmp was not declared. That escaped me... ps. you can also remove the global const and the global $hGUI. (I just dislike those unnecessary globals) WildByDesign 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
WildByDesign Posted April 12 Author Posted April 12 45 minutes ago, Nine said: Also I see better result in my case when the up-down control is moved only 1 pixel instead of 2 (right and left). You are right about the 1 pixel move being the most appropriate. 37 minutes ago, WildByDesign said: Interesting, I appreciate this feedback. This makes me wonder if the number of pixels needed to move depends on DPI. My scaling is 125% and 2 pixels works best for mine. I would then assume that users with even higher scaling may need slightly differing pixel values. I will have to dig into this some more. I just tested with the different scaling settings and my assumption was wrong. As you suggested, 1 pixel move seems best for all. I have updated my current script for this. 21 minutes ago, Nine said: One other note. When adding (which I usually do when I create a new project) : Opt("MustDeclareVars", True) It freezes the GUI. This is somewhat a known bug (at least for me). When subclassing, if a variable is not declared in the subclass proc, AutoIt freezes literally. You need to kill the process. Not so obvious when you are not aware of it. After a closer look at the subclass proc for it, I noticed that $tRectTmp was not declared. That escaped me... I've added the MustDeclareVars Opt now and declared the $tRectTmp variable locally in the UpDownSub() function. 23 minutes ago, Nine said: ps. you can also remove the global const and the global $hGUI. (I just dislike those unnecessary globals) Done. Removed. I can't remember why I added that because it was needed at some point in time when I was testing a few things. But it is definitely not needed now. Without a doubt, your implementation is better than Windows own UpDown control functionality. Originally, I was only going to subclass the control for Windows 10 users and use the DarkMode theming for Windows 11 users. But now I am thinking of subclassing regardless of OS build because your implementation is just better. The only remaining concern that I have is making the arrows the same size. We could possibly use GDI+ to draw them but I have no experience with GDI+. We could use _WinAPI_DrawThemeBackground() to paint a resource from theme. But I could not find any plain arrows in aero.msstyles from Windows 10 resources (unless we use the light mode arrow and invert). It would have to support Win10 users. I did find chevrons in the theme resources but I don't think chevrons would look good because it would signify scrollbar which would seem wrong. Here is my current script with your latest suggestions (and pen colour change as well): expandcollapse popupDllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsStylesConstants.au3> #include <WinAPITheme.au3> #include <WinAPISysWin.au3> #include <WindowsNotifsConstants.au3> #include <WinAPIGdiDC.au3> #include <APIGdiConstants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> #include <Misc.au3> Opt("MustDeclareVars", True) Global Const $UDM_GETBUDDY = 1130 Global $hUser32Dll = DllOpen("user32.dll") Example() Func Example() Local $hGUI = GUICreate("Dark Mode UpDown", 400, 400) GUISetBkColor(0x323232) GUISetFont(14) ; Apply dark mode to Edit box GUIRegisterMsg($WM_CTLCOLOREDIT, "_WM_CTLCOLOR") Local $idInput = GUICtrlCreateInput("2", 150, 80, 100, 40, -1, $WS_EX_STATICEDGE) Local $h_Input = GUICtrlGetHandle($idInput) Local $idUpDown = GUICtrlCreateUpdown($idInput) Local $hUpDown = GUICtrlGetHandle($idUpDown) Local $idInput2 = GUICtrlCreateInput("2", 150, 140, 100, 40, -1, $WS_EX_STATICEDGE) Local $h_Input2 = GUICtrlGetHandle($idInput2) Local $idUpDown2 = GUICtrlCreateUpdown($idInput2, $UDS_HORZ) ; UDS_HORZ testing Local $hUpDown2 = GUICtrlGetHandle($idUpDown2) Local $iBuddyPos ; Move UpDown control by 1 pixel to prevent clipping If BitAND(_WinAPI_GetWindowLong($hUpDown, $GWL_STYLE), $UDS_ALIGNLEFT) Then $iBuddyPos = -1 Else $iBuddyPos = 1 EndIf GUICtrlSetPos($idUpDown, ControlGetPos("", "", $hUpDown)[0] + $iBuddyPos) If BitAND(_WinAPI_GetWindowLong($hUpDown2, $GWL_STYLE), $UDS_ALIGNLEFT) Then $iBuddyPos = -1 Else $iBuddyPos = 1 EndIf GUICtrlSetPos($idUpDown2, ControlGetPos("", "", $hUpDown2)[0] + $iBuddyPos) Local $hDll = DllCallbackRegister(UpDownSub, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") _WinAPI_SetWindowSubclass($hUpDown, DllCallbackGetPtr($hDll), $idUpDown) _WinAPI_SetWindowSubclass($hUpDown2, DllCallbackGetPtr($hDll), $idUpDown2) ; tab control test GUISetFont(9) Local $idTab = GUICtrlCreateTab(100, 200, 200, 100) Local $h_Tab = GUICtrlGetHandle($idTab) GUICtrlCreateTabItem("tab0") GUICtrlCreateTabItem("tab1") GUICtrlCreateTabItem("tab2") GUICtrlCreateTabItem("tab3") GUICtrlCreateTabItem("tab4") GUICtrlCreateTabItem("") ; find updown control Local $hUpDown3 = _WinAPI_FindWindowEx($h_Tab, 0, "msctls_updown32", "") _WinAPI_SetWindowSubclass($hUpDown3, DllCallbackGetPtr($hDll), $idTab) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass($hUpDown, DllCallbackGetPtr($hDll), $idUpDown) _WinAPI_RemoveWindowSubclass($hUpDown2, DllCallbackGetPtr($hDll), $idUpDown2) _WinAPI_RemoveWindowSubclass($hUpDown3, DllCallbackGetPtr($hDll), $idTab) DllCallbackFree($hDll) DllClose($hUser32Dll) EndFunc ;==>Example Func _WM_CTLCOLOR($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hDC = $wParam Local $hCtrl = $lParam _WinAPI_SetTextColor($hDC, 0xFFFFFF) Local $hBrush = _WinAPI_CreateSolidBrush(0x202020) _WinAPI_SetBkColor($hDC, 0x202020) _WinAPI_SetBkMode($hDC, $TRANSPARENT) Return $hBrush EndFunc ;==>_WM_CTLCOLOR Func UpDownSub($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) Local Static $bHover Local $bHorz = BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), $UDS_HORZ) Local $tRectTmp Switch $iMsg Case $WM_PAINT Local $tPaint, $hDC = _WinAPI_BeginPaint($hWnd, $tPaint) Local $tRect = _WinAPI_GetClientRect($hWnd) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $tRect.right, $tRect.bottom) Local $hOldBmp = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $hPen = _WinAPI_CreatePen($PS_SOLID, 1, 0xE0E0E0) ; TODO: change color later in UDF to match border color var _WinAPI_SelectObject($hMemDC, $hPen) Local $hBrush = _WinAPI_CreateSolidBrush(0x242424) _WinAPI_SetBkMode($hMemDC, $TRANSPARENT) _WinAPI_SelectObject($hMemDC, $hBrush) _WinAPI_Rectangle($hMemDC, $tRect) If $bHorz Then _WinAPI_DrawLine($hMemDC, Int($tRect.right / 2), 0, Int($tRect.right / 2), $tRect.bottom) Else _WinAPI_DrawLine($hMemDC, 0, Int($tRect.bottom / 2), $tRect.right, Int($tRect.bottom / 2)) EndIf _WinAPI_DeleteObject($hPen) _WinAPI_DeleteObject($hBrush) If $bHover Then If $bHorz Then Local $iPos = Round(_WinAPI_GetMousePos(True, $hWnd).x / _WinAPI_GetClientRect($hWnd).right, 0) Else Local $iPos = Round(_WinAPI_GetMousePos(True, $hWnd).y / _WinAPI_GetClientRect($hWnd).bottom, 0) EndIf $hBrush = _WinAPI_CreateSolidBrush(_IsPressed($VK_LBUTTON, $hUser32Dll) ? 0x404040 : 0x606060) $tRectTmp = _WinAPI_GetClientRect($hWnd) If $iPos Then If $bHorz Then $tRectTmp.left = Int($tRect.right / 2) Else $tRectTmp.top = Int($tRect.bottom / 2) EndIf Else If $bHorz Then $tRectTmp.right = Int($tRect.right / 2) Else $tRectTmp.bottom = Int($tRect.bottom / 2) EndIf EndIf _WinAPI_SelectObject($hMemDC, $hBrush) _WinAPI_Rectangle($hMemDC, $tRectTmp) _WinAPI_DeleteObject($hBrush) EndIf _WinAPI_SetTextColor($hMemDC, 0xFFFFFF) $tRectTmp = _WinAPI_GetClientRect($hWnd) Local $iFW = Int($tRect.right / ($bHorz ? 5 : 3)), $iFH = $iFW + ($bHorz ? 14 : 2) Local $hFont = _WinAPI_CreateFont($iFH, $iFW) _WinAPI_SelectObject($hMemDC, $hFont) If $bHorz Then $tRectTmp.top = Int(($tRect.bottom - $iFH) / 2) $tRectTmp.right = $tRect.right / 2 _WinAPI_DrawText($hMemDC, "◄", $tRectTmp, BitOR($DT_CENTER, $DT_VCENTER, $DT_NOCLIP)) $tRectTmp.left = Int($tRect.right / 2) $tRectTmp.right = $tRect.right _WinAPI_DrawText($hMemDC, "►", $tRectTmp, BitOR($DT_CENTER, $DT_VCENTER, $DT_NOCLIP)) Else $tRectTmp.top = Int((Round($tRect.bottom / 2) - $iFH) / 2) _WinAPI_DrawText($hMemDC, "▲", $tRectTmp, BitOR($DT_CENTER, $DT_VCENTER, $DT_NOCLIP)) $tRectTmp.top += Round($tRect.bottom / 2) _WinAPI_DrawText($hMemDC, "▼", $tRectTmp, BitOR($DT_CENTER, $DT_VCENTER, $DT_NOCLIP)) EndIf _WinAPI_BitBlt($hDC, 0, 0, $tRect.right, $tRect.bottom, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hOldBmp) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _WinAPI_DeleteObject($hFont) _WinAPI_EndPaint($hWnd, $tPaint) Case $WM_MOUSEMOVE $bHover = True _WinAPI_TrackMouseEvent($hWnd, $TME_LEAVE) _WinAPI_InvalidateRect($hWnd, 0, False) Return Case $WM_MOUSELEAVE $bHover = False _WinAPI_InvalidateRect($hWnd, 0, False) Return EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>UpDownSub Func _WinAPI_FindWindowEx($hParent, $hAfter, $sClass, $sTitle = "") Local $ret = DllCall($hUser32Dll, "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
Nine Posted April 12 Posted April 12 8 minutes ago, WildByDesign said: The only remaining concern that I have is making the arrows the same size. Just fix the font size as you want it to (height and width). You can decide to have 2 different sizes (horizontal and vertical). Just replace my calculations with fixed values ($iFH and $iFW). Rest should stay the same. WildByDesign 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
pixelsearch Posted April 12 Posted April 12 @WildByDesign Hello As I always said, this syntax is wrong... Opt("MustDeclareVars", True) ...when this syntax is correct... Opt("MustDeclareVars", 1) For example, in your script from preceding page, when $tRectTmp is not declared, this is the result of both syntax, when you click on Scite menu "Syntax CheckProd Ctrl+F5" Opt("MustDeclareVars", True) Exit code: 0 <=== no syntax error detected, but script will hang when you run it Opt("MustDeclareVars", 1) (139,57) : warning: $tRectTmp possibly not declared/created yet $tRectTmp = _WinAPI_GetClientRect($hWnd) >Exit code: 1 This demonstration should be enough to get rid forever with the undocumented syntax Opt("MustDeclareVars", True) WildByDesign 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
WildByDesign Posted April 12 Author Posted April 12 1 hour ago, pixelsearch said: Hello Hello, it's great to see you. 1 hour ago, pixelsearch said: This demonstration should be enough to get rid forever with the undocumented syntax Opt("MustDeclareVars", True) Indeed, that demo speaks for itself. Thanks for the clarification. I will make this change right now.
WildByDesign Posted April 12 Author Posted April 12 7 hours ago, Nine said: Just fix the font size as you want it to (height and width). You can decide to have 2 different sizes (horizontal and vertical). Just replace my calculations with fixed values ($iFH and $iFW). Rest should stay the same. I appreciate it. That helped. I am pretty certain that it is ready now to add to GUIDarkTheme UDF. Thank you so much for your help. This would not have been possible without you. And now, any AutoIt user can use it. Arrows are DPI aware now: expandcollapse popupDllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsStylesConstants.au3> #include <WinAPITheme.au3> #include <WinAPISysWin.au3> #include <WindowsNotifsConstants.au3> #include <WinAPIGdiDC.au3> #include <APIGdiConstants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> #include <Misc.au3> Opt("MustDeclareVars", 1) Global Const $UDM_GETBUDDY = 1130 Global $hUser32Dll = DllOpen("user32.dll") Global $g_iDpi Example() Func Example() Local $hGUI = GUICreate("Dark Mode UpDown", 400, 400) $g_iDpi = _WinAPI_GetDPI($hGUI) / 96 If @error Then $g_iDpi = 1 GUISetBkColor(0x323232) GUISetFont(14) ; Apply dark mode to Edit box GUIRegisterMsg($WM_CTLCOLOREDIT, "_WM_CTLCOLOR") Local $idInput = GUICtrlCreateInput("2", 150, 80, 100, 40, -1, $WS_EX_STATICEDGE) Local $h_Input = GUICtrlGetHandle($idInput) Local $idUpDown = GUICtrlCreateUpdown($idInput) Local $hUpDown = GUICtrlGetHandle($idUpDown) Local $idInput2 = GUICtrlCreateInput("2", 150, 140, 100, 40, -1, $WS_EX_STATICEDGE) Local $h_Input2 = GUICtrlGetHandle($idInput2) Local $idUpDown2 = GUICtrlCreateUpdown($idInput2, $UDS_HORZ) ; UDS_HORZ testing Local $hUpDown2 = GUICtrlGetHandle($idUpDown2) Local $iBuddyPos ; Move UpDown control by 1 pixel to prevent clipping If BitAND(_WinAPI_GetWindowLong($hUpDown, $GWL_STYLE), $UDS_ALIGNLEFT) Then $iBuddyPos = -1 Else $iBuddyPos = 1 EndIf GUICtrlSetPos($idUpDown, ControlGetPos("", "", $hUpDown)[0] + $iBuddyPos) If BitAND(_WinAPI_GetWindowLong($hUpDown2, $GWL_STYLE), $UDS_ALIGNLEFT) Then $iBuddyPos = -1 Else $iBuddyPos = 1 EndIf GUICtrlSetPos($idUpDown2, ControlGetPos("", "", $hUpDown2)[0] + $iBuddyPos) Local $hDll = DllCallbackRegister(UpDownSub, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") _WinAPI_SetWindowSubclass($hUpDown, DllCallbackGetPtr($hDll), $idUpDown) _WinAPI_SetWindowSubclass($hUpDown2, DllCallbackGetPtr($hDll), $idUpDown2) ; tab control test GUISetFont(9) Local $idTab = GUICtrlCreateTab(100, 200, 200, 100) Local $h_Tab = GUICtrlGetHandle($idTab) GUICtrlCreateTabItem("tab0") GUICtrlCreateTabItem("tab1") GUICtrlCreateTabItem("tab2") GUICtrlCreateTabItem("tab3") GUICtrlCreateTabItem("tab4") GUICtrlCreateTabItem("") ; find updown control Local $hUpDown3 = _WinAPI_FindWindowEx($h_Tab, 0, "msctls_updown32", "") _WinAPI_SetWindowSubclass($hUpDown3, DllCallbackGetPtr($hDll), $idTab) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass($hUpDown, DllCallbackGetPtr($hDll), $idUpDown) _WinAPI_RemoveWindowSubclass($hUpDown2, DllCallbackGetPtr($hDll), $idUpDown2) _WinAPI_RemoveWindowSubclass($hUpDown3, DllCallbackGetPtr($hDll), $idTab) DllCallbackFree($hDll) DllClose($hUser32Dll) EndFunc ;==>Example Func _WM_CTLCOLOR($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hDC = $wParam Local $hCtrl = $lParam _WinAPI_SetTextColor($hDC, 0xFFFFFF) Local $hBrush = _WinAPI_CreateSolidBrush(0x202020) _WinAPI_SetBkColor($hDC, 0x202020) _WinAPI_SetBkMode($hDC, $TRANSPARENT) Return $hBrush EndFunc ;==>_WM_CTLCOLOR Func UpDownSub($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) Local Static $bHover Local $bHorz = BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), $UDS_HORZ) Local $tRectTmp Switch $iMsg Case $WM_PAINT Local $tPaint, $hDC = _WinAPI_BeginPaint($hWnd, $tPaint) Local $tRect = _WinAPI_GetClientRect($hWnd) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $tRect.right, $tRect.bottom) Local $hOldBmp = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $hPen = _WinAPI_CreatePen($PS_SOLID, 1, 0xE0E0E0) ; TODO: change color later in UDF to match border color var _WinAPI_SelectObject($hMemDC, $hPen) Local $hBrush = _WinAPI_CreateSolidBrush(0x242424) _WinAPI_SetBkMode($hMemDC, $TRANSPARENT) _WinAPI_SelectObject($hMemDC, $hBrush) _WinAPI_Rectangle($hMemDC, $tRect) If $bHorz Then _WinAPI_DrawLine($hMemDC, Int($tRect.right / 2), 0, Int($tRect.right / 2), $tRect.bottom) Else _WinAPI_DrawLine($hMemDC, 0, Int($tRect.bottom / 2), $tRect.right, Int($tRect.bottom / 2)) EndIf _WinAPI_DeleteObject($hPen) _WinAPI_DeleteObject($hBrush) If $bHover Then If $bHorz Then Local $iPos = Round(_WinAPI_GetMousePos(True, $hWnd).x / _WinAPI_GetClientRect($hWnd).right, 0) Else Local $iPos = Round(_WinAPI_GetMousePos(True, $hWnd).y / _WinAPI_GetClientRect($hWnd).bottom, 0) EndIf $hBrush = _WinAPI_CreateSolidBrush(_IsPressed($VK_LBUTTON, $hUser32Dll) ? 0x404040 : 0x606060) $tRectTmp = _WinAPI_GetClientRect($hWnd) If $iPos Then If $bHorz Then $tRectTmp.left = Int($tRect.right / 2) Else $tRectTmp.top = Int($tRect.bottom / 2) EndIf Else If $bHorz Then $tRectTmp.right = Int($tRect.right / 2) Else $tRectTmp.bottom = Int($tRect.bottom / 2) EndIf EndIf _WinAPI_SelectObject($hMemDC, $hBrush) _WinAPI_Rectangle($hMemDC, $tRectTmp) _WinAPI_DeleteObject($hBrush) EndIf _WinAPI_SetTextColor($hMemDC, 0xFFFFFF) $tRectTmp = _WinAPI_GetClientRect($hWnd) Local $iFH = 7 * $g_iDpi Local $sFontName = "Segoe MDL2 Assets" Local $hFont = _WinAPI_CreateFont($iFH, 0, 0, 0, $FW_NORMAL, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, $sFontName) _WinAPI_SelectObject($hMemDC, $hFont) If $bHorz Then $tRectTmp.top = Int(($tRect.bottom - $iFH) / 2) $tRectTmp.right = $tRect.right / 2 _WinAPI_DrawText($hMemDC, ChrW(0xEDD9), $tRectTmp, BitOR($DT_CENTER, $DT_VCENTER, $DT_NOCLIP)) $tRectTmp.left = Int($tRect.right / 2) $tRectTmp.right = $tRect.right _WinAPI_DrawText($hMemDC, ChrW(0xEDDA), $tRectTmp, BitOR($DT_CENTER, $DT_VCENTER, $DT_NOCLIP)) Else $tRectTmp.top = Int((Round($tRect.bottom / 2) - $iFH) / 2) _WinAPI_DrawText($hMemDC, ChrW(0xEDDB), $tRectTmp, BitOR($DT_CENTER, $DT_VCENTER, $DT_NOCLIP)) $tRectTmp.top += Round($tRect.bottom / 2) _WinAPI_DrawText($hMemDC, ChrW(0xEDDC), $tRectTmp, BitOR($DT_CENTER, $DT_VCENTER, $DT_NOCLIP)) EndIf _WinAPI_BitBlt($hDC, 0, 0, $tRect.right, $tRect.bottom, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hOldBmp) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _WinAPI_DeleteObject($hFont) _WinAPI_EndPaint($hWnd, $tPaint) Case $WM_MOUSEMOVE $bHover = True _WinAPI_TrackMouseEvent($hWnd, $TME_LEAVE) _WinAPI_InvalidateRect($hWnd, 0, False) Return Case $WM_MOUSELEAVE $bHover = False _WinAPI_InvalidateRect($hWnd, 0, False) Return EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>UpDownSub Func _WinAPI_FindWindowEx($hParent, $hAfter, $sClass, $sTitle = "") Local $ret = DllCall($hUser32Dll, "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 _WinAPI_GetDPI($hWnd = 0) $hWnd = Not $hWnd ? _WinAPI_GetDesktopWindow() : $hWnd Local Const $hDC = _WinAPI_GetDC($hWnd) If @error Then Return SetError(1, 0, 0) Local Const $iDPI = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSX) If @error Or Not $iDPI Then _WinAPI_ReleaseDC($hWnd, $hDC) Return SetError(2, 0, 0) EndIf _WinAPI_ReleaseDC($hWnd, $hDC) Return $iDPI EndFunc ;==>_WinAPI_GetDPI
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