UserGadget

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

UserGadget

Post 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:
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post 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
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post 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
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post 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 ;)
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: UserGadget

Post 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.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: UserGadget

Post 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:
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Berikco wrote:Sparkie will know how to do it
Image
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

Would this be a Windows-only Gadget? Or does OSX and GTK have similiar gadgets?
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post 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.
Post Reply