Author Topic: Dialog units in oxygen...  (Read 300 times)

0 Members and 1 Guest are viewing this topic.

Offline Brian Alvarez

  • Moderator
  • Full Member
  • *****
  • Posts: 147
    • PluriBASIC
Dialog units in oxygen...
« on: December 31, 2018, 09:19:50 AM »
I currently use this to position dialogs:

Code: [Select]
  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:

Code: [Select]
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".
« Last Edit: December 31, 2018, 09:25:03 AM by Brian Alvarez »

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 677
    • Charles Pegge
Re: Dialog units in oxygen...
« Reply #1 on: December 31, 2018, 10:18:02 AM »

Offline Brian Alvarez

  • Moderator
  • Full Member
  • *****
  • Posts: 147
    • PluriBASIC
Re: Dialog units in oxygen...
« Reply #2 on: December 31, 2018, 10:30:27 PM »
I looked at that page the other day and made this code:

Code: [Select]
  ' 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. :)