Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Bernard Bout
  Where is Bernard Bout?
 Bernard Bout
 To: Greg Green
  Where is Greg Green?
 Georgia - United States
 Greg Green
Subject: RE: Bernard Bout's LightBox Class
Thread ID: 416384 Message ID: 416473 # Views: 60 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Classes and Objects
Date: Tuesday, December 30, 2014 3:19:59 AM         

> The Lightbox class generates the GDI image via the following call:
> this.CaptureBmp = _Screen.System.Drawing.Bitmap.FromScreen(thisform.HWnd, lnLeftBorder, lnTopBorder+lnTitleHeight, thisform.Width, thisform.Height)

> However, if I change the above code to:
> this.CaptureBmp = _Screen.System.Drawing.Bitmap.FromScreen(thisform.HWnd)

> The form's image is properly captured as shown (but includes the form's header) as shown:
> Not sure why the difference in the capture and display -- why does the full form capture correctly but not the one of the active area of the form? The parent's LightBox class correctly captures the area's image.
> Any suggestions -- I have tried to debug and not found anything unexpected. The values for lnLeftBorder, lnTopBorder, and lnTitleHeight are valid reasonable values. Internally it appears that the full form is being captured in both cases, but it is the trimming when the boundary values are included that the form becomes all gray.
> *********************
> I have found that if I set the child form's property to BorderStyle=3 (Sizable) instead of BorderStyle=2 (Fixed) that the form's image is captured properly. So it seems that the GDI will not capture a form with a BorderStyle=2 (have not tried a value of 1). The form is not to be resized; I can control this via the MaxWidth, MaxHeight, MinWidth, and MinHeight property values all set to the same value as Height and Width. This is a work-around, but does someone know how to fix the GDI image capture and clip? It does work to capture the full form (BorderStyle=2) when only the form's handle is passed as a parameter (image 3 above), so I would think it would work for a selected area in the form.

The source code, which is included, is :

lnTitleHeight = IIF(ThisForm.TitleBar = 1,Sysmetric(9),0)
	lnLeftBorder = IIF(ThisForm.BorderStyle < 2,0,Sysmetric(3))
	lnTopBorder = IIF(ThisForm.BorderStyle < 2,0,Sysmetric(4))

Basically, .Bitmap.FromScreen() will capture the complete form. including the titlebar and borders, if ONLY the hWnd is passed in. This includes the Titlebar, the left & right borders, and the top & bottom borders. To simulate the correct size the above code uses SYSMETRIC() to calculate this and if you have borders and titlebar, it resizes the capture rectangle.

If, for instance, you wanted a lightbox for a form with NO titlebar, say using Jun's form skinner class, then obviously you would need to change the code so that you could pass in the correct dimensions, sans the height of your custom titlebar, as the class has no way of knowing this.

Having the code makes this easy as you can just subclass the class and override the code with your own.


** If you see someone without a smile, give em one of yours **
My Blog


Bernard Bout's LightBox Class Posted by Greg Green @ 12/28/2014 11:19:30 PM
RE: Bernard Bout's LightBox Class Posted by fedison72 fernando @ 12/29/2014 5:33:56 PM
RE: Bernard Bout's LightBox Class Posted by Greg Green @ 12/29/2014 6:42:42 PM
RE: Bernard Bout's LightBox Class Posted by Bernard Bout @ 12/30/2014 3:19:59 AM
RE: Bernard Bout's LightBox Class Posted by Greg Green @ 12/30/2014 5:17:18 AM