second window

Just starting out? Need help? Post your questions and find answers here.
alicent23

second window

Post 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!
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: second window

Post by BarryG »

It opens here, directly on top of the first window.
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: second window

Post by mk-soft »

Remove #PB_Window_ScreenCentered.
Then the windows are not exactly on top of each other.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kiffi
Addict
Addict
Posts: 1509
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: second window

Post by Kiffi »

FYI: alicent23 is a bot. I deleted him, but kept his post because the answers may be helpful to other users
Hygge
Post Reply