IT-Berater: Theo Gottwald (IT-Consultant) > Brians Board

Dialog units in oxygen...

(1/1)

Brian Alvarez:
I currently use this to position dialogs:


--- Code: ---  sys hFont     = _10GetStockObject(17)
  sys       hDC = _10GetDC(0)
  single ratioX = (_10GetDeviceCaps(hDC, 88) / 96)
  single ratioY = (_10GetDeviceCaps(hDC, 90) / 96) 
  _10ReleaseDC(0, hDC)
                                                 
  long DX = 0
  long dy = 0
  int dw  = (W * RatioX) * 1.53
  int dH  = (H * RatioY) * 1.7 
 
  if @Xt then
    DX = (XT * RatioX) * 1.53
  else
    DX = (_10GetSystemMetrics(0)/2) - (dw/2)
  end if
 
  if @Yt then
    DY = (YT * RatioY) * 1.7
  else
    DY = (_10GetSystemMetrics(1)/2) - (dh/2)
  end if
--- End code ---

 But to be honest im not really sure how dialog units are calculated. I have done it several ways
already but none oF them give the same result. The above code is the closest to real units,
but i dont even know why i have to add the multiplier.

This is only for UNITS (the only half-implemented way now), but the syntax already accepts:


--- Code: ---DIALOG NEW hParent... ' default, Units.
DIALOG NEW UNITS, hParent...
DIALOG NEW PIXELS, hParent...
DIALOG NEW DPIAWARE, hParent...
DIALOG NEW OPENGL, hParent...
--- End code ---

However, the guts need to be coded. If you have suggestions for the rest, i would appreciate it.

By the way, the _10 prefix is to avoid collisions with #INCLUDE "WIN32API.INC".

Charles Pegge:
Hi Brian,

Have you tried

MapDialogRect function

https://docs.microsoft.com/en-gb/windows/desktop/api/winuser/nf-winuser-mapdialogrect

Brian Alvarez:
I looked at that page the other day and made this code:


--- Code: ---  ' TO-DO:
  ' calculate the coordinates to work as units too.
 ' sys BaseUnits = _10GetDialogBaseUnits()
 ' int baseunitX = (((BaseUnits)>>16) and 0xffff) 
 ' int baseunitY = ((BaseUnits) and 0xffff)
 '
 ' PRINT STR(Ratiox) + " " + STR(Ratioy)
 ' PRINT STR(x) + " " + STR(y) + " " + STR(w) + " " + STR(h)
 ' PRINT STR(baseunits) + " " + STR(baseunitX) + " " + STR(baseunitY)
 '
 ' int dx        = _10MulDiv(X, 4, BaseunitX)
 ' int dy        = _10MulDiv(Y, 8, BaseunitY)
 ' int dW        = _10MulDiv(W, 4, BaseunitX)
 ' int dH        = _10MulDiv(H, 8, BaseunitY)
--- End code ---

Ended up remarking that because the sizes didn't match. I will try again tonight. :)

Navigation

[0] Message Index

Go to full version