Solved

Transparent form

Posted on 2002-04-11
9
209 Views
Last Modified: 2010-05-02
Hi to you all,

Does anybody know how I can make a form completly transparent. Without transparancy of the other objects in that form.
So that the buttons seems to be placed by theire own on the screen.

Thanks
0
Comment
Question by:theo kouwenhoven
9 Comments
 
LVL 2

Accepted Solution

by:
Ber earned 50 total points
Comment Utility
The following should do the job

In a Module Add the Following Declarations

Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_TRANSPARENT = &H20&
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_SHOWME = SWP_FRAMECHANGED Or _
SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_NOTOPMOST = -2

Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

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

'I placed this code behind a button for this example but
'It can be placed pretty much wherever you need it

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

Cheers...
Ber...
0
 
LVL 2

Expert Comment

by:Ber
Comment Utility
P.S. The ShowInTaskbar property should be set to False and the BorderStyle to 0-None

Cheers...
Ber...
0
 
LVL 16

Author Comment

by:theo kouwenhoven
Comment Utility
Hi Ber,

Nice trick, but not only the window is invisible but also all label-objects?

Why
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Cause labels are drawing objects not "real" objects and they are drawn in the same layer as form does.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Expert Comment

by:Ber
Comment Utility
This is not really a solution but it might help

Add a text box to the the form
set its properties to the following

Text1.Appearance = 0
Text1.BorderStyle = 0
Text1.BackColor = &H8000000F
Text1.Locked = True

this will look like a label and the user will not be able to type in it...

Cheers...
Ber...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Ber, it would be possible to hide caret with API stuff also.
0
 
LVL 2

Expert Comment

by:Ber
Comment Utility
Good point richie

To hide the caret use the following API

place the following in a module
Declare Function HideCaret Lib "user32" _
(ByVal hWnd as Long) As Long

Then set the Gotfocus event in the text Box as follows

Private Sub Text1_GotFocus()
HideCaret (Text1.hWnd)
End Sub
0
 
LVL 8

Expert Comment

by:glass_cookie
Comment Utility
Hi!

Here's a file for you ver the net:

Download...
http://www.vb-helper.com/HowTo/transimg.zip
Description: Make a "transparent" form (9K)

There' are controls on it to amke it look as if theys veen placed on a form.  Is that what you're looking for?

That's it!

glass scookie : )
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Hi murphey2 any progress/comment?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now