Dividing oDlg:nHeight and oDlg:nWidth by 2, it shows the controls in the right place.
nageswaragunupudi wrote:In the ON INIT clause, we do not have to do 1/2
Therefore, to convert dialog template units to pixels, use the following formulas:
pixelX = MulDiv(templateunitX, baseunitX, 4);
pixelY = MulDiv(templateunitY, baseunitY, 8 );
Similarly, to convert from pixels to dialog template units, use the following formulas:
templateunitX = MulDiv(pixelX, 4, baseunitX);
templateunitY = MulDiv(pixelY, 8, baseunitY);
#include "FiveWin.ch"
function Main()
local oWnd, cTest := Space( 20 )
DEFINE WINDOW oWnd TITLE "A window"
@ 20, 20 SAY "Hello" SIZE 80, 20 PIXEL
@ 20, 60 GET cTest SIZE 80, 20 PIXEL
@ 80, 60 BUTTON "Ok" SIZE 80, 20 PIXEL
@ 80, 180 BUTTON "Cancel" SIZE 80, 20 PIXEL
Dialog( oWnd )
ACTIVATE WINDOW oWnd ;
ON CLICK MsgInfo( oWnd:nWidth )
return nil
#define SM_CXDLGFRAME 7
function Dialog( oWnd )
local oDlg, cTest := Space( 20 )
local factorX := 4 / nLoWord( GetDlgBaseUnits() )
local factorY := 8 / nHiWord( GetDlgBaseUnits() )
DEFINE DIALOG oDlg TITLE "A dialog" ;
SIZE oWnd:GetCliRect():nWidth - 2, oWnd:GetCliRect():nHeight - 2
@ 20 * factorX, 20 * factorY SAY "Hello" SIZE 80 * factorY, 20 * factorX PIXEL
@ 20 * factorX, 60 * factorY GET cTest SIZE 80 * factorY, 20 * factorX PIXEL
@ 80 * factorX, 60 * factorY BUTTON "Ok" SIZE 80 * factorY, 20 * factorX PIXEL
@ 80 * factorX, 180 * factorY BUTTON "Cancel" SIZE 80 * factorY, 20 * factorX PIXEL
ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
ON CLICK MsgInfo( oDlg:GetCliRect():nWidth - oWnd:GetCliRect():nWidth )
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 16 guests