Inverse of GadgetID(Gadget)

Windows specific forum
dougmo52usr
User
User
Posts: 55
Joined: Mon Jul 18, 2016 6:43 pm

Inverse of GadgetID(Gadget)

Post by dougmo52usr »

When coding windows callbacks, I wanted a way to get the Gadget# assigned by use of the #PB_Any parameter. This seems to work.

Code: Select all

Procedure GadgetFromGadgetID(GadgetID)
  If IsWindow_(GadgetID)
    ProcedureReturn GetDlgCtrlID_(GadgetID)
  EndIf
  ProcedureReturn 0
EndProcedure
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Inverse of GadgetID(Gadget)

Post by netmaestro »

Yes, that's what GetDlgCtrlID is for. It's what I always use because I know it'll never change but another way is GetProp_(hwnd, "PB_ID") which probably won't change either but being a PureBasic internal, it could potentially fall victim to a future overhaul of the way PureBasic manages windows and gadgets.
BERESHEIT
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Inverse of GadgetID(Gadget)

Post by Mistrel »

netmaestro wrote:... being a PureBasic internal, it could potentially fall victim to a future overhaul of the way PureBasic manages windows and gadgets.
I miss being able to WaitWindowEvent(1)=#WM_CLOSE. :(
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Inverse of GadgetID(Gadget)

Post by netmaestro »

Yeah, me too!
BERESHEIT
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: Inverse of GadgetID(Gadget)

Post by gurj »

should:
ProcedureReturn -1

Code: Select all

Procedure GadgetFromGadgetID(GadgetID)
  If IsWindow_(GadgetID)
    ProcedureReturn GetDlgCtrlID_(GadgetID)
  EndIf
  ProcedureReturn -1
EndProcedure
my pb for chinese:
http://ataorj.ys168.com
Post Reply