Transparent Container Gadget

Just starting out? Need help? Post your questions and find answers here.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Transparent Container Gadget

Post by kinglestat »

Is it possible to make a ContainerGadget Transparent?
I've tried using the excellent PureColor lib

PureCOLOR_SetGadgetColor ( gn, #PureCOLOR_SystemColor , #PureCOLOR_DontSetBackColor )

But container shows up as white

cheers

KingLestat
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Transparent Container Gadget

Post by gnozal »

kinglestat wrote:Is it possible to make a ContainerGadget Transparent?
I've tried using the excellent PureColor lib
PureCOLOR_SetGadgetColor ( gn, #PureCOLOR_SystemColor , #PureCOLOR_DontSetBackColor )
But container shows up as white
Iirc #PureCOLOR_DontSetBackColor only works with Text/Option/CheckBox gadgets, and if XP Themes are disabled.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

yes I sort of gathered that by myself!
But I would still like to make my containergadget transparent!!
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

If you will explain your goal more we could try to help you.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

If you're not going to be moving the gadgets around on the container you can apply a region to it:

Code: Select all

Procedure ScanRegion(image)
  Protected width, height
  width = ImageWidth(image)
  height = ImageHeight(image)
  hRgn = CreateRectRgn_(0, 0, Width, Height)
  StartDrawing(ImageOutput(image))
    For y=0 To ImageHeight(image)
      For x=0 To ImageWidth(image)
        color = Point(x,y)
        If color = #Black
          hTmpRgn = CreateRectRgn_(x,y,x+1,y+1)
          CombineRgn_(hRgn, hRgn, hTmpRgn, #RGN_XOR)
          DeleteObject_(hTmpRgn)
        EndIf
      Next
    Next
  StopDrawing()
  ProcedureReturn hRgn;
EndProcedure

CreateImage(0, 320, 240, 24)
startdrawing(ImageOutput(0))
  Box(10,10,100,20,#White)
  Box(120,10,50,20,#White)
stopdrawing()

mainrgn = ScanRegion(0)

OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
setwindowcolor(0, #White)
CreateGadgetList(WindowID(0))
ContainerGadget(0, 10,10,300,220)
StringGadget(1,10,10,100,20,"")
ButtonGadget(2,120,10,50,20,"OK")
CloseGadgetList()

SetWindowRgn_(GadgetID(0),mainrgn,1)
Repeat:Until WaitWindowEvent()=#WM_CLOSE
The window is colored white to show that those portions of the container not holding a gadget are invisible. If this were not the case the container would show as a big gray box. Comment out the SetWindowRgn_() to see.
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Nice one netty.

I can't help feel that the following really shouldn't work, or at least should throw up certain problems, but...

Code: Select all

Global gOldProc

Procedure ContainerProc(hWnd,Msg,wParam,lParam) 
  Protected wHdc
  Select Msg
    Case #WM_ERASEBKGND
      result = 0
    Default
      result=CallWindowProc_(gOldProc, hWnd, Msg, wParam, lParam)
  EndSelect 

  ProcedureReturn result
EndProcedure 

OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu) 
SetWindowColor(0, #White) 
CreateGadgetList(WindowID(0)) 
ContainerGadget(0, 10,10,300,220) 
StringGadget(1,10,10,100,20,"") 
ButtonGadget(2,120,10,50,20,"OK") 
CloseGadgetList() 
gOldProc=SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @ContainerProc())

Repeat:Until WaitWindowEvent()=#WM_CLOSE 
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Ha. OK, I for some reason didn't think that would work so I didn't try it. But, if it does work, then this should work too:

Code: Select all

OpenWindow(0,0,0,320,240,"",$CF0001) 
SetWindowColor(0, #White) 
CreateGadgetList(WindowID(0)) 
ContainerGadget(0, 10,10,300,220) 
StringGadget(1,10,10,100,20,"") 
ButtonGadget(2,120,10,50,20,"OK") 
CloseGadgetList() 

SetClassLong_(GadgetID(0),#GCL_HBRBACKGROUND,GetStockObject_(#NULL_BRUSH))

Repeat:Until WaitWindowEvent()=#WM_CLOSE 
Which is just one extra line of code. You don't even have to delete the brush at the end because it's a stock object!
BERESHEIT
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

Good point guys
I havent tried what you posted but what I am trying to do is the following
I have multiple screens which I flip with buttons
each screen is on a container gadget
with some help (on this forum) its working

But I wanted to have a common backround image

this is what I have

ghBrushBack = CreatePatternBrush_ ( Image4 )
ContainerGadget ( #MDIOptions, 0, #CONTAINER_Y, #CONTAINER_SIZEX, #CONTAINER_SIZEY )
SetClassLong_ ( GadgetID ( GadNUM ), #GCL_HBRBACKGROUND, ImgBrush )
InvalidateRect_ ( GadgetID ( GadNUM ), 0 ,1 )

the problem with this is that the buttons at top (I am using CreateTB ( 0, hwnd, 64, 64, #TBpro_TRANSPARENT ) ) look butt ugly. So I am trying to use

SetWinBackgroundImage ( gWindowID, Image4 )
But the containergadget looks grey
My reasoning is if the ContainerGadget is transparent, the background image comes out

I apologize I didnt mention this earlier
Didnt really cross my mind...considering you guys know bloody everything anyway!!

KingLestat
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

netmaestro, you'r a friggin genius
worked like a charm

Thanks again for your help srod too
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

The only thing with using SetClassLong_() is that all container gadgets in your application will be affected. That's why I steered away from it. :)
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

the funny thing it still looks awfull
shuks
I'm hopeless at user interfaces
I should stick to linux and windows scripts!
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

kinglestat wrote:I'm hopeless at user interfaces
I should stick to linux and windows scripts!
Simple and functional, that's my philosophy! :wink:

Course, I should add that I'm crap at designing gui's as well!
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

srod, in retrospect you where right
and yes it took me more than a month to realize it
why cant people simply forget the use of GUIs?

is there a voice recognition library available??
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

is there a voice recognition library available??
Har har! Good one! Image

Certainly one of the hardest things to program. There aren't any libraries that would achieve a reliable voice recognition. And believe me, not even Micro$oft can do it right:

http://www.youtube.com/watch?v=2Y_Jp6PxsSQ Image
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

they never learn!
Post Reply