by ShumingWang » Wed Apr 30, 2014 3:02 am
dialog.prg
+ METHOD Autoresize(ntop,nleft,res)
METHOD Autoresize(ntop,nleft,res)
local i,rsl0,rsl1,oCtrol,aRect
DEFAULT ntop:=0
DEFAULT nleft:=0
if res==nil; res:=800; end
rsl0:=getsysmetrics(0)/res //width,col
if rsl0==1; return ; end //<=800*600, not needed
rsl1:=getsysmetrics(1)/if(res==800,600,768) // height ,nrow
for i:=1 TO LEN(::acontrols)
oCtrol = ::aControls[i] // top:nrow, left:ncol,bottom: nrow, right:ncol
aRect = GetCoors( oCtrol:hWnd )
do case
case oCtrol:classname()=="TCOMBOBOX"
oCtrol:Move( aRect[1]*rsl1, aRect[2]*rsl0)
otherwise
oCtrol:Move( aRect[1]*rsl1, aRect[2]*rsl0,(aRect[4] - aRect[2])*rsl0, (aRect[3] - aRect[1])*rsl1, .t. )
// ntop,nleft,nbottom,nright
end case
next
// aRect = GetWndRect( ::hWnd )
::Move( ntop,nleft,::nWidth*rsl0, ::nHeight*rsl1, .T. )
if ::lCentered
WndCenter( ::hWnd )
else
if Empty( ::cResName )
::Move( ::nTop, ::nLeft )
endif
endif
return
in prg:
ACTIVATE DIALOG odlg
ON INIT (odlg:autoresize())