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
 To: Bernard Bout
  Where is Bernard Bout?
 Bernard Bout
Subject: RE: Bernard Bout's LightBox Class
Thread ID: 416384 Message ID: 416477 # Views: 50 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Classes and Objects
Date: Tuesday, December 30, 2014 5:17:18 AM         

> 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.
> Bernard
> ** If you see someone without a smile, give em one of yours **
> My Blog

I tried your sample SCX that is included with the original ZIP version 6 (I believe this is the last version). Change your sample SCX's BorderStyle=2. Now run the form and try the activating the LightBox -- your form will be "blacked out" with no controls being shown (at least this occurs on my system). Now change the BorderStyle to any value other than 2. Now the LightBox class will "black out" as expected and show the controls. The problem is how the capture is being performed and repainted; something about the Form being BorderStyle=2 is causing the image control capture/cut/repaint to not work as expected.

However, if you only pass the hWnd value to the method:

this.CaptureBmp = _Screen.System.Drawing.Bitmap.FromScreen(thisform.HWnd)

Then the form's image is captured and displayed (as shown in my first post). I suspect that it has something to do with the BeforeDraw code and the form being BorderStyle=2 that the Draw is doing something different. An even simpler fix than setting the max/min properties is to set the BorderStyle=1 (thin fixed border) and the capture will work as expected and trim the title bar and borders leaving only the grayed out controls.


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