Page 1 of 1

Transparent window in pb4

Posted: Tue Sep 19, 2006 9:41 am
by karu
How i can do that so window is full transparent but gadgets are not

Karu

Posted: Tue Sep 19, 2006 11:58 am
by netmaestro
This'll work, I supplied methods to move and close the window, but you're certainly free to use your own imagination to accomplish those tasks:

Code: Select all

OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_BorderLess) 
SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_LAYERED) 
SetLayeredWindowAttributes_(WindowID(0),RGB(255,0,255),0,#LWA_COLORKEY) 
SetWindowColor(0,RGB(255,0,255)) 
CreateGadgetList(WindowID(0)) 
ButtonGadget(0,300,0,20,20,"X") 
StickyWindow(0,1) 

CreateImage(0,32,32) 
StartDrawing(ImageOutput(0)) 
  Box(0,0,32,32,RGB(255,0,255)) 
  Box(12,0,6,32,0) 
  Box(0,12,32,6,0) 
StopDrawing() 

ImageGadget(1,0,0,0,0,ImageID(0)) 
DisableGadget(1,1) 

quit = 0 
Repeat 
  ev = WaitWindowEvent() 
  Select ev 
    Case #WM_LBUTTONDOWN 
      SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN,#HTCAPTION,0) 
    Case #PB_Event_Gadget 
      If EventGadget()=0 
        quit = 1 
      EndIf 
  EndSelect 
Until quit 
If you're going to put image gadget(s) on there to make a skin, remember to disable them so they aren't firing events.

For Win 9x you can use region clipping to accomplish a similar result but it's more work.

Posted: Tue Sep 19, 2006 1:40 pm
by karu
Thanks

Posted: Tue Sep 19, 2006 4:26 pm
by NoahPhense
Nice code net..

- np

Posted: Tue Sep 19, 2006 5:20 pm
by Fluid Byte

Code: Select all

SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN,#HTCAPTION,0) 
OMFG! I wasted so many days writing my own window caption click detection and dragging routine for my custom GUI but your single line of code makes it all superfluous.

This nifty thang' is a enormous time/life saver, thanks netmaestro!