Page 1 of 2
Transparent Container Gadget
Posted: Fri Jun 01, 2007 4:41 pm
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
Re: Transparent Container Gadget
Posted: Fri Jun 01, 2007 4:45 pm
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.
Posted: Fri Jun 01, 2007 4:50 pm
by kinglestat
yes I sort of gathered that by myself!
But I would still like to make my containergadget transparent!!
Posted: Fri Jun 01, 2007 10:05 pm
by Pantcho!!
If you will explain your goal more we could try to help you.
Posted: Fri Jun 01, 2007 10:35 pm
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.
Posted: Fri Jun 01, 2007 11:01 pm
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
Posted: Fri Jun 01, 2007 11:21 pm
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!
Posted: Sat Jun 02, 2007 8:26 am
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
Posted: Sat Jun 02, 2007 8:31 am
by kinglestat
netmaestro, you'r a friggin genius
worked like a charm
Thanks again for your help srod too
Posted: Sat Jun 02, 2007 10:23 am
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.

Posted: Sat Jun 02, 2007 10:32 am
by kinglestat
the funny thing it still looks awfull
shuks
I'm hopeless at user interfaces
I should stick to linux and windows scripts!
Posted: Sat Jun 02, 2007 11:36 am
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!
Course, I should add that I'm crap at designing gui's as well!
Posted: Fri Jul 06, 2007 4:23 pm
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??
Posted: Fri Jul 06, 2007 6:28 pm
by Fluid Byte
is there a voice recognition library available??
Har har! Good one!
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 
Posted: Sat Jul 07, 2007 1:49 pm
by kinglestat
they never learn!