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

I have been using Bernard Bout's LightBox class with several of my projects. I have found it to be a very useful class (see link http://weblogs.foxite.com/bernardbout/2009/09/21/the-fastest-lightbox-ever) for displaying child forms as modeless but allows me to prevent the user from selecting the parent form. I place the LightBox class on the parent form and active the class when calling a modeless child form. This gives the appearance of the parent form as in-active. In the MouseDown event of the LightBox class I redirect the user back to the child form.

The above process works very well as seen in the first image:

The parent is a In-Top-Level form that is positioned as a MDI form in the program's Top-Level form. This allows the user to select another unrelated form but keeps the child's parent form from being selected. Now when the child form spans another child form (grand-child of the parent), I again use the LightBox class as an object on the child form. However, the form's image capture is all grey (being alpha-blended) as shown:

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.


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