Dynamically creating windows and recieving events from them

Just starting out? Need help? Post your questions and find answers here.
two_bits
User
User
Posts: 15
Joined: Sat Oct 04, 2003 6:52 pm

Dynamically creating windows and recieving events from them

Post by two_bits »

Hello everyone, what i would like to do is something similar to what msn messenger does.
Every time someone pms you it will open another window similaer to every other chat window.
Now what I would like to know is how to do it? Is it possible to create an unknown number of windows and deal with events from every window??
Cheers
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Use WindowN = EventWindowID() to know which window produced the event.
You should use the same event loop:

Code: Select all

Repeat

EventID=WaitWindowEvent()

Select EventWindowID()

  Case 1
  Case 2

EndSelect

Until EventID=#PB_EventCloseWindow
One small example that you can run:

Code: Select all

If OpenWindow(0,100,150,450,100,#PB_Window_SystemMenu,"Test")
  CreateGadgetList(WindowID())
  ButtonGadget(2,300,30,50,25,"Test")
  ButtonGadget(3,70,30,150,25,"Generate an event")
  Repeat
    EventID=WaitWindowEvent()
    WindowN = EventWindowID() 
    Select EventID
      
      Case #PB_EventGadget
        Select EventGadgetID()
          Case 2
            OpenWindow(1,0,0,450,100,#PB_Window_SystemMenu,"Test")
            CreateGadgetList(WindowID())
            ButtonGadget(3,70,30,150,25,"Generate an event")
          Case 3
            MessageRequester("Window Event","This event was produced in window #" + Str(WindowN),0)
        EndSelect
        
    EndSelect
    
  Until EventID=#PB_EventCloseWindow
EndIf
ARGENTINA WORLD CHAMPION
two_bits
User
User
Posts: 15
Joined: Sat Oct 04, 2003 6:52 pm

Post by two_bits »

Thanks a bunch m8y :D
Post Reply