Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Transparent form

Posted on 2002-04-11
9
212 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

860 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