473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

VB6 Transparency

In VB6 , is it possible to have the form invisible but the things inside it visible?
Sep 14 '07 #1
8 11696
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 Expert 1GB
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
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
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 Expert 8TB
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
Set the form to invisible and the controls visible
Pre-Tried,Useless
Nothing found " Round forms";"Circular Forms"
Sep 15 '07 #7
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
Thank you
<:TOPIC SOLVED:>
Sep 16 '07 #9

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

Similar topics

2
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.