StringGadget open a new window does not work

Windows specific forum
cajomi
User
User
Posts: 45
Joined: Thu Dec 04, 2008 9:53 am
Location: Essen

StringGadget open a new window does not work

Post by cajomi »

Code: Select all

If OpenWindow(0,200,200,300,300,"Test")
  StringGadget(1,5,10,200,20,"testbutton",#PB_String_ReadOnly)
  
  Repeat
    Event = WaitWindowEvent()
    
    Select EventWindow() 
      Case 0       
        If Event = #PB_Event_CloseWindow  
          Quit = 1
        EndIf
        Select Event     
          Case #PB_Event_Gadget  
            Select EventGadget() 
              Case 1
                If IsWindow(1)
                Else 
                  OpenWindow(1,0,0,100,100,"Test2")
                  ButtonGadget(3,5,5,100,20,"close window")
                EndIf
            EndSelect
        EndSelect
      Case 1
        Select Event     
          Case #PB_Event_Gadget  
            Select EventGadget() 
              Case 3
                CloseWindow(1)
            EndSelect
        EndSelect
    EndSelect    
  Until Quit=1
EndIf
The code is ?
When you open it 1 time and close it, the window is still open.
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: StringGadget open a new window does not work

Post by Bisonte »

If I click on the StringGadget(), the second window is shown, I click on the button and the second window dissapears.

So what is the behaviour you expect ?
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
cajomi
User
User
Posts: 45
Joined: Thu Dec 04, 2008 9:53 am
Location: Essen

Re: StringGadget open a new window does not work

Post by cajomi »

Open it once again,
1. open the window,
2. close window
3. open it again

that is the problem
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: StringGadget open a new window does not work

Post by falsam »

Good morning.
Your stringgadget is ReadOnly.

When you focus the first time, an event is active and you open the window (#1).

The second time, you you have no event.

When you close your window (#1), I think in this case, you must have another gadget.

Your stringgadget (#1) will generate the event (#PB_EventType_Focus).

Code: Select all

If OpenWindow(0,200,200,300,300,"Test")
  StringGadget(0,5,10,200,20,"Nothing", #PB_String_ReadOnly)
  StringGadget(1,5,40,200,20,"testbutton", #PB_String_ReadOnly)
  
  Repeat
    Event = WaitWindowEvent()
    WEvent = EventWindow() 
    GEvent = EventGadget() 
    TEvent = EventType()
    
    Select Event
      Case #PB_Event_CloseWindow
        If WEvent = 0
          End
        EndIf
        
      Case #PB_Event_Gadget  
        Select GEvent
          Case 1  
            Select TEvent
              Case #PB_EventType_Focus
                If Not IsWindow(1)
                  OpenWindow(1,0,0,100,100,"Test2")
                  ButtonGadget(3,5,5,100,20,"close window")  
                EndIf
            EndSelect
            
          Case 3
            SetActiveWindow(0)
            SetActiveGadget(0)
            CloseWindow(1)
            
        EndSelect
    EndSelect
  ForEver
EndIf

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
cajomi
User
User
Posts: 45
Joined: Thu Dec 04, 2008 9:53 am
Location: Essen

Re: StringGadget open a new window does not work

Post by cajomi »

Thanks for help (by falsam)
Post Reply