My first window is not closing

Just starting out? Need help? Post your questions and find answers here.
cleber
New User
New User
Posts: 9
Joined: Mon May 25, 2015 8:22 pm
Location: Brasil

My first window is not closing

Post by cleber »

Hello everyone,

I made my first window is not closing properly. The rest think it's ok.

Any suggestion?

att.,
Cleber

Code: Select all

IncludeFile "\qmsys\syscom\qmclient.unicode.pb"

wFlags = #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget |
         #PB_Window_SizeGadget | #PB_Window_ScreenCentered

OpenWindow(1, 0, 0, 300, 200, "Minha janela", wFlags)

#BotaoSeleciona = 1
ButtonGadget(#BotaoSeleciona, 10,100, 200, 60, "Seleciona")


Repeat 
  Event = WindowEvent()
  Select EventGadget()
  Case #BotaoSeleciona
    If Not QMConnect("localhost", -1, "cleber", "psw", "teste") 
      TextGadget(0, 0, 0, 250, 200, "Não conectou", #PB_Text_Center )
    Else
      TextGadget(0, 0, 0, 250, 200, "Conectou com QM", #PB_Text_Center)
      Delay(5000)
      Arg1.s = ""
      QMCall1("RELCADCLI", Arg1.s)
      TextGadget(0, 0, 0, 250, 200, Arg1.s, #PB_Text_Center)
      Delay(5000)
   EndIf
EndSelect
Until Event = #PB_Event_CloseWindow 



infratec
Always Here
Always Here
Posts: 7699
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: My first window is not closing

Post by infratec »

Maybe this works:

Code: Select all

IncludeFile "\qmsys\syscom\qmclient.unicode.pb"

wFlags = #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget |
         #PB_Window_SizeGadget | #PB_Window_ScreenCentered

OpenWindow(1, 0, 0, 300, 200, "Minha janela", wFlags)

#BotaoSeleciona = 1
ButtonGadget(#BotaoSeleciona, 10,100, 200, 60, "Seleciona")
TextGadget(0, 0, 0, 250, 200, "", #PB_Text_Center )

Repeat
  Event = WindowEvent()
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #BotaoSeleciona
          If Not QMConnect("localhost", -1, "cleber", "psw", "teste")
            SetGadgetText(0, "Não conectou")
          Else
            SetGadgetText(0, "Conectou com QM")
            Delay(5000)
            Arg1.s = ""
            QMCall1("RELCADCLI", Arg1)
            SetGadgetText(0, Arg1)
            Delay(5000)
          EndIf
      EndSelect
  EndSelect
Until Event = #PB_Event_CloseWindow
If I comment out all the stuff concerning QM..., the windows close.

But...
the delays inside the main loop are a 'no go', because you block everything with it.

Bernd
User avatar
TI-994A
Addict
Addict
Posts: 2764
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: My first window is not closing

Post by TI-994A »

cleber wrote:...window is not closing properly.
Like infratec said, the window seems to close properly when clicking the close window button [x]. However, if you'd like the window to close when pressing the [Seleciona] button, simply call the PostEvent(#PB_Event_CloseWindow) function at the appropriate location:

Code: Select all

IncludeFile "\qmsys\syscom\qmclient.unicode.pb"

wFlags = #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget |
         #PB_Window_SizeGadget | #PB_Window_ScreenCentered

OpenWindow(1, 0, 0, 300, 200, "Minha janela", wFlags)

#BotaoSeleciona = 1
ButtonGadget(#BotaoSeleciona, 10,100, 200, 60, "Seleciona")


Repeat 
  Event = WindowEvent()
  Select EventGadget()
    Case #BotaoSeleciona
      If Not QMConnect("localhost", -1, "cleber", "psw", "teste") 
        TextGadget(0, 0, 0, 250, 200, "Não conectou", #PB_Text_Center )
        PostEvent(#PB_Event_CloseWindow)   ;place it here
      Else
        TextGadget(0, 0, 0, 250, 200, "Conectou com QM", #PB_Text_Center)
        Delay(5000)
        Arg1.s = ""
        QMCall1("RELCADCLI", Arg1.s)
        TextGadget(0, 0, 0, 250, 200, Arg1.s, #PB_Text_Center)
        Delay(5000)
        ;PostEvent(#PB_Event_CloseWindow)   ;or place it here
      EndIf
  EndSelect
Until Event = #PB_Event_CloseWindow
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply