OK how can I make the form totally invisible but have the objects such as picture boxes and labels still visible on it.:cool:
Printable View
OK how can I make the form totally invisible but have the objects such as picture boxes and labels still visible on it.:cool:
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 PSCQuote:
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.
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.Quote:
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
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... :confused: :confused: 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 confuzingQuote:
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... :confused: :confused: 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?
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
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.
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 :cool:Quote:
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
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
lol thanxQuote:
Originally posted by seaweed
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
Actually thats not good enuff :mad: lolQuote:
Originally posted by duc
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 :cool:
All that does is make the Title Bar disappear. The app does appear after you move another window over it though.
:wave:
*bump*:mad: :o :) :rolleyes: :( :confused:
He only wants controls visible, so no form or nothing is shown. Just like floating controls
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?
Form = Not there
Buttons and images = there
;)
I guess....lol. I think thats what I want. So there is no form. But anything that i put on the form is visible.Quote:
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?
*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.
*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
Have you tried setting the BorderStyle to None? I think that works.Quote:
Originally posted by duc
Actually thats not good enuff :mad: lol
All that does is make the Title Bar disappear. The app does appear after you move another window over it though.
:wave:
I think that works. I will give it a try when I get back to my house. :wave:
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... :cool:
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 :)