Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Semi-transparent form - how?
Message
From
10/10/2002 07:53:18
Fabian Belo
Independent Developer
Argentina
 
 
To
10/10/2002 07:31:17
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00709749
Message ID:
00709759
Views:
18
Use Foxtools.fll like this:

FORM Init:
Set Library To Home() + "Foxtools.fll" ADDITIVE

** Declare API functions
Declare Integer CombineRgn in "gdi32" integer hDestRgn, integer hRgn1, integer hRgn2, integer nMode
Declare Integer CreateRectRgn in "gdi32"  integer X1, integer Y1, integer X2, integer Y2
Declare Integer SetWindowRgn in "user32" integer hwnd, integer hRgn, integer nRedraw

** Calling Method
This.SetTransparent()
FORM Resize:
** Call Method when resizing
THIS.SetTransparent()
FORM gethwndform (New Method)
** Returns form windows handle or identifier
Local lcOldCaption, lnHWND

With Thisform
	lcOldCaption = .Caption
	.Caption     = Sys(3)
	lnHWND       = _WhToHwnd(_WFindTitl(.Caption))
	.Caption     = lcOldCaption	
EndWith
	
Return lnHWND
FORM settransparent (New Method)
LOCAL lnControlBottom, ;
  	  lnControlRight, ;
	  lnControlLeft, ;
	  lnControlTop, ;
	  lnBorderWidth, ;
	  lnTitleHeight, ;
	  lnFormHeight, ;
	  lnFormWidth, ;
	  lnInnerRgn, ;
	  lnOuterRgn, ;
	  lnCombinedRgn, ;
	  lnControlRgn, ;
	  lnControl, ; 
	  lnRgnDiff, ;
	  lnRgnOr, ;
	  llTrue

** 
lnRgnDiff     =  4
lnRgnOr       =  2
llTrue        = -1

With Thisform
	** Setting border & title bar size
	lnBorderWidth =  3 
	lnTitleHeight = 23 

	** Getting widht & Height
	lnFormWidth   = (.Width + 1) + (lnBorderWidth * 2)
	lnFormHeight  =  .Height + lnTitleHeight + lnBorderWidth

	** Creating internal & external regions
	lnOuterRgn    =  CreateRectRgn(0, 0, lnFormWidth, lnFormHeight)
	lnInnerRgn    =  CreateRectRgn(lnBorderWidth, lnTitleHeight, ;
		 lnFormWidth - lnBorderWidth, lnFormHeight - lnBorderWidth)

	** Retrieving internal from external region
	lnCombinedRgn = CreateRectRgn(0, 0, 0, 0)
	CombineRgn(lnCombinedRgn, lnOuterRgn, lnInnerRgn, lnRgnDiff)

	** 
	For Each Control in .Controls
   		lnControlLeft   = Control.Left   + lnBorderWidth 
        	lnControlTop    = Control.Top    + lnTitleHeight
        	lnControlRight  = Control.Width  + lnControlLeft 
		lnControlBottom = Control.Height + lnControlTop
        	lnControlRgn    = CreateRectRgn(lnControlLeft, lnControlTop, ;
        				  lnControlRight, lnControlBottom)
        	CombineRgn(lnCombinedRgn, lnCombinedRgn, lnControlRgn, lnRgnOr)
	EndFor

	** Set window region
	SetWindowRgn(.GetHwndForm(), lnCombinedRgn, llTrue)
EndWith
>I'm trying to make my form semi-transparent using WinAPI SetLayeredWindowAttributes() (VFP6SP5,Win2000). When the form is "As Top-Level" (ShowWindow=2) this function works, otherwise (In Screen or In Top-Level form) - not. Why? Please, help!
>
"Since I've read that alcohol is bad... I quit reading."
Me


http://www.fabianbelo.com.ar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform