WinColor()

Share your advanced PureBasic knowledge/code with the community.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

WinColor()

Post by gurj »

Code: Select all

Procedure WinColor(Win,WinColor=$fcfcfc,TransparentColor=#Green,TransparentLevel=256)
 SetWindowColor(Win,WinColor)
  Win=WindowID(Win)
 SetWindowLongPtr_(Win, #GWL_EXSTYLE,GetWindowLongPtr_(win, #GWL_EXSTYLE) | #WS_EX_LAYERED);|*=$00080000
 SetLayeredWindowAttributes_(Win, TransparentColor,TransparentLevel, #LWA_COLORKEY|#LWA_ALPHA);*|*=3
EndProcedure
;-{*********Example:

TranColor=#Green
OpenWindow(0,0,0,700,400,"",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
LoadFont(0,"Tahoma", 28, #PB_Font_Bold):SetGadgetFont(#PB_Default, FontID(0))

ButtonGadget(0, 30, 30,200, 50, "Button 0")
StringGadget(1, 30, 90,200, 50, "String 1")
SetGadgetColor(1,#PB_Gadget_BackColor,TranColor)
StringGadget(2, 30, 150,200, 50, "String 2")
SetGadgetColor(2,#PB_Gadget_FrontColor,TranColor)
SetGadgetColor(2,#PB_Gadget_BackColor,#Red)
             
WinColor(0,TranColor,TranColor,127)
While WindowEvent():Wend
While WindowEvent()=0:Wend
While WindowEvent():Wend
Delay(2220)
SetGadgetText(2,"String "+98)
WinColor(0,#Yellow,TranColor,127)
While WindowEvent():Wend
While WindowEvent()=0:Wend
While WindowEvent():Wend
Delay(2222)
SetGadgetText(2,"String "+99)
WinColor(0,#Yellow,TranColor,255)
While WindowEvent():Wend
While WindowEvent()=0:Wend
While WindowEvent():Wend
While WindowEvent()=0:Wend
While WindowEvent():Wend
Delay(1224)
SetGadgetText(2,"String "+100)
WinColor(0,#Yellow,TranColor,80)

;AddWindowTimer(0,1,2222)
Repeat:ev=WaitWindowEvent():Select ev
  Case #PB_Event_Timer
WinColor(0,TranColor+Random($00ff00,10),TranColor,Random(255,10))

  Case #PB_Event_CloseWindow:Break
EndSelect:ForEver
End
;-}
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: WinColor()

Post by gurj »

add:',useTransparent=0'

Code: Select all

Procedure WinColor(Win,WinColor=$fcfcfc,useTransparent=0,TransparentColor=#Green,TransparentLevel=256)
 SetWindowColor(Win,WinColor)
  If useTransparent=1:Win=WindowID(Win)
 SetWindowLongPtr_(Win, #GWL_EXSTYLE,GetWindowLongPtr_(win, #GWL_EXSTYLE) | #WS_EX_LAYERED);|*=$00080000
 SetLayeredWindowAttributes_(Win, TransparentColor,TransparentLevel, #LWA_COLORKEY|#LWA_ALPHA);*|*=3
 EndIf
EndProcedure
my pb for chinese:
http://ataorj.ys168.com
Post Reply