transparent window

Everything else that doesn't fall into one of the other PB categories.
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

transparent window

Post by delikanli_19_82 »

hello guys,

i need a way to make a window fully transparent, while i can choose the operciy intensity of the window on windows, linux and mac. i know that this is only doable by os-api.

have someone any idea, how to realize that?

kind regards

kurt
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 »

IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Shardik
Addict
Addict
Posts: 2079
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: transparent window

Post by Shardik »

delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Re: transparent window

Post by delikanli_19_82 »

hello guys,

i asked the same question in the german forum. there is a well solution for windows:

Code: Select all

Procedure.i SetWindowTransparency(Window.i, transparency.i) ; Fenster durchsichtig machen (transparency : 0-255)
  
  If IsWindow(Window)
    Protected WindowID = WindowID(Window)
    SetWindowLongPtr_(WindowID,#GWL_EXSTYLE,#WS_EX_LAYERED)
    SetLayeredWindowAttributes_(WindowID,0,transparency,#LWA_ALPHA)
  EndIf

EndProcedure

OpenWindow( 100, 0, 0, 300, 300, "Test", #PB_Window_ScreenCentered )

SetWindowTransparency( 100, 220 )

Define e.l

Repeat
  
  e = WaitWindowEvent()
  
Until e = #PB_Event_CloseWindow
original thread http://forums.purebasic.com/german/view ... 54711ba1e2

the mac-solution from shardik is the same on os x. thanks.

now i need a way to realize it also on linux.

kurt
User avatar
idle
Always Here
Always Here
Posts: 6238
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: transparent window

Post by idle »

linux

Code: Select all

ImportC "-gtk" 
  gtk_window_set_opacity(*window.i,opacity.d);
  gtk_widget_is_composited (*widget)
EndImport  
win = OpenWindow(#PB_Any,0,0,200,200,"test")

If gtk_widget_is_composited (WindowID(win))
 gtk_window_set_opacity(WindowID(win), 0.5);
EndIf 

 Repeat 
   ev=WaitWindowEvent()  
 Until  ev = #PB_Event_CloseWindow 
Windows 11, Manjaro, Raspberry Pi OS
Image
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Re: transparent window

Post by delikanli_19_82 »

thanks :-)
Post Reply