Print Page | Close Window

How to set transparent when window is inactive???

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=16086
Printed Date: 27 November 2024 at 12:35am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to set transparent when window is inactive???
Posted By: shipwreck
Subject: How to set transparent when window is inactive???
Date Posted: 27 January 2010 at 6:57am
Hello.

I am using the form extender control and would take full advantage of its transparency feature. What I would like to do is have active windows not transparent whatsoever (255), and the inactive windows or when they lose focus, to become transparent to a certain degree.

Is there a way to do this? And if there is, How would someone go about doing so??



Thanks and Regards in advance!

-------------
Product: Xtreme Suite Pro (Active-X), Version 15.3.1

Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit)

Language: Visual Basic 6.0 SP6



Replies:
Posted By: Aaron
Date Posted: 29 January 2010 at 2:39am
Hi,
 
You could use Form Activate and Deactivate event and set desired transparency. I tried it myself but sometimes form will loose it transparency entirely and only showing a "grayish shadow" and after resizing form repaints itself and everything is back to normal. Don't know why but is does...
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: Aaron
Date Posted: 29 January 2010 at 3:27am
Hi,
 
I tried again and it seems that DockingPanes is causing this behaviour. If you click on one of the pane captions the form is grayed. Clicking somewhere else on other form seems to work fine.
 
Maybe CJ has an explanation for this?
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: shipwreck
Date Posted: 29 January 2010 at 5:47am
Hopefully they would. But if they don't I understand why. Most applications don't function like that anyhow. But I think I've actually tried using that and I couldn't get it to actually do anything. I was putting "formextender.transparency = 150" in the deactivate and "formextender.transparency = 255" and it was as if I never put any code there for some reason. Is there a better way to do this?

-------------
Product: Xtreme Suite Pro (Active-X), Version 15.3.1

Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit)

Language: Visual Basic 6.0 SP6


Posted By: Aaron
Date Posted: 29 January 2010 at 7:35am
Hi,
 
Did you try again? It really does work with code in activate and deactivate event.
 
If you have DockingPanes and you click on PaneCaption it doesn't anymore
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: shipwreck
Date Posted: 29 January 2010 at 7:53am
Hey Aaron, I just tried it and it still doesn't seem to work for me.
Under the form_deactivate I have "FE.transparency = 150" and under form_activate I have "FE.transparency = 255" and when I run the app its as if I never put the code there to start with.

-------------
Product: Xtreme Suite Pro (Active-X), Version 15.3.1

Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit)

Language: Visual Basic 6.0 SP6


Posted By: Mr.Den
Date Posted: 29 January 2010 at 11:12am
Just for kicks to see if it works, put this in a module:
 
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2
 
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
   
Public Function TransForm(Form As Form, TransLevel As Byte) As Boolean
 
On Error Resume Next
   
    SetWindowLong Form.hwnd, GWL_EXSTYLE, WS_EX_LAYERED
    SetLayeredWindowAttributes Form.hwnd, 0, TransLevel, LWA_ALPHA
   
    TransForm = Err.LastDllError = 0
   
End Function
 
And call it from a form like this:
 
TransForm Me, 1
 
That should make your form transparent.
 
TransForm Me, 255
 
To reverse the transparency
 
If it barks at you, pass the number as a byte: CByte(255)
 


-------------
Product: Xtreme SuitePro (ActiveX) version 16.3.1

Platform: Windows 7 Professional (64bit) - SP 1

Language: Visual Basic 6.0 SP 6


Posted By: Aaron
Date Posted: 29 January 2010 at 12:47pm
Hi,
 
Here's is test project that should work.
 
https://forum.codejock.com/uploads/20100129_124724_Transparency.zip - uploads/20100129_124724_Transparency.zip  


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: shipwreck
Date Posted: 29 January 2010 at 1:10pm
Mr.Den, that's great code but I prefer to use the transparency feature built into the Form Extender control.

Aaron, your sample works great. But I found out why it wasn't working for me. You see, your sample launches multiple forms and then makes the inactive forms transparent. My idea was to basically have one form, and when the user selects another window to be active, it would then turn transparent as well. Your sample does this but only with the forms you have created rather than all forms the user may be using. Would you know how to do it this way as well?

-------------
Product: Xtreme Suite Pro (Active-X), Version 15.3.1

Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit)

Language: Visual Basic 6.0 SP6


Posted By: jpbro
Date Posted: 29 January 2010 at 1:47pm
You need to subclass VB6 forms to catch activation/deactivation from/to different applications. The Form_Activate/Deactivate events only work for forms in your own app.

See the AppGotFocus and AppLostFocus events in the code in this thread:
http://forum.codejock.com/forum_posts.asp?TID=13008&PID=43883#43883 - http://forum.codejock.com/forum_posts.asp?TID=13008&PID=43883#43883


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: shipwreck
Date Posted: 29 January 2010 at 7:31pm
Well, I've actually found a way to do it when the mouse leaves the window and I consider it to be more functional either way at this moment. Thanks for the advice guys, I'll close this one for now. :]

-------------
Product: Xtreme Suite Pro (Active-X), Version 15.3.1

Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit)

Language: Visual Basic 6.0 SP6



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net