Page 1 of 1

transparent window

Posted: Fri Aug 26, 2011 8:13 pm
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

Re: transparent window

Posted: Fri Aug 26, 2011 9:23 pm
by IdeasVacuum

Re: transparent window

Posted: Sat Aug 27, 2011 3:49 pm
by Shardik

Re: transparent window

Posted: Sat Aug 27, 2011 6:36 pm
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

Re: transparent window

Posted: Sat Aug 27, 2011 11:48 pm
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 

Re: transparent window

Posted: Sun Aug 28, 2011 6:30 pm
by delikanli_19_82
thanks :-)