Page 1 of 1

Inverse of GadgetID(Gadget)

Posted: Tue Jan 17, 2017 12:12 am
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

Re: Inverse of GadgetID(Gadget)

Posted: Tue Jan 17, 2017 1:42 am
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.

Re: Inverse of GadgetID(Gadget)

Posted: Tue Jan 17, 2017 3:15 am
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. :(

Re: Inverse of GadgetID(Gadget)

Posted: Tue Jan 17, 2017 3:54 am
by netmaestro
Yeah, me too!

Re: Inverse of GadgetID(Gadget)

Posted: Sat Jan 21, 2017 11:40 am
by gurj
should:
ProcedureReturn -1

Code: Select all

Procedure GadgetFromGadgetID(GadgetID)
  If IsWindow_(GadgetID)
    ProcedureReturn GetDlgCtrlID_(GadgetID)
  EndIf
  ProcedureReturn -1
EndProcedure