2021年12月10日 星期五

Multi-monitor in Delphi . Change Screen Resolution

https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Forms.TScreen.Monitors
https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Forms.TMonitor

Developing Application Programs Using Multi-monitor in Delphi
 Screen.MonitorCount Screen.Monitors array WorkareaRect  TCustomForm.MakeFullyVisible
MakeFullyVisible Monitor  dmDesktop  TScreen TMonitor
dmDesktop No special treatment
dmPrimary Display the form on the first monitor. This is another trap, literally understood as the main monitor, but in fact it refers to the Screen.Monitor[0] monitor.
dmMainForm Display the form to the monitor where the main form is located
dmActiveForm Display the form to the monitor on the desktop where the active form is located
 
BoundsRect  Get the corresponding desktop area of ​​the monitor, which is equivalent to the above four attributes
WorkareaRect  Get the area of ​​the desktop corresponding to the working area of ​​the monitor.

https://github.com/t-d-k/LibreCrypt/blob/master/SDeanComponents/DelphiVistaModifications/_originals/_ORIG%20-%20Forms.pas%20-%20ORIG_
 LibreCrypt/SDeanComponents/DelphiVistaModifications/_originals/_ORIG - Forms.pas - ORIG_
 
Tips for Multi-Resolution Delphi Applications
https://www.thoughtco.com/multi-resolution-delphi-applications-1058296
 
改變螢幕解析度. Change Screen Resolution in Windows using C++ 主要使用Windows API ChangeDisplaySettings 及 EnumDisplaySettings

取得單一螢幕或多螢幕的解析度get resolution of a ...
https://ccw1986.blogspot.com › 2014/01 › c-get-resolut...
 foreach (var screen in System.Windows.Forms.Screen.AllScreens) { Console.WriteLine("Device Name: " + screen.DeviceName);//裝置名稱. Console.

delphi Windows Resolution recommended screen resolution
Get current/native screen resolution of all monitors in Delphi DirectX

MonInfo: TMonitorInfo;
  MonInfo.cbSize := SizeOf(MonInfo);
  GetMonitorInfo(MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST), @MonInfo);
  ShowMessage(Format('Current resolution: %dx%d',
              [MonInfo.rcMonitor.Right - MonInfo.rcMonitor.Left,
               MonInfo.rcMonitor.Bottom - MonInfo.rcMonitor.Top]));


See the GetDeviceCaps API to get the screen resolution.

Use the TCustomForm.Monitor property to get the monitor on which the form appears.
 
how to get the recommend resolution (native ... - MSDN
https://social.msdn.microsoft.com › en-US
Building Windows 8. As to how to get screen resolution using C++. There are many ways to do this. You can choose to use. GetSystemMetrics with ...
 
    GetSystemMetrics function (winuser.h) - Win32 apps
    https://docs.microsoft.com › win32 › api The width of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of ...

Improving the high-DPI experience in GDI based Desktop Apps
https://blogs.windows.com  GDI was for many years the de facto win32 2D API and is behind many of ... how best to make legacy GDI apps look right on high DPI monitors.
  Windows 8.1 DPI Scaling Enhancements This could be a problem if the reason you bought that 4K display was to see more of your images at native resolution! Windows 8.1 provides APIs ...

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changedisplaysettingsexa
ChangeDisplaySettingsExA function (winuser.h)

https://blogs.embarcadero.com/new-in-rad-studio-11-high-dpi-ide-and-form-designing/
https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Per_Monitor_V2
https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Supporting_high-DPI_images_with_the_Image_Collection_and_Virtual_ImageList_components
https://docwiki.embarcadero.com/RADStudio/Alexandria/en/VCL_Styles_Support_for_High-DPI_Graphics
 
https://github.com/ThePacielloGroup/CCA-Win/blob/master/PerMonitorApi.pas
Type
  TMONITOR_DPI_TYPE = (
    MDT_EFFECTIVE_DPI {= 0},
    MDT_ANGULAR_DPI   {= 1},
    MDT_RAW_DPI       {= 2},
    MDT_DEFAULT       {= MDT_EFFECTIVE_DPI });
var
  dpiX              : UINT;
  dpiY              : UINT;
  ErrCode           : HResult;
  hShcore           : THandle;
  GetDpiForMonitor  : function(monitor: HMONITOR; dpiType: TMONITOR_DPI_TYPE; var dpi, dpiY: UINT): HRESULT; stdcall;
begin
  hShcore := GetModuleHandle('Shcore');
  If hShcore <> 0 then GetDpiForMonitor := GetProcAddress(hShcore,'GetDpiForMonitor');
  If @GetDpiForMonitor <> nil then
    ErrCode := GetDpiForMonitor(Monitor.Handle,MDT_EFFECTIVE_DPI,dpiX,dpiY);
end;
https://docs.microsoft.com/zh-tw/archive/blogs/askcore/display-scaling-in-windows-10
https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows
https://gist.github.com/toptensoftware/a6b8ca2cfc9ac63e7b6687968db408a2

https://github.com/r1me/delphi-monitorhelper/blob/master/Vcl.Forms.MonitorHelper.pas
https://github.com/pgiacomo69/TFormResizer
https://github.com/KohrAhr/DelphiDemoPPI

https://github.com/timmui/ScreenResolutionChanger
 
https://stackoverflow.com/questions/1538602/find-number-and-resolution-to-all-monitors
In C#: Screen Class Represents a display device or multiple display devices on a single system. You want the Bounds attribute.
 var screen in Screen.AllScreens)
    // For each screen, add the screen properties to a list box.
     ("Device Name: " + screen.DeviceName);
     ("Bounds: " + screen.Bounds.ToString());
     ("Type: " + screen.GetType().ToString());
     ("Working Area: " + screen.WorkingArea.ToString());
     ("Primary Screen: " + screen.Primary.ToString());

取得顯示監視器的資訊

https://docs.microsoft.com/zh-tw/windows/win32/gdi/getting-information-on-a-display-monitor
https://docs.microsoft.com/zh-tw/windows/win32/api/winuser/nf-winuser-enumdisplaydevicesa
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)
    FARPROC EnumDisplayDevices;
    HINSTANCE  hInstUser32;
    DISPLAY_DEVICE DispDev;
    char szSaveDeviceName[33];  // 32 + 1 for the null-terminator
    BOOL bRet = TRUE;
        HRESULT hr;
    hInstUser32 = LoadLibrary("c:\\windows\User32.DLL");
    if (!hInstUser32) return FALSE; 
    // Get the address of the EnumDisplayDevices function
    EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
    if (!EnumDisplayDevices) {
        FreeLibrary(hInstUser32);
if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0))
                hr = StringCchCopy(szSaveDeviceName, 33, DispDev.DeviceName);
        EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);  
                hr = StringCchCopy(lpszMonitorInfo, 129, DispDev.DeviceString);
                if (FAILED(hr))
 

沒有留言: