Solved

Transparent form

Posted on 2002-04-11
9
210 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
ID: 6935382
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
ID: 6935411
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
ID: 6937250
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
ID: 6938450
Cause labels are drawing objects not "real" objects and they are drawn in the same layer as form does.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:Ber
ID: 6938909
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
ID: 6939031
Ber, it would be possible to hide caret with API stuff also.
0
 
LVL 2

Expert Comment

by:Ber
ID: 6940340
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
ID: 6941243
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
ID: 6948933
Hi murphey2 any progress/comment?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

863 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

17 Experts available now in Live!

Get 1:1 Help Now