Frame3d Title backcolor

Just starting out? Need help? Post your questions and find answers here.
phuckstepp
User
User
Posts: 19
Joined: Tue Dec 27, 2005 12:10 pm
Location: United Kingdom
Contact:

Frame3d Title backcolor

Post 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.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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
I may look like a mule, but I'm not a complete ass.
phuckstepp
User
User
Posts: 19
Joined: Tue Dec 27, 2005 12:10 pm
Location: United Kingdom
Contact:

Post by phuckstepp »

Thanks, I did forget to mention I'm using PB4 beta 7.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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 
I may look like a mule, but I'm not a complete ass.
phuckstepp
User
User
Posts: 19
Joined: Tue Dec 27, 2005 12:10 pm
Location: United Kingdom
Contact:

Post 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?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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 
I may look like a mule, but I'm not a complete ass.
phuckstepp
User
User
Posts: 19
Joined: Tue Dec 27, 2005 12:10 pm
Location: United Kingdom
Contact:

Post by phuckstepp »

Fantastic, works like a dream.

Thanks for all your help.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Does anyone know how to set the text colour of a frame3dgadget with XP themes turned on?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply