1. Edinson Nongrados
  2. PowerBuilder
  3. Monday, 26 April 2021 11:12 AM UTC

Good afternoon,

I have a doubt about the resolution of my second screen, i don't know hot to get the resolution from pixels to powerbuilder units.

 

Do you know any way to get the resolution ?

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Monday, 26 April 2021 13:48 PM UTC
  2. PowerBuilder
  3. # Permalink

Greetings, Edinson -

Screen resolution generally refers to dots (pixels) per inch (DPI), whereas screen size is typically expressed as the number of pixels wide (x-direction) by the number of pixels high (y-direction). All monitors also have a starting x,y coordinate within the virtual screen (a bounding rectangle that encompasses all monitors).

https://docs.microsoft.com/en-us/windows/win32/gdi/the-virtual-screen

Which of these are you asking about? Could you please clarify?

Comment
  1. Edinson Nongrados
  2. Monday, 26 April 2021 15:00 PM UTC
Hello, John



I meant the screen size (the width adn the height) in pixel of my second screen.



Thank you for answer.



  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 26 April 2021 18:41 PM UTC
  2. PowerBuilder
  3. # 1

The built in function UnitsToPixels converts PBUs to Pixels. Likewise PixelsToUnits converts pixels to PBUs.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 26 April 2021 18:36 PM UTC
  2. PowerBuilder
  3. # 2

Hi Edison;

  I would look at using the SDK function ...

FUNCTION Integer  GetSystemMetrics ( Integer nIndex ) LIBRARY "USER32.dll"

  to locate if the machine has a second monitor and then, the SDK function ...

FUNCTION Boolean GetMonitorInfoW ( HMONITOR  hMonitor,   LPMONITORINFO lpmi ) LIBRARY "USER32.dll"

  to get the monitor's dimensions. number, etc,

Example: http://www.rgagnon.com/pbdetails/powerbuilder-display-on-the-second-monitor.html

HTH

Regards ... Chris

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 26 April 2021 18:35 PM UTC
  2. PowerBuilder
  3. # 3

To obtain properties of all secondary monitors, you need a (windows) handle to the monitor.  The "proper" way to obtain monitor handles is via the EnumDisplayMonitors Windows API, but this requires a callback function - which is not possible using pure PowerScript. If you have a window or a screen coordinate to test, you can obtain a monitor handle, but the virtual screen (the rectangle that encompasses all visible display monitors) is not always completely covered by monitors and virtual screen coordinates can be negative, so it is not obvious what coordinate(s) you should test.

So I came up with a "brute force" method that seems to work on my two-monitor system. The approach uses some Windows API functions and Windows structures, but the code is all PowerScript. The script calls the GetSystemMetrics, MonitorFromPoint and GetMonitorInfoEx API functions and uses the PB equivalent of the Windows POINT, RECT and MONITORINFOEX structures.

Attached is a zip file containing a small, single-window app named MonitorInfo, written in PB 2017. The Clicked event script for the command button labelled "Info About All Monitors" obtains size information about all monitors and displays that information in a series of message boxes, one for each monitor.

You should be able to adapt the code to satisfy your needs.

Best regards, John

Attachments (1)
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.