framecolor - Frame3DGadget

Just starting out? Need help? Post your questions and find answers here.
hth
User
User
Posts: 41
Joined: Tue Aug 21, 2007 8:01 pm

framecolor - Frame3DGadget

Post by hth »

Code: Select all

Frame3DGadget(#Gadget, x, y, width, hight, "", #PB_Frame3D_Flat)
The color of the frame is black.
Is it possible to change the color?

hth
eJan
Enthusiast
Enthusiast
Posts: 366
Joined: Sun May 21, 2006 11:22 pm
Location: Sankt Veit am Flaum

Re: framecolor - Frame3DGadget

Post by eJan »

Maybe this helps, thanks netmaestro:

Code: Select all

; netmaestro: http://www.purebasic.fr/english/viewtopic.php?p=173362#p173362

Global TextBackground = CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE))
Global TextForeground = #Red

Procedure WinProc(hWnd, Msg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  If Msg = #WM_CTLCOLORSTATIC And lParam = GadgetID(0)
    SetBkMode_(wParam, #TRANSPARENT)
    SetTextColor_(wParam, TextForeground)
    result = TextBackGround
  EndIf
  ProcedureReturn result
EndProcedure

OpenWindow(0, 0, 0, 250, 100, "Colored Frame3D", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
SetWindowCallback(@WinProc())

Frame3DGadget(0, 10, 10, 230, 80, "This is a Frame3D")

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

DeleteObject_(TextForeground)
DeleteObject_(TextBackground)
Image
hth
User
User
Posts: 41
Joined: Tue Aug 21, 2007 8:01 pm

Re: framecolor - Frame3DGadget

Post by hth »

Thanks,
but not the text, but the border line should be of a different colour.

hth
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: framecolor - Frame3DGadget

Post by Danilo »

hth wrote:Thanks,
but not the text, but the border line should be of a different colour.
Draw it yourself? It is more flexible.

Code: Select all

Procedure MyFrame3DGadget(window, gadget, x, y, width, height, text$, frontcolor=0, backcolor=0, shadow=$FFFFFF)
    background = GetSysColor_(#COLOR_BTNFACE);GetWindowColor(window))
    container  = ContainerGadget(gadget,x,y,width,height)
    img = CreateImage(#PB_Any,width,height)
    If img And StartDrawing(ImageOutput(img))
        Box(0,0,width,height,background)
        DrawingMode(#PB_2DDrawing_Outlined)
        RoundBox(6,6,width-12,height-12,3,3,shadow)
        RoundBox(5,5,width-10,height-10,3,3,backcolor)
        DrawingFont(GetGadgetFont(#PB_Default))
        DrawText(10,0," "+text$+" ",frontcolor, background)
        StopDrawing()
        DisableGadget(ImageGadget(#PB_Any,0,0,width,height,ImageID(img)),1)
    EndIf
    ProcedureReturn container
EndProcedure

OpenWindow(0, 0, 0, 250, 100, "Colored Frame3D", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)

MyFrame3DGadget(0, 0, 10, 10, 230, 80, "This is a Frame3D",RGB($00,$00,$FF),RGB($FF,$00,$00))
ButtonGadget(1,10,20,100,20,"Button")
CloseGadgetList()

Repeat
    Select WaitWindowEvent()
        Case #PB_Event_CloseWindow : Break
        Case #PB_Event_Gadget      : If EventGadget()=1 : MessageRequester("Info","Button pressed") : EndIf
    EndSelect
ForEver
User avatar
Blue
Addict
Addict
Posts: 967
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: framecolor - Frame3DGadget

Post by Blue »

Many thanks, Danilo.
Very nicely done.

You've saved me a lot of suffering... :lol:

I never would have thought of using DisableGadget() to make the drawing visible.
In fact, i see that it does work, but i'm still bafflled as to why it's required.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Post Reply