• Welcome to Jose's Read Only Forum 2023.
 

Dialog units in oxygen...

Started by Brian Alvarez, December 31, 2018, 09:19:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

I currently use this to position dialogs:

  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


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:

DIALOG NEW hParent... ' default, Units.
DIALOG NEW UNITS, hParent...
DIALOG NEW PIXELS, hParent...
DIALOG NEW DPIAWARE, hParent...
DIALOG NEW OPENGL, hParent...


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".


Brian Alvarez

I looked at that page the other day and made this 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)


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