Page 1 of 1

A couple of useful imports from the gadget lib

Posted: Mon Feb 15, 2010 4:55 am
by netmaestro
Warning: Windows only and PB internals could change with new compiler versions, so be aware that an update could break this code.

Code: Select all

Import ""
  PB_Gadget_SendGadgetCommand(hwnd, EventType) ; Raise gadget event for gadgetid
  PB_Gadget_GetRootWindow(hwnd)                ; Find root window of gadgetid
  PB_Gadget_GetCommonControlsVersion()         ; Easy way to know if themes enabled or not
EndImport

Debug OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ContainerGadget(0,0,0,260,200)
ContainerGadget(1,0,0,200,100)
SetGadgetColor(0, #PB_Gadget_BackColor, #Gray)
SetGadgetColor(1, #PB_Gadget_BackColor, #White)
ButtonGadget(2,0,0,100,20,"OK")
CloseGadgetList()
CloseGadgetList()
PB_Gadget_SendGadgetCommand(GadgetID(2), 0)

Debug PB_Gadget_GetRootWindow(GadgetID(2))     ; should be the same as WindowID(0)
Debug PB_Gadget_GetCommonControlsVersion()>>16 ; 6 for xp skins, 5 otherwise

Repeat
  ev = WaitWindowEvent()
  Select ev
    Case #PB_Event_Gadget
      Debug "Button press event received by gadget "+Str(EventGadget())
  EndSelect
Until ev=#PB_Event_CloseWindow

Re: A couple of useful imports from the gadget lib

Posted: Mon Feb 15, 2010 6:11 am
by rsts
Nice :D

Posted: Mon Feb 15, 2010 7:07 am
by +18
Fantastic :D

Thanks for sharing , merci

Re: A couple of useful imports from the gadget lib

Posted: Mon Feb 15, 2010 6:54 pm
by SFSxOI
Nice, Thank You :)

Re: A couple of useful imports from the gadget lib

Posted: Mon Feb 15, 2010 7:50 pm
by Rook Zimbabwe
Excellent... I have been meaning to learn mor eabout import as well!!! Lots of noew toys in 4.41!!! :D

Re: A couple of useful imports from the gadget lib

Posted: Tue Feb 16, 2010 1:17 am
by DoubleDutch
It would be great if these became proper commands.

Re: A couple of useful imports from the gadget lib

Posted: Tue Feb 16, 2010 2:17 am
by ts-soft
I will not open a extra thread.
Here some usefull imports from the window.lib

Code: Select all

Import ""
  PB_Window_Icon
  PB_Window_Cursor
EndImport

OpenWindow(0, #PB_Ignore, #PB_Ignore, 180, 70, "", #PB_Window_SystemMenu)
If PB_Window_Icon; you have to add a icon in the compilersettings!
  ImageGadget(0, 10, 10, 50, 50, PB_Window_Icon)
EndIf
If PB_Window_Cursor
  ImageGadget(1, 100, 10, 50, 50, PB_Window_Cursor)
EndIf

While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
greetings
Thomas