|
-
Aug 19th, 2009, 07:29 AM
#1
Thread Starter
Lively Member
[RESOLVED] Fully Transparent form
hi VB Forums
i have vb code for making a form transparent, but that code has got 1 problem- it with that code if u click in the form area it takes click to the window behind that form
here's the code im using:
Code:
Option Explicit
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _
ByVal hWnd As Long, _
ByVal crKey As Long, _
ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1&
Private Const LWA_ALPHA = &H2&
Private Sub Form_Load()
'Set the Form transparent by color.
BackColor = RGB(127, 127, 0) 'Unique but explicit (non-system) color.
SetWindowLong hWnd, _
GWL_EXSTYLE, _
GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes hWnd, BackColor, 0, LWA_COLORKEY
End Sub
so i want my form fully trans-parent but dont want any interactions with window behind it.....
if anybody have code then please post it here.
Thank you
Boing
-
Aug 19th, 2009, 08:02 AM
#2
Re: Fully Transparent form
If you are telling the O/S to make it transparent, it will click thru. Recommend trying the following modification. It is 99.9% transparent.
SetLayeredWindowAttributes hWnd, 0&, 1, LWA_ALPHA
FYI: This could be really annoying for someone if you lose track of the form or make it maximized. It's not visible, it may be overlapping other windows, the user can't click thru to them and has no idea why. Maybe you have more pure intentions.
Edited: Really no reason to assign a unique backcolor now. You just may want to make the form's backcolor white or black.
Last edited by LaVolpe; Aug 19th, 2009 at 08:13 AM.
-
Aug 19th, 2009, 08:13 AM
#3
Thread Starter
Lively Member
Re: Fully Transparent form
thank you very much LaVolpe, in actual i wanna give my program a cool effect by transperacy and also change activate the timer on click anywhere in the form, its smilar to poerpoint type presentation in which image will scroll on clicking anywhere...
-
Aug 19th, 2009, 08:16 AM
#4
Re: [RESOLVED] Fully Transparent form
I don't know if the above will work you giving your description, unless you plan on putting your animation under the transparent window. If the window is 99.9% transparent, so is any graphics on that window.
I actually used similar code to create a software screen filter/tinter. My wife complained the screen hurt her eyes, especially at night. So I used semi-transparency, with color options. Now she can choose the level of opacity and which color to overlap the entire screen. The big difference is the my project had to remain click-thru, so to close the screen filter or change options, a system tray icon is used.
-
Aug 19th, 2009, 08:44 AM
#5
Thread Starter
Lively Member
Re: [RESOLVED] Fully Transparent form
i will use multiple forms for that..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|