Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A Zoom Effect - Need some graphics advice
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01391293
Message ID:
01392062
Views:
105
This message has been marked as the solution to the initial question of the thread.
>Sergey, I had a chance to look at Bernard's Zoombar class. It's composed of ZoomImage objects which can work independently of the zoombar. That's really cool - I should be able drive the zoom effect with a little work.
>
>The only piece I need now is hot to use GDI+ to grab a snapshot of the button and turn it into a PNG so that the zoom has a file to work with for the zoom. Seems to me Bernard may have done that before too.
>
>Thanks again,
>
>-m@
Hi Mathew.

1) As you have said you can actually use a single control from my class and it does ZOOM with animation rather than just going from small to big in one jerky shot. It was becuse of this deficiency in the other ZoomBar, that copies the windows bubblebar, that I came up with this class from scratch that can provide smooth variable zooming which even a timer cannot provide.

2) To save an image of any control on a form you add a method like this to the form and call it, passing the control
LPARAMETERS toControl
* used GDI+x 
Do Locfile("System.App")
Local loCaptureBmp As xfcBitmap
Local lnTitleHeight, lnLeftBorder, lnTopBorder, lcImage, loImage
lnTitleHeight = Sysmetric(9)
lnLeftBorder = Sysmetric(3)
lnTopBorder = Sysmetric(4)
* grab the image
With _Screen.System.Drawing
	loCaptureBmp = .Bitmap.FromScreen(Thisform.HWnd,;
		toControl.Left+lnLeftBorder,;
		toControl.Top + lnTopBorder+lnTitleHeight,;
		toControl.Width,;
		toControl.Height)

	* and save it
	loCaptureBmp.Save("MyControl.png", _Screen.System.Drawing.Imaging.ImageFormat.Png)
Endwith
3) Now with regard to resizing the form, that is not necessary. There is a trick you can use to get that effect.

It will be difficult to describe here but I will try.
Imagine a form with an image control in the middle. Form has no titlebar and no border and has a BackColour = RGB(255,0,255) - Magenta.

The picture of the image control is the picture of a smaller form such that its size never exceeds the larger form. On top of this you place your image you want to zoom. It can now appear to be zoomed outside the "form", if you get my drift.

Now what you do is use the API to make the Magenta part full transparent. This will give the effect of hiding the larger form while showing only the smaller form image and your zooming image. In fact I have used this to make an animation of fish swimming on my desktop, by maximizing the mainform, hiding it as above and now I have the complete desktop to move my objects while showing the background "through" the form.

To make the Magenta part invisible have this code in the form.Init
This.BackColor = RGB(255,0,255)		&& magenta
THis.Transparentcolor = This.BackColor
THis.BorderStyle = 0
#DEFINE LWA_COLORKEY 1 
#DEFINE LWA_ALPHA 2 
#DEFINE GWL_EXSTYLE -20 
#DEFINE WS_EX_LAYERED 0x80000 
Declare Integer GetWindowLong In user32;
	INTEGER HWnd, Integer nIndex

Declare Integer SetWindowLong In user32;
	INTEGER HWnd, Integer nIndex, Integer dwNewLong

Declare Integer SetLayeredWindowAttributes In user32;
	INTEGER HWnd, Integer crKey,;
	SHORT bAlpha, Integer dwFlags
nExStyle = GetWindowLong(This.HWnd, GWL_EXSTYLE)
nExStyle = Bitor(nExStyle, WS_EX_LAYERED)
= SetWindowLong(This.HWnd, GWL_EXSTYLE, nExStyle)
nRgb = ThisForm.transparentcolor
nAlpha =  0
nFlags = LWA_COLORKEY
= SetLayeredWindowAttributes(This.HWnd, m.nRgb,;
	m.nAlpha, m.nFlags)
So now the tobezoomed image can be sized as tall and wide as the "hidden form". Because the image of the smaller form is visible, it appears that your image has zoomed out of its form.

Note the Large form must have ShowWindow = 2


Hope this all makes sense, otherwise please say so and I will post an example on my blog.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform