![]() ![]() This scenario is where scaling plays a role. Windows 10 scaling is beneficial in this situation, allowing you to match the text, images, and icons to the default display better.įurthermore, it’s always nice to have a higher resolution for visual experiences such as videos and games, but sometimes, text and icons look too small to read comfortably. Still, it can be annoying to drag windows between monitors when the resolution is different. Using multiple screens is a great way to organize your work or various activities. You can easily keep everything similar in size-or expand your existing monitor for better visibility. There are a number of possible solutions.This article shows you how to set up Windows 10 display scaling using one, two, or more screens simultaneously. Working around this bug is left as an exercise to the reader. ![]() However, the code fails miserably in the presence of multiple monitors, which allows for negative onscreen coordinates. In a single-monitor environment, negative coordinates are always off-screen, and it makes sense to snap to onscreen coordinates, which are always positive. The code was probably there from when only single monitors were supported in Windows 95 / Windows NT 4.0. Which is amusing, since two lines later are calls to SetWindowToMonitor. It seems that this code wasn't updated when VCL was updated to support multiple monitors. So, if you try to center the form on a monitor to the left or above the primary monitor (remember that origin is at upper-left corner of primary monitor), it will get snapped to the primary monitor from this check. The key to this bug seems to be the following snippets, repeated several times in the function: if X < 0 then X := 0 Y := (Screen.DesktopHeight - Height) div 2 X := (Screen.DesktopWidth - Width) div 2 Y := ((CenterForm.Height - Height) div 2) + CenterForm.Top X := ((CenterForm.Width - Width) div 2) + CenterForm.Left If (FPosition = poOwnerFormCenter) and (Owner is TCustomForm) then Y := ( - Height) div 2 Įlse if FPosition in then ((FPosition = poMainFormCenter) and (FormStyle = fsMDIChild)) then From forms.pas on my system, with some snipping for brevity: procedure TCustomForm.CMShowingChanged(var Message: TMessage) SetWindowPlacement(Form.Handle, of the other answers here mention the cause of the problem in the first place, which is a bug in the VCL. Result := (X >= X1) And (X = Y1) And (Y Left + Width then Function PointInBox(x, y, x1, y1, x2, y2 : Integer) : Boolean Note that this is only about ensuring that the form is visible and entirely on one monitor, there is no attempt to center it. It's been a long time since I messed with this, it hasn't given me any trouble in ages and so I haven't tested it on anything more recent than XP/Delphi 7. (This would come about when the saved position is on a monitor that doesn't exist anymore-either removed or running on a different machine.) ![]() Note that you must consider the case where the window shows up not on ANY monitor-I handle that by throwing it to the first monitor. While my code does not center (I was simply after ensuring that the window is entirely within whatever monitor it came up on) the idea remains the same. I have a standard procedure that goes through the list of monitors and figures out where the upper left corner is to decide what monitor to put it on. Screen.Monitors contains information on each screen. Jlouro has the right idea except for looking at the mouse. ![]()
0 Comments
Leave a Reply. |