Hi All,
Please advice how to measure the 'Width' and 'Height' of
an image, so that I can display always in the midle of the
screen whatever setting of the screen ( by getting WROW()
and WCOL() function. )

Thanks for your advices
Hidayat

Re: How to measure an image width/height by Eric

Eric
Wed Dec 31 02:06:39 CST 2003

Hello, Hidayat!
You wrote on Tue, 30 Dec 2003 19:52:53 -0800:

H> Hi All,
H> Please advice how to measure the 'Width' and 'Height' of
H> an image, so that I can display always in the midle of the
H> screen whatever setting of the screen ( by getting WROW()
H> and WCOL() function. )

Here's two ways:
<vfp_code>
* 1:
oPic = LOADPICTURE(GETPICT())
?oPic.Height
?oPic.Width
* 2:
LOCAL loImage
loImage = CREATEOBJECT("Image")
loImage.picture = GETPICT()
loImage.stretch = 0 &&Clip
?loImage.width
?loImage.height
</vfp_code>

Here's code to keep the image in the center of the screen, even when the
_screen is resized. In VFP8, you need to use BINDEVENTS() to respond to
_screen resize events.
<vfp_code>
_screen.addobject("oSH","ScreenHook")
_screen.addobject("oImage", "Image")
WITH _screen.oImage
.picture = GETPICT()
.stretch = 0
.left = (_screen.width 2) - (.width 2)
.top = (_screen.height 2) - (.height 2)
.visible = .T.
ENDWITH

*
* ScreenMethods.PRG
*
* Fred Taylor - ElZorro 4/10/2001 www.elzorro.org
*
* with thanks to "Michel Roy" <roym@jonar.com> from the
* News Group microsoft.public.fox.programmer.exchange
* Subject: Re: Centering Picture in _SCREEN ( or modifying _SCREEN
* Methods )
* Use the following to modify _SCREEN methods:
*
* For VFP6 & 7:
*
* _SCREEN.NewObject("oSH","ScreenHook","screenmethods.prg")
*
* For VFP3 & 5:
*
* SET PROCEDURE TO screenmethods ADDITIVE
* _SCREEN.AddObject("oSH","ScreenHook")
*
* Any of the main VFP screen methods can be hooked into in this manner.
*
DEFINE CLASS ScreenHook AS CUSTOM
oScr = _SCREEN
PROCEDURE oScr.Resize()
*
* Code to handle the main VFP screen being resized
*
WITH this.oImage
.left = (_screen.width 2) - (.width 2)
.top = (_screen.height 2) - (.height 2)
ENDWITH
ENDPROC
PROCEDURE oScr.RightClick
*
* Code to do a "shortcut" menu on main VFP screen RightClick
*
DO testmenu.mpr
ENDPROC
*
* Custom methods work, too.
*
PROCEDURE oScr.MyMethod
wait window "my method fired!"
ENDPROC
ENDDEFINE
</vfp_code>
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8