Page 1 of 1

Enhanced Frame Gadget

Posted: Wed Jan 04, 2023 2:22 pm
by RASHAD
Easy to adapt
It could be much better using Vector lib.

Code: Select all

Procedure _FrameGadget(gadget,x,y,width,height,Text$,tColor,lColor)
  img = CreateImage(#PB_Any,width,height,24,$C5FDEB)
  StartDrawing(ImageOutput(img))
    DrawingMode(#PB_2DDrawing_Outlined)
    RoundBox(0, 4, width, height-8, 10,10, lcolor)
    RoundBox(1, 5, width-2, height-10, 10,10, $FFFFFF)
    DrawingMode(#PB_2DDrawing_Default)
    DrawingFont(FontID(1))
    DrawText(15,-2,text$,tColor,GetSysColor_(#COLOR_BTNFACE	))
  StopDrawing()
  ImageGadget(gadget,x,y,width,height+8,ImageID(img))
  DisableGadget(gadget,1)
  SetWindowLongPtr_(GadgetID(gadget), #GWL_STYLE, GetWindowLongPtr_(GadgetID(gadget), #GWL_STYLE) | #WS_CLIPSIBLINGS)
EndProcedure

LoadFont(1,"BroadWay",12)

OpenWindow(0, 0, 0, 600, 400, "",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered )

  ListViewGadget(1,20,40,280,130)
  For a = 1 To 12
    AddGadgetItem (1, -1, "Item " + Str(a) + " of the Listview")
  Next
  ButtonGadget(2,20,178,80,20,"TEST")
  
  Text$ = " Colored FrameGadget "
  _FrameGadget(3,10,10,300,200," Colored FrameGadget ",$5D62FF,$20DB00)
  
Repeat
  ev = WaitWindowEvent()
  Select ev
    Case #PB_Event_CloseWindow
        Quit = 1
        
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Debug "ListView"
          
        Case 2
          Debug "ButtonGadget"
          
      EndSelect

  EndSelect
Until Quit = 1
# 2 :

Code: Select all

Global TextBackground=CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE))

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

OpenWindow(0,0,0,250,100,"Colored Frame3D",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(0,$C5FDEB)
SetWindowCallback(@WinProc())
FrameGadget(0,10,10,230,80,"This is a Frame ")
SetWindowTheme_(GadgetID(0), @Null.w, @Null.w)
InvalidateRect_(WindowID(0),0,1)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
# 3 :

Code: Select all

hWnd = OpenWindow(0, 0, 0, 400,300, "", #PB_Window_SystemMenu |#PB_Window_ScreenCentered)
SetWindowColor(0,$C5FDEB)
TextGadget(1,18,5,110,20," This is a Frame ")
SetGadgetColor(1,#PB_Gadget_FrontColor,$0000FF) 
hDC = GetDC_(WindowID(0))
SetRect_(r.RECT,10,10,230,80)
DrawEdge_(hDC,r,#EDGE_ETCHED,#BF_RECT)
Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_CloseWindow 
      End
      
    Case #PB_Event_MoveWindow
       DrawEdge_(hDC,r,#EDGE_ETCHED,#BF_RECT)
       SetGadgetColor(1,#PB_Gadget_FrontColor,$0000FF)
  EndSelect 
ForEver 

Re: Enhanced Frame Gadget

Posted: Mon Jan 16, 2023 12:43 pm
by Kwai chang caine
Thanks a loft for sharing this nices pieces of code :wink: