kamesankamesan Posted July 29, 2024 Posted July 29, 2024 Hi, My screen is a 2560x1440. My windows ui scale is 125% I'm trying to draw a yellow rectangles on viewport area. But my drawing area seems based on the 125% virtual resolution of 2048x1152 So rectangles are cropped. here my code part: Local $scale = _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] / @DesktopWidth _GDIPlus_Startup() Local $hDC = _WinAPI_GetDC($GE_Pos) Local $hPen = _GDIPlus_PenCreate(0xFFFFA500, 2) ; Format de couleur ARGB (Alpha, Rouge, Vert, Bleu) Local $rect = WinGetClientSize($GE_Pos) Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) _GDIPlus_GraphicsDrawRect($hGraphics, ($Lpos[0]+$GE_Pos[0]+$Title_X_Tweak+2)*$scale, ($Lpos[1]+$GE_Pos[1]+$Title_Y_Tweak+2)*$scale, ($GE_Pos[2] - 4)*$scale, ($GE_Pos[3] - 4)*$scale, $hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_PenDispose($hPen) _WinAPI_ReleaseDC($GE_Pos, $hDC) _GDIPlus_Shutdown() i'm biting my head. Any help is welcome.
Nine Posted July 29, 2024 Posted July 29, 2024 (edited) Just pick the resolution you enjoy most at 100%. This is what I did. And all your DPI and scaling issues will be resolved. But if you insist on keeping your 125%, search for DPI awareness threads on this forum, there are numerous discussions of this topic. Edited July 29, 2024 by Nine “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) Screen Scraping Multi-Threading Made Easy
kamesankamesan Posted July 29, 2024 Author Posted July 29, 2024 Thank you. Unfortunately there are several users with different ui scales. My rectangles should be able to draw according to any ui scale % .
Solution kamesankamesan Posted July 30, 2024 Author Solution Posted July 30, 2024 DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) was the key thx
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