Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pixels and Foxels conversion
Message
De
16/03/2003 23:22:59
 
 
À
16/03/2003 17:30:25
Peter Easson
Catalina Trading
Sydney, Australie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00766384
Message ID:
00766431
Vues:
40
>When defining a POPUP MENU with
>
DEFINE POPUP mnuXXX SHORTCUT RELATIVE FROM MROW(), MCOL()
, the mrow() and mCol()values are in FOXELS. If you try to reposition the menu relative to an object on the screen, it becomes difficult to manage, as the object positions are in PIXELS. Has anybody a UDF to convert from PIXELS to FOXELS, ?
>
>Peter Easson, Sydney

Your welcome to try ....

***********************************************
function Pix2Fox
************************************************
lparameters nTop, nLeft, oObj
* convert a top/left pixel pair into a row/column pair based on font of object.
* callers responsibility to ensure oObj has font attributes.
* pass nTop and nLeft by reference
nTop= round(nTop/fontmetric(1, oObj.fontname, oObj.fontsize, OStyle2Style(m.oObj)), 3)
nLeft= round(nLeft/fontmetric(6, oObj.fontname, oObj.fontsize, OStyle2Style(m.oObj)), 3)

************************************************
function OStyle2Style
************************************************
lparameter oTxt
* Convert an objects text style to a Fontmetric Style
local cS
with oTxt
if .fontbold
cS= "B"
else
cS= "N"
endif
if .fontitalic
cS= m.cS + "I"
endif
if .fontoutline
cS= m.cS + "O"
endif
if .fontshadow
cS= m.cS + "S"
endif
if .fontstrikethru
cS= m.cS + "-"
endif
if .fontunderline
cS= m.cS + "U"
endif
if type(".Backstyle")="N" and .backstyle = 0
cS= m.cS + "T"
endif
endwith
return m.cS
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform