|
-
Apr 2nd, 2003, 05:43 PM
#1
Thread Starter
Fanatic Member
Invisible Form BUT...
OK how can I make the form totally invisible but have the objects such as picture boxes and labels still visible on it.
-
Apr 2nd, 2003, 05:45 PM
#2
Frenzied Member
It's called transparency and it's a very difficult thing to accomplish in VB. You may search Google.com or planetsoursecode.com for ready to go samples.
-
Apr 2nd, 2003, 05:47 PM
#3
Thread Starter
Fanatic Member
Originally posted by McGenius
It's called transparency and it's a very difficult thing to accomplish in VB. You may search Google.com or planetsoursecode.com for ready to go samples.
Oh! Transparency does make the form totally invisible? I thot it just made it see through.... well anyway im gonna go check PSC
-
Apr 2nd, 2003, 05:51 PM
#4
Thread Starter
Fanatic Member
Originally posted by duc
Oh! Transparency does make the form totally invisible? I thot it just made it see through.... well anyway im gonna go check PSC
Well I found an example and I was right. It only makes it transparent. I want the FORM totally invisible but the objects such as pics and labels not invisible.
-
Apr 2nd, 2003, 05:58 PM
#5
Clue me in.... I don't get it.... you want the form invisible, but not transparent.... but yet you want objects on the form visible... can you show an example? The way I read it is that you want the back ground of the formto show through so that the objects on the form appear to float over what ever is behind it it.... is that not what you want?
-
Apr 2nd, 2003, 06:27 PM
#6
Thread Starter
Fanatic Member
Originally posted by techgnome
Clue me in.... I don't get it.... you want the form invisible, but not transparent.... but yet you want objects on the form visible... can you show an example? The way I read it is that you want the back ground of the formto show through so that the objects on the form appear to float over what ever is behind it it.... is that not what you want?
OK, my plan is to make the form totally invisible but the picture boxes and labels visible. The reason I am doing this is becasue im to lazy to learn how to shape forms so I thought I would just draw my own form in PhotoShop and put it into VB. :-p confuzing
-
Apr 2nd, 2003, 07:06 PM
#7
Frenzied Member
Try this:
VB Code:
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TRANSPARENT = &H20&
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_SHOWME = SWP_FRAMECHANGED Or _
SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_NOTOPMOST = -2
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter _
As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Sub Command1_Click()
SetWindowLong Me.hwnd, GWL_EXSTYLE, _
WS_EX_TRANSPARENT
SetWindowPos Me.hwnd, HWND_NOTOPMOST, _
0&, 0&, 0&, 0&, SWP_SHOWME
End Sub
Last edited by seaweed; Apr 2nd, 2003 at 07:09 PM.
~seaweed
-
Apr 2nd, 2003, 08:35 PM
#8
Hyperactive Member
In the 2 cents department....
I experimented with transparent forms to display microscope images (code almost identical to Seaweed's - it is btw exactly what you asked for), but man is it quirky.
You can paint on the transparent form, the controls are visible, but its a bear trying to keep it transparent.
You might be better off shaping the form.www.vbwm.com had a pretty good tutorial on doing it.
-
Apr 2nd, 2003, 10:27 PM
#9
Thread Starter
Fanatic Member
Originally posted by seaweed
Try this:
VB Code:
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TRANSPARENT = &H20&
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_SHOWME = SWP_FRAMECHANGED Or _
SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_NOTOPMOST = -2
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter _
As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Sub Command1_Click()
SetWindowLong Me.hwnd, GWL_EXSTYLE, _
WS_EX_TRANSPARENT
SetWindowPos Me.hwnd, HWND_NOTOPMOST, _
0&, 0&, 0&, 0&, SWP_SHOWME
End Sub
Works perfctly! THX! But for some reason the form still looks like its their unless u move anothers programs form over it and then it disappears. But good enuff
-
Apr 4th, 2003, 03:42 PM
#10
Frenzied Member
Take a look at this site...it shows you how to make an irregular shaped form, including putting holes in it!
http://www.thescarms.com/vbasic/IrregularForms.asp
-
Apr 5th, 2003, 12:37 AM
#11
Thread Starter
Fanatic Member
-
Nov 8th, 2003, 07:15 PM
#12
Thread Starter
Fanatic Member
-
Nov 10th, 2003, 03:35 PM
#13
Thread Starter
Fanatic Member
-
Nov 10th, 2003, 03:54 PM
#14
Supreme User
He only wants controls visible, so no form or nothing is shown. Just like floating controls
-
Nov 10th, 2003, 03:59 PM
#15
Hyperactive Member
You want a hole in the form but the form is covered by the entire hole (which is you can click stuff behind it as if it wasn't there) right?
53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.

-
Nov 10th, 2003, 04:03 PM
#16
Thread Starter
Fanatic Member
Form = Not there
Buttons and images = there
-
Nov 10th, 2003, 04:04 PM
#17
Thread Starter
Fanatic Member
Originally posted by Q_Me
You want a hole in the form but the form is covered by the entire hole (which is you can click stuff behind it as if it wasn't there) right?
I guess....lol. I think thats what I want. So there is no form. But anything that i put on the form is visible.
-
Nov 13th, 2003, 11:03 AM
#18
Hyperactive Member
*Ponders*
hmmmmm....
Anybody got a code to wrap the hole around the buttons? I know that one is out there, they make smiley faces with those iregular forms, I'm sure there's a way to wrap it arround each object.
53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.

-
Dec 20th, 2003, 02:41 PM
#19
Thread Starter
Fanatic Member
*big bump*
I want to be able to put buttons and images on the form but when the program starts, you dont see the form, all you see is the buttons and graphics placed on top of it. thanks!!1 This mustve been the 93rd time i described it lol
-duc
Last edited by duc; Dec 20th, 2003 at 02:44 PM.
-
Dec 20th, 2003, 02:44 PM
#20
Originally posted by duc
Actually thats not good enuff lol
All that does is make the Title Bar disappear. The app does appear after you move another window over it though.
Have you tried setting the BorderStyle to None? I think that works.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 20th, 2003, 02:47 PM
#21
Thread Starter
Fanatic Member
I think that works. I will give it a try when I get back to my house.
-
Dec 21st, 2003, 08:46 AM
#22
Fanatic Member
Here's code for a completely transparent form containing a textbox and 2 command buttons:
VB Code:
Option Explicit
Private Declare Function CreateRectRgn Lib _
"gdi32" (ByVal X1 As Long, ByVal Y1 As Long, _
ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib _
"gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, _
ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function SetWindowRgn Lib _
"user32" (ByVal hWnd As Long, ByVal hRgn As Long, _
ByVal bRedraw As Boolean) As Long
Private Declare Function DeleteObject Lib _
"gdi32" (ByVal hObject As Long) As Long
' Constants used by the CombineRgn function
Private Const RGN_AND = 1
Private Const RGN_OR = 2
Private Const RGN_XOR = 3
Private Const RGN_DIFF = 4
Private Const RGN_COPY = 5
Private Sub Form_Activate()
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
' Calculate the form area
borderWidth = (Me.Width - Me.ScaleWidth) / 2
titleHeight = Me.Height - Me.ScaleHeight - borderWidth
' Convert to Pixels
borderWidth = ScaleX(borderWidth, vbTwips, vbPixels)
titleHeight = ScaleY(titleHeight, vbTwips, vbPixels)
formWidth = ScaleX(Me.Width, vbTwips, vbPixels)
formHeight = ScaleY(Me.Height, vbTwips, vbPixels)
' Create a region for the whole form
rgnForm = CreateRectRgn(0, 0, formWidth, formHeight)
rgnCombined = CreateRectRgn(0, 0, 0, 0)
' Make the graphical area transparent by combining the two regions
x = CombineRgn(rgnCombined, rgnForm, rgnForm, RGN_DIFF)
' Make the controls visible
For Each ctl In Controls
' Make the regions of controls whose container is the form visible
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 Sub
Private Sub Command2_Click()
Unload Me
End Sub
...only wish I could remember where I got this to give proper credit...
Do canibals not eat clowns because they taste funny? 
-
Dec 22nd, 2003, 01:14 PM
#23
Thread Starter
Fanatic Member
Soooo close. When I add an imagebox or picturebox the the form the form becomes visible again. Also how can I make the background of a picturbox transparent. Thx.
-duc
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|