No announcement yet.

Dialog Pixels To Units

  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    also, when centering a control or a dialog relative to the screen, you should also take into account how big the task bar is - if the task bar is large or on an "unusual" position, your app may end up overlapping it which can produce interesting results! you should calculate the centre based on the available desktop area, rather than the screen area.

    the systemparametersinfo() api with the %spi_getworkarea flag will give you the true desktop size.

    also see

    powerbasic support
    mailto:[email protected][email protected]</a>

    Leave a comment:

  • Chris Boss

    The coordinates used for creating controls are "Client" coordinates, not "Screen" coordinates.

    To make a label centered in your Dialog, requires knowing the width and height of the client area (inside of Dialog, excluding the Caption Bar, menu and Borders) and then calculating where to center it.

    You seem to be using "Screen" coordinates, based on centering to the screen.


    Leave a comment:

  • Peter Lameijn
    started a topic Dialog Pixels To Units

    Dialog Pixels To Units

    When I use the following code:
    Dim X As Long, Y As Long
      Dialog Pixels hDlg, GetSystemMetrics(% SM_CXSCREEN)  ,GetSystemMetrics(%SM_CYSCREEN) To Units x, y
      Control Add Label, hDlg, -1, "Test!", X\2-20, Y\2-10, 40, 20
    The label should be positioned on the screen center, but it isn't. The horizontal (x)position is OK, but the vertical (y) position is well below the screen center on a fullscreen dialog window. The getsystemmetrics call returns the right value's (1024 * 768 in my case) Is there some error in the pixels-to-units conversion?

    Kind regards,