Page 1 of 1

UserGadget

Posted: Sat Mar 04, 2006 12:34 am
by fsw
How about a USER Gadget?

Result = UserGadget(#Gadget, x, y, Width, Height, Text$, Flags/Style, Class)

I would like to have a ContainerGadget with the background like a PanelGadgetItem.
(It looks so cool with FlyAKite...)

With WinAPI it's:

CreateWindowEx_(0,"SysTabControl32", 0, #WS_CHILD|#WS_VISIBLE, 20, 20, 200, 200, hWnd, 1, 0, 0)

but then there is no inner link to PureBasic's internal automatic stuff (GadgetList etc.).
So no Gadgets can be placed.

Please consider.

Thanks

PS. Or maybe somebody knows how to change the class of a control without destroying it.
Haven't found anything on the net...
HotBasic can do it, so it should be possible :roll:

Posted: Sat Mar 04, 2006 10:28 am
by Berikco
You can use the result of CreateWindowEX_() for the GadgetList

Code: Select all

Global Window_0, Button_0, Hwnd

Procedure Open_Window_0()
  
  Window_0 = OpenWindow(#PB_Any, 5, 5, 400, 200,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Window 0")
  If Window_0
    
   Hwnd = CreateWindowEx_(0,"SysTabControl32", 0, #WS_CHILD|#WS_VISIBLE, 20, 20, 200, 200, WindowID(Window_0), 1, 0, 0) 
    If CreateGadgetList(Hwnd)
      Button_0 = ButtonGadget(#PB_Any, 60, 100, 70, 50, "ok")
      
      
    EndIf
  EndIf
EndProcedure

Open_Window_0()

Repeat
  
  Event = WaitWindowEvent()
  
  WindowID = EventWindow()
  
  GadgetID = EventGadget()
  
  If Event = #PB_Event_Gadget
    
  EndIf
  
Until Event = #PB_Event_CloseWindow

End

Posted: Sat Mar 04, 2006 1:08 pm
by einander
Why don't work?

Code: Select all

Global Window_0, Button_0, hWnd

Procedure Open_Window_0()
    Window_0 = OpenWindow(#PB_Any, 5, 5, 400, 200,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Window 0")
    If Window_0
        hWnd = CreateWindowEx_(0,"SysTabControl32", 0, #WS_CHILD|#WS_VISIBLE, 20, 20, 200, 200, WindowID(Window_0), 1, 0, 0)
        If CreateGadgetList(hWnd)
            Button_0 = ButtonGadget(#PB_Any, 60, 100, 70, 50, "ok")
        EndIf
    EndIf
EndProcedure

Open_Window_0()

Repeat
    Event = WaitWindowEvent()
    WindowID = EventWindow()
    GadgetID = EventGadget()    ;get always 0
    Debug "GadgetID="+Str(GadgetID)
    If Event = #PB_Event_Gadget  ; never happen
        Debug "Event="+Str(Event)  
    EndIf
Until Event = #PB_Event_CloseWindow
End

Posted: Sat Mar 04, 2006 1:34 pm
by Berikco
einander wrote:Why don't work?

Ohh, never tested that, but Fred told me once you can mix PB and API like this.
Sparkie will know how to do it ;)

Re: UserGadget

Posted: Sun Mar 05, 2006 1:10 am
by fsw
fsw wrote:How about a USER Gadget?

Result = UserGadget(#Gadget, x, y, Width, Height, Text$, Flags/Style, Class)
Just popped in my mind that another parameter needs to be added: Type.

Since V4 PB distinguishes between GadgetTypes:
#PB_GadgetType_Button
#PB_GadgetType_ButtonImage
#PB_GadgetType_Calendar
#PB_GadgetType_CheckBox
#PB_GadgetType_ComboBox
#PB_GadgetType_Container
#PB_GadgetType_Date
#PB_GadgetType_Editor
#PB_GadgetType_ExplorerCombo
#PB_GadgetType_ExplorerList
#PB_GadgetType_ExplorerTree
#PB_GadgetType_Frame3D
#PB_GadgetType_HyperLink
#PB_GadgetType_Image
#PB_GadgetType_IPAddress
#PB_GadgetType_ListIcon
#PB_GadgetType_ListView
#PB_GadgetType_MDI
#PB_GadgetType_Option
#PB_GadgetType_Panel
#PB_GadgetType_ProgressBar
#PB_GadgetType_ScrollArea
#PB_GadgetType_ScrollBar
#PB_GadgetType_Spin
#PB_GadgetType_Splitter
#PB_GadgetType_String
#PB_GadgetType_Text
#PB_GadgetType_TrackBar
#PB_GadgetType_Tree
#PB_GadgetType_Unknown
#PB_GadgetType_Web


So the function would be:

Result = UserGadget(#Gadget, x, y, Width, Height, Text$, Flags/Style, Class, Type)

This way the user Gadget can be categorized to a GadgetType Family.

Actually it would be nice to get this not only for Gadgets, but also for Windows, Menues, Toolbars etc. for everything that gets special treatment (events etc.) inside the PB GUI toolkit.

Re: UserGadget

Posted: Sun Mar 05, 2006 11:56 am
by Trond
fsw wrote:CreateWindowEx_(0,"SysTabControl32", 0, #WS_CHILD|#WS_VISIBLE, 20, 20, 200, 200, hWnd, 1, 0, 0)
Trying to make thumbnails? :lol:

Posted: Mon Mar 06, 2006 5:44 am
by Sparkie
Berikco wrote:Sparkie will know how to do it
Image

Posted: Mon Mar 06, 2006 5:15 pm
by Straker
Would this be a Windows-only Gadget? Or does OSX and GTK have similiar gadgets?

Posted: Thu Mar 23, 2006 11:42 pm
by fsw
Straker wrote:Would this be a Windows-only Gadget? Or does OSX and GTK have similiar gadgets?
Actually it should work on every OS.
It's just a possibility to create a custom gadget with the PB-GUI toolkit funcionality built in.