A couple of useful imports from the gadget lib

Share your advanced PureBasic knowledge/code with the community.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

A couple of useful imports from the gadget lib

Post 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
BERESHEIT
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: A couple of useful imports from the gadget lib

Post by rsts »

Nice :D
+18
Enthusiast
Enthusiast
Posts: 228
Joined: Fri Oct 24, 2008 2:07 pm

Post by +18 »

Fantastic :D

Thanks for sharing , merci
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: A couple of useful imports from the gadget lib

Post by SFSxOI »

Nice, Thank You :)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: A couple of useful imports from the gadget lib

Post by Rook Zimbabwe »

Excellent... I have been meaning to learn mor eabout import as well!!! Lots of noew toys in 4.41!!! :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: A couple of useful imports from the gadget lib

Post by DoubleDutch »

It would be great if these became proper commands.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: A couple of useful imports from the gadget lib

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