What window does a gadget belong to?
Posted: Wed Dec 17, 2014 12:58 am
how to tell gadget is in what window?
like:
MyWindow = GadgetBelongsToWhatWindow( SomeGadget )
like:
MyWindow = GadgetBelongsToWhatWindow( SomeGadget )
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
SetGadgetData(#MyStringGadget01, #MyWin02)
iWinID.i = GetGadgetData(#MyStringGadget01)
Code: Select all
Macro GadgetWindow(gad)
GetProp_(GetParent_(GadgetID(gad)),"PB_WindowID")-1
EndMacro
This does'nt work, if you have a gadget on a containergadget.PB Fanatic wrote:Code: Select all
Macro GadgetWindow(gad) GetProp_(GetParent_(GadgetID(gad)),"PB_WindowID")-1 EndMacro
That's pretty slick -- I always forget about the added properties...PB Fanatic wrote:Code: Select all
Macro GadgetWindow(gad) GetProp_(GetParent_(GadgetID(gad)),"PB_WindowID")-1 EndMacro
Code: Select all
Procedure GetGadgetWindow(nGadget)
Protected nWindow, hParent, hGadget
If IsGadget(nGadget)
hGadget = GadgetID(nGadget)
Repeat
hParent = GetParent_(hGadget)
nWindow = GetProp_(hParent,"PB_WindowID")
If nWindow=0
hGadget = hParent
Else
nWindow - 1
EndIf
Until IsWindow(nWindow)
else
nWindow=-1
EndIf
ProcedureReturn nWindow
EndProcedure