Page 1 of 1

My first window is not closing

Posted: Fri May 29, 2015 5:01 pm
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 




Re: My first window is not closing

Posted: Fri May 29, 2015 5:21 pm
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

Re: My first window is not closing

Posted: Fri May 29, 2015 5:31 pm
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