Page 1 of 1

Get the parent window (cross platform)

Posted: Mon Jan 13, 2014 6:06 pm
by mestnyi

Re: Get the parent window (cross platform)

Posted: Mon Jan 13, 2014 6:19 pm
by ts-soft

Code: Select all

Debug UseGadgetList(0)

Re: Get the parent window (cross platform)

Posted: Mon Jan 13, 2014 7:41 pm
by mestnyi
^

Re: Get the parent window (cross platform)

Posted: Mon Jan 13, 2014 9:39 pm
by netmaestro
if you call this procedure right after you create a gadget, it will return the root window it was created on regardless of how deep it is. Then you can store it for future use. I can't come up with a crossplatform way to pass a gadget# to the procedure.

Code: Select all

Procedure GetRootWindow()
  savedgadgetlist = UseGadgetList(0)
  result = savedgadgetlist
  While (result<>lastresult) And result<>0
    result=UseGadgetList(result)
    If result
      lastresult=result
    EndIf
  Wend
  UseGadgetList(savedgadgetlist)
  ProcedureReturn lastresult
EndProcedure

Re: Get the parent window (cross platform)

Posted: Tue Jan 14, 2014 5:26 am
by mestnyi
^

Re: Get the parent window (cross platform)

Posted: Tue Jan 14, 2014 6:52 am
by mestnyi
^

Re: Get the parent window (cross platform)

Posted: Tue Jan 14, 2014 7:15 am
by Bisonte
I think he means : How to get the PB Object number crossplatform.... from a windows-handle ... to use e.g. PostEvent()

Re: Get the parent window (cross platform)

Posted: Tue Jan 14, 2014 7:57 pm
by uweb
I saw your question yesterday, but my englisch is not so good and ts-soft was quicker as i with a other interpretation of you question.
today i am again unsure. it is too simple, but may ...

Code: Select all

OpenWindow(1, 100, 200, 200, 100, "Window 1")
ButtonGadget  (101, 10, 10, 180, 20, "Hello")
ButtonGadget  (102, 10, 40, 180, 20, "World")


OpenWindow(2, 310, 200, 200, 100, "Window 2")
ButtonGadget  (201, 10, 10, 180, 20, "Hello")
ButtonGadget  (202, 10, 40, 180, 20, "World")


UseGadgetList(WindowID(1))
ButtonGadget  (103, 10, 70, 180, 20, "!")
UseGadgetList(WindowID(2))
ButtonGadget  (203, 10, 70, 180, 20, "?")


Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Gadget : GadgetEvent = EventGadget()
    If GadgetEvent > 200 : Debug WindowID(2) : ElseIf GadgetEvent > 100 : Debug WindowID(1) : EndIf
  EndIf
Until Event = #PB_Event_CloseWindow

Re: Get the parent window (cross platform)

Posted: Tue Jan 14, 2014 9:40 pm
by mestnyi
^

Re: Get the parent window (cross platform)

Posted: Tue Jan 14, 2014 10:52 pm
by RASHAD

Code: Select all

ExamineDesktops()


OpenWindow(1, 100, 200, 200, 100, "Window 1")
    ButtonGadget  (1, 10, 10, 180, 20, "1")
    SetGadgetData(1,1)
    ButtonGadget  (2, 10, 40, 180, 20, "2")
    SetGadgetData(2,1)

OpenWindow(2, 310, 200, 200, 100, "Window 2")
    ButtonGadget  (3, 10, 10, 180, 20, "3")
    SetGadgetData(3,2)
    ButtonGadget  (4, 10, 40, 180, 20, "4")
    SetGadgetData(4,2)

UseGadgetList(WindowID(1))
ButtonGadget  (5, 10, 70, 180, 20, "5")
SetGadgetData(5,1)


UseGadgetList(WindowID(2))
ButtonGadget  (6, 10, 70, 180, 20, "6")
SetGadgetData(6,2)


Repeat
  
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1
      
      Case #PB_Event_Gadget
          Select EventGadget()
           Case 1            
          EndSelect
          
      Default
         x = DesktopMouseX()
         y = DesktopMouseY()

        For g = 1 To 6
            If x >= GadgetX(g,#PB_Gadget_ScreenCoordinate) And x < GadgetX(g,#PB_Gadget_ScreenCoordinate) + GadgetWidth(g) And y >= GadgetY(g,#PB_Gadget_ScreenCoordinate) And y < GadgetY(g,#PB_Gadget_ScreenCoordinate) + GadgetHeight(g)
               If g <> oldg
                  Debug "Parent Window is : Window "+Str(GetGadgetData(g))
                  oldg = g  
               EndIf
              ; MessageRequester("Info","Parent Window is : Window "+Str(GetGadgetData(g)),#PB_MessageRequester_Ok)
            EndIf
        Next         

             
  EndSelect 

Until Quit = 1
End

Re: Get the parent window (cross platform)

Posted: Wed Jan 15, 2014 12:35 am
by IdeasVacuum
That is something worth knowing - I always thought SetGadgetData() was Windows only. It is certainly very handy for this purpose, as Rashad has shown.

Re: Get the parent window (cross platform)

Posted: Wed Jan 15, 2014 2:42 pm
by davido
@RASHAD

Very nice. Thank you for sharing. :D

Re: Set parent and get parent for the all gadgets (cross platform)

Posted: Thu Jan 16, 2014 6:14 am
by mestnyi
^