Page 1 of 1

second window

Posted: Mon Oct 21, 2024 8:34 am
by alicent23
I’m trying to create a window with a button that, when clicked, should open a second window. However, every time I press the button, nothing happens, and no errors appear. Here's the code I’m working with:

Code: Select all

If OpenWindow(0, 100, 100, 300, 200, "Main Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(1, 100, 70, 100, 30, "Open Second Window")
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_Gadget
      Select EventGadget()
        Case 1
          ; Trying to open second window here
          If OpenWindow(1, 200, 150, 300, 200, "Second Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
          Else
            MessageRequester("Error", "Failed to open the second window", 0)
          EndIf
      EndSelect
    EndIf
    
  Until Event = #PB_Event_CloseWindow
  
EndIf
Could anyone point out what I might be doing wrong here? The second window just doesn’t seem to open. Any help would be appreciated!

Re: second window

Posted: Mon Oct 21, 2024 8:36 am
by BarryG
It opens here, directly on top of the first window.

Re: second window

Posted: Mon Oct 21, 2024 8:39 am
by mk-soft
Remove #PB_Window_ScreenCentered.
Then the windows are not exactly on top of each other.

Re: second window

Posted: Mon Oct 21, 2024 9:13 am
by Kiffi
FYI: alicent23 is a bot. I deleted him, but kept his post because the answers may be helpful to other users