[SOLVED] Transparent Window

Windows specific forum
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

[SOLVED] Transparent Window

Post by SkyManager »

Does anybody know how to set the window background color to be TRANSPARENT?
Last edited by SkyManager on Tue Feb 08, 2011 6:49 am, edited 1 time in total.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Transparent Window

Post by IdeasVacuum »

There is an API way: Set the Window Background to a specific colour and then set that colour as transparent.

Code: Select all

#WIN = 0

Procedure ShowWin()
;-------------------
If OpenWindow(#WIN, 0, 0, 300, 300, "Transparent Window",#PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)

              SetWindowColor(#WIN,#Blue)
              SetWindowLong_(WindowID(#WIN), #GWL_EXSTYLE, #WS_EX_LAYERED | #WS_EX_TOPMOST)
              SetLayeredWindowAttributes_(WindowID(#WIN),#Blue,0,#LWA_COLORKEY)

EndIf

EndProcedure

ShowWin()

Repeat
 
       iEvent.i = WaitWindowEvent(1)
 
Until iEvent = #PB_Event_CloseWindow
 
End
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Transparent Window

Post by dobro »

Thanks ! Excellent !! :D
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Re: Transparent Window

Post by SkyManager »

Thank you very much.
User avatar
Primus
New User
New User
Posts: 5
Joined: Mon Feb 07, 2011 5:08 pm
Location: Europe

Re: [SOLVED] Transparent Window

Post by Primus »

I'm using a code like that to create a transparent window, but I encountered a problem:

When hiding and un-hiding gadgets, the desktop shines through for the glimpse of a second.

It's just a short flash, but with a sufficient amount of gadgets, it becomes annoying. Besides, it doesn't look exactly professional if parts of your software suddenly disappear without an apparent reason :lol:

I already tried SmartWindowRefresh, but it doesn't do the trick.

Now, I know that hiding requires to redraw the window, but isn't there a way to do it without the abovementioned effect? For example, isn't it possible to create an additional layer which is excluded from the refreshing process?
User avatar
Primus
New User
New User
Posts: 5
Joined: Mon Feb 07, 2011 5:08 pm
Location: Europe

Re: [SOLVED] Transparent Window

Post by Primus »

Found a solution myself: I use a parent window that has the same background as the main window. That way, the background doesn't vanish if the gadgets of the main window are modified.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: [SOLVED] Transparent Window

Post by dobro »

[HS on]
on your avatar pretty Gardenia taitensis (Tiaré)
ia ora na ... ;)
[HS off]
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Nituvious
Addict
Addict
Posts: 1029
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: [SOLVED] Transparent Window

Post by Nituvious »

Primus wrote:I'm using a code like that to create a transparent window, but I encountered a problem:

When hiding and un-hiding gadgets, the desktop shines through for the glimpse of a second.

It's just a short flash, but with a sufficient amount of gadgets, it becomes annoying. Besides, it doesn't look exactly professional if parts of your software suddenly disappear without an apparent reason :lol:

I already tried SmartWindowRefresh, but it doesn't do the trick.

Now, I know that hiding requires to redraw the window, but isn't there a way to do it without the abovementioned effect? For example, isn't it possible to create an additional layer which is excluded from the refreshing process?
You can try creating a hidden window, creating your gadgets and then unhiding the window.
▓▓▓▓▓▒▒▒▒▒░░░░░
Post Reply