Transparent Form.... or not?

stijn koopal
02-11-2005, 01:49 PM
I got 2 forms in my project. The first one acts as some sort of Parent form. The second one I have made transparent, except for the controls. The transparent form will be shown on the fitst one. But now I got this problem, when I make a shape on my trans form and I make it rounded then I got this color around my shape, the color of the background of the trans form. Also when I create a label on my trans form and I make the background of that label transparent then the backcolor of the background is also show as backcolor of the label.
How can I make my form "really" transparent?

this is the code I'm using for my trans form.

Public Sub TransFrm(frm As Form)

Dim rgnForm As Long, rgnCombined As Long
Dim rgnControl As Long, x As Long
Dim formWidth As Single, formHeight As Single
Dim borderWidth As Single, titleHeight As Single
Dim ctlLeft As Single, ctlTop As Single
Dim ctlWidth As Single, ctlHeight As Single
Dim ctl As Control

With frm

borderWidth = (.Width - .ScaleWidth) / 2
titleHeight = .Height - .ScaleHeight - borderWidth

borderWidth = .ScaleX(borderWidth, vbTwips, vbPixels)
titleHeight = .ScaleY(titleHeight, vbTwips, vbPixels)
formWidth = .ScaleX(.Width, vbTwips, vbPixels)
formHeight = .ScaleY(.Height, vbTwips, vbPixels)

rgnForm = CreateRectRgn(0, 0, formWidth, formHeight)
rgnCombined = CreateRectRgn(0, 0, 0, 0)

x = CombineRgn(rgnCombined, rgnForm, rgnForm, RGN_DIFF)

For Each ctl In .Controls

If TypeOf ctl.Container Is Form Then
ctlLeft = .ScaleX(ctl.Left, vbTwips, vbPixels) + borderWidth
ctlTop = .ScaleX(ctl.Top, vbTwips, vbPixels) + titleHeight
ctlWidth = .ScaleX(ctl.Width, vbTwips, vbPixels) + ctlLeft
ctlHeight = .ScaleX(ctl.Height, vbTwips, vbPixels) + ctlTop
rgnControl = CreateRectRgn(ctlLeft, ctlTop, ctlWidth, ctlHeight)
x = CombineRgn(rgnCombined, rgnCombined, rgnControl, RGN_OR)
End If
Next ctl
' Set the clipping area of the window using the resulting region
SetWindowRgn .hWnd, rgnCombined, True
' Tidy up
x = DeleteObject(rgnCombined)
x = DeleteObject(rgnControl)
x = DeleteObject(rgnForm)
End With
End Sub

02-11-2005, 02:37 PM
Just a few threads down (at the moment) is this thread:

Check out my reply and the pages linked to.. :)

stijn koopal
02-11-2005, 04:15 PM
Whoow thanks man, that worked :D

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum