473,503 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB6 Transparency

21 New Member
In VB6 , is it possible to have the form invisible but the things inside it visible?
Sep 14 '07 #1
8 11712
VBPhilly
95 New Member
In VB6 , is it possible to have the form invisible but the things inside it visible?
You have to use windows api in VB6:

Declarations:
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  2. Private Declare Function SetWindowLong Lib "user32"  Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long,  ByVal dwNewLong As Long) As Long
  3. Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
  4. Private Const GWL_EXSTYLE = (-20)
  5. Private Const WS_EX_LAYERED = &H80000
  6. Private Const LWA_ALPHA = &H2&
  7.  
Using the api:
Expand|Select|Wrap|Line Numbers
  1.  Dim bytOpacity As Byte       'Set the transparency level    
  2. bytOpacity = 128    
  3. Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)    
  4. Call SetLayeredWindowAttributes(Me.hwnd, 0, bytOpacity, LWA_ALPHA)
  5.  

finally, restoring the windows opacity;

Expand|Select|Wrap|Line Numbers
  1.  Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) And (Not WS_EX_LAYERED))
  2.  
Reference: http://articles.techrepublic.com.com...-5031805.html#
Sep 14 '07 #2
kadghar
1,295 Recognized Expert Top Contributor
You have to use windows api in VB6:

Declarations:
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  2. Private Declare Function SetWindowLong Lib "user32"  Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long,  ByVal dwNewLong As Long) As Long
  3. Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
  4. Private Const GWL_EXSTYLE = (-20)
  5. Private Const WS_EX_LAYERED = &H80000
  6. Private Const LWA_ALPHA = &H2&
  7.  
Using the api:
Expand|Select|Wrap|Line Numbers
  1.  Dim bytOpacity As Byte       'Set the transparency level    
  2. bytOpacity = 128    
  3. Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)    
  4. Call SetLayeredWindowAttributes(Me.hwnd, 0, bytOpacity, LWA_ALPHA)
  5.  

finally, restoring the windows opacity;

Expand|Select|Wrap|Line Numbers
  1.  Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) And (Not WS_EX_LAYERED))
  2.  
Reference: http://articles.techrepublic.com.com...-5031805.html#
I've used that method before, but is it possible to make the Form transparente while the controls in it are not?
That'll be really cool
Sep 14 '07 #3
VBPhilly
95 New Member
I've used that method before, but is it possible to make the Form transparente while the controls in it are not?
That'll be really cool
I see what you mean. That would be cool.

I dont know of any quick way.

Although, if your desktop is black, you could simply make your form black.

Another idea is to make your visible controls become forms themselves (make the form borderless and the same size as the visible control) and layer them on top of the transparent form. Thats alot of form tracking though.

Anyway, good luck with it.
Sep 14 '07 #4
aviraldg
21 New Member
Thanks guys ,but
1) I'd tried the Control-is-a-form method before posting here...But what if you have a circle shape?I Doubt you can have circular forms...
2) I'll try the API Functions Later...
3) <Not Related : How do you add bytes?>
Sep 14 '07 #5
Killer42
8,435 Recognized Expert Expert
1) I'd tried the Control-is-a-form method before posting here...But what if you have a circle shape?I Doubt you can have circular forms...
I think you can. I've seen a demo of a circular clock or something, which was done just to show off differently-shaped windows. Try a quick search for expressions like "round clock". It may have even been mentioned previously on TheScripts, so you can try our search box up the top.

2) I'll try the API Functions Later...
3) <Not Related : How do you add bytes?>
To what?

By the way, one way you might be able to simulate a transparent form is by taking a snapshot of the screen before displaying your form (standard stuff when writing a screensaver) then paint that picture (appropriately positioned) onto your form.

Oh, one other thing. I didn't read the code form that link (don't have time) but is it possible that it could be applied to one or more controls? That is, set the form to transparent, then set control(s) to non-transparent?
Sep 15 '07 #6
aviraldg
21 New Member
Set the form to invisible and the controls visible
Pre-Tried,Useless
Nothing found " Round forms";"Circular Forms"
Sep 15 '07 #7
VBPhilly
95 New Member
Pre-Tried,Useless
Nothing found " Round forms";"Circular Forms"
Good old irregular shaped forms.
check out this link:
http://www.thescarms.com/VBasic/IrregularForms.aspx
Sep 15 '07 #8
aviraldg
21 New Member
Thank you
<:TOPIC SOLVED:>
Sep 16 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5650
by: Cecile Muller | last post by:
I've been trying to just open a png and display it, that way: <? header ("Content-type: image/png"); $im = imagecreatefrompng('empty.png'); imagepng($im); ?> But the transparency is not...
57
3899
by: Piotr Wolski | last post by:
how to make my page that it was correct with every browser standard? for example when i change HTML's table size it has no effect when i see it under mozilla and has effect under Internet...
4
3298
by: Matthias Czapla | last post by:
Hi! I want to resize uploaded GIF images. Currently I do it like this: <?php // ... $img = imagecreatefromgif($path); $img_scaled = imagecreate($new_width, $new_height);...
2
4843
by: Robin Becker | last post by:
Has anyone done transparency with PIL & TIFF? I'm using PIL to generate a preview TIFF for embedding into an eps file and am being asked for the TIFF to support transparency. -- Robin Becker
3
3847
by: Mr. x | last post by:
Hello, I would like that my image's background color will be transparent. What I have is only paintbrush. My image is *.jpg format (I have tried to save it as *.gif format, and I got less...
20
4471
by: Nathan Sokalski | last post by:
I am trying to create graphics with GDI+ that include transparency. However, the transparency never seems to show up, even though my colors have an alpha value of 0. How can I generate a graphic...
6
3643
by: tommaso.gastaldi | last post by:
In a previous post I have been asking about a way to test Alpha Transparency. Bob and Michael have kindly provided some ideas. Here I would like to share the function I have prepared, for the...
0
1291
by: ZikO | last post by:
Hi. I've experienced one problem. Im using three froms. Two of them are maximized, whereas one is normal form with transparency. Transparency stops working, that is I can see the color which...
1
2695
by: dragze | last post by:
Hi, On one of the pages of my site i use two javascripts, one makes transparency of png's work in IE, and the other embeds a flash player. Now use one of the scripts it works fine, use both and...
3
4199
by: Martijn Mulder | last post by:
When I populate a ToolStrip with ToolStripButtons with a .png-image on it, will Windows understand the transparency of the .png file?
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.