Page 1 of 1

Frame3d Title backcolor

Posted: Sun Mar 19, 2006 2:07 pm
by phuckstepp
I have a window that has a background color of white and on it I have a Frame3d gadget. I want the title/text of the frame3d gadget to be white as well so that it all matches nicely.

Unfortunately it seems that the SetGadgetColor command doesn't apply to the frame3d gadget at least where the backColor is concerned.

Is there a way to change the background color of the frame3d title?

Thanks for any help.

Posted: Sun Mar 19, 2006 2:19 pm
by srod
Use a window callback as follows: (note PB 3.94 only. A few minor changes required for PB4)

Code: Select all

Global Background
Background = CreateSolidBrush_(#White) 

Procedure WinProc(hWnd,Msg,wParam,lParam) 
result = #PB_ProcessPureBasicEvents 
  Select Msg
  Case #WM_CTLCOLORSTATIC
    result = Background 
  EndSelect 
  ProcedureReturn result
EndProcedure 

If OpenWindow(0,0,0,320,250,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Frame3DGadget")
    CreateGadgetList(WindowID(0))
      Frame3DGadget(0, 10,  10, 300, 50, "Frame3DGadget Standard")
      SetWindowCallback(@WinProc()) 
    
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Posted: Sun Mar 19, 2006 2:29 pm
by phuckstepp
Thanks, I did forget to mention I'm using PB4 beta 7.

Posted: Sun Mar 19, 2006 2:51 pm
by srod
For PB4 beta 7:

Code: Select all

Global Background, Foreground  
Background = CreateSolidBrush_(#White) 
Foreground = #Green

Procedure WinProc(hWnd,Msg,wParam,lParam) 
result = #PB_ProcessPureBasicEvents 
  Select Msg 
  Case #WM_CTLCOLORSTATIC 
    SetBkMode_(wParam,#TRANSPARENT) 
    SetTextColor_(wParam,Foreground) 
    result = Background 
  EndSelect 
  ProcedureReturn result 
EndProcedure 

If OpenWindow(0,0,0,320,250,"Frame3DGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
    CreateGadgetList(WindowID(0)) 
      Frame3DGadget(0, 10,  10, 300, 50, "Frame3DGadget Standard") 
      SetWindowCallback(@WinProc(),0) 
    
    Repeat 
    Until WaitWindowEvent() = #PB_Event_CloseWindow 
  EndIf 

Posted: Sun Mar 19, 2006 3:28 pm
by phuckstepp
That worked great, with one small exception.

It also changes the background color of every other gadget on the window. I have a number of other gadgets that have different colored backgrounds.

Can the call back be gadget specific rather than globally for hte entire window?

Posted: Sun Mar 19, 2006 4:56 pm
by srod
Yes, the lParam variable holds the handle of the underlying control. Sorry, I should have mentioned that!

Code: Select all

Global Background, Foreground  
Background = CreateSolidBrush_(#White) 
Foreground = #Green

Procedure WinProc(hWnd,Msg,wParam,lParam) 
result = #PB_ProcessPureBasicEvents 
  Select Msg 
  Case #WM_CTLCOLORSTATIC 
    If lParam = GadgetID(0)
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam,Foreground) 
      result = Background 
    EndIf
  EndSelect 
  ProcedureReturn result 
EndProcedure 

If OpenWindow(0,0,0,320,250,"Frame3DGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
    CreateGadgetList(WindowID(0)) 
      Frame3DGadget(0, 10,  10, 300, 50, "Frame3DGadget Standard") 
      SetWindowCallback(@WinProc(),0) 
    
    Repeat 
    Until WaitWindowEvent() = #PB_Event_CloseWindow 
  EndIf 

Posted: Sun Mar 19, 2006 5:38 pm
by phuckstepp
Fantastic, works like a dream.

Thanks for all your help.

Posted: Thu Jan 18, 2007 10:12 pm
by DoubleDutch
Does anyone know how to set the text colour of a frame3dgadget with XP themes turned on?