Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

GetDialogBaseUnits working replacement

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GetDialogBaseUnits working replacement

    If you tried using GetDialogBaseUnits it is useless. It only returns baseunits based on default font.

    Supply the original width and height of the dialog and make sure the dialog is not resized when you use this.



    Code:
    SUB GetDialogBaseUnitsX (BYVAL hDlg AS LONG, BYVAL nWidth AS LONG, nHeight AS LONG, baseunitX AS LONG, baseunitY AS LONG )
    
    
    ''%XWConst = 4
    ''%YHConst = 8
    
    
      LOCAL mdr AS rect
    
    
                ' nWidth    original width  dlg units
                ' nHeight   original height dlg units
    
                mdr.right =  nWidth
                mdr.bottom = nHeight
    
                MapDialogRect( hDlg,mdr )           'map  dlg with original dlu creation values
                                                    'this will return return the size in pixels
    
                'rcl.right and rcl.bottom now holds Pixels which is the current dlg size in pixels
    
                ''baseunityX =    '4        *  current x in pix  / dlu x creation value
                baseunitX =    %XWConst     * mdr.right          / nWidth
                ''baseunity =     '8        *  current y in pix  / dlu y creation value
                baseunitY =    %YHConst     * mdr.bottom         / nHeight
    
    
      END SUB 'GetDialogBaseUnitsX
    Last edited by Michael Mayerhoffer; 26 Sep 2021, 01:51 AM. Reason: spelling
    A dozen what.

  • #2
    Discussion thread: https://forum.powerbasic.com/forum/u...ion#post811195

    Comment

    Working...
    X