Page 1 of 1

window problem

Posted: Mon Dec 15, 2008 10:36 pm
by wh1sp3r
I have problem with new window. So, i open my window, where are values from pressure sensors, all works ok but when I move with window or I move cursor on close button, window freeze, windows show "program not responding". Why ? Have I missed something importat ? I call WindowEvent() every loop and have delay(1) there.

my code:

Code: Select all

      OpenWindow(#staticmeasure, 219, 349, 943, 160, "Statické měření",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered ,WindowID(#Window_0))
      CreateGadgetList(WindowID(#staticmeasure))
      TextGadget(#static_text4, 730, 0, 60, 55, "4:")
      SetGadgetFont(#static_text4, FontID1static)
      TextGadget(#static_text1, 10, 0, 60, 55, "1:")
      SetGadgetFont(#static_text1, FontID1static)
      TextGadget(#static_text2, 245, 0, 60, 55, "2:")
      SetGadgetFont(#static_text2, FontID1static)
      TextGadget(#static_text3, 485, 0, 60, 55, "3:")
      SetGadgetFont(#static_text3, FontID1static)
      TextGadget(#staticvalue1, 10, 60, 195, 90, "10.00")
      SetGadgetFont(#staticvalue1, FontID3static)
      TextGadget(#staticvalue2, 250, 55, 195, 90, "10.00")
      SetGadgetFont(#staticvalue2, FontID3static)
      TextGadget(#staticvalue3, 490, 50, 195, 90, "10.00")
      SetGadgetFont(#staticvalue3, FontID3static)
      TextGadget(#staticvalue4, 735, 50, 195, 90, "10.00")
      SetGadgetFont(#staticvalue4, FontID3static)
      
      
       kontrola = Kontrola_pripojeni()
       If kontrola = 1
      
      WriteSerialPortString(#SerialPort, "#")
      
      oldtime = ElapsedMilliseconds()
      Repeat    
         Measure_winID = WindowEvent()
         getSERIALdata()
                  
         time = ElapsedMilliseconds()
         If (oldtime + 300) < time 
         Debug "data" "
         SetGadgetText(#staticvalue1, StrF(DATAA1/100.0,2))
         SetGadgetText(#staticvalue2, StrF(DATAC1/100.0,2))
         SetGadgetText(#staticvalue3, StrF(DATAD1/100.0,2))
         SetGadgetText(#staticvalue4, StrF(DATAE1/100.0,2))
         
         
         oldtime = time
         EndIf
         delay(1)
      Until Measure_winID = #PB_Event_CloseWindow   

Posted: Mon Dec 15, 2008 11:16 pm
by idle
I suspect your call to getserialdata() is not finishing.
it probably should be in thread.

Posted: Mon Dec 15, 2008 11:29 pm
by wh1sp3r
yeah, you are right. In this function, I am waiting for data every loop, Its strange, because, its only 10 ms to get data ..

Posted: Mon Dec 15, 2008 11:33 pm
by Kaeru Gaman
how would you know it only takes 10 secs?
seems it doesn't.

... why and how is impossible to say without the code of the procedure.