How to set transparent when window is inactive??? |
Post Reply |
Author | |
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
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 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
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 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
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 |
|
Mr.Den
Groupie Joined: 26 August 2007 Status: Offline Points: 50 |
Post Options
Thanks(0)
|
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 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
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 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1355 |
Post Options
Thanks(0)
|
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 |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |