Page 1 of 1

Window not refreshed

Posted: Sat Jun 23, 2007 5:49 am
by clipper
In this code the window is not refreshed (empty) after I have called Openfilerequester()
A Reszisewindow() will not work!
What can I do, that the windows gadgets are shown during the fileoperations?

Code: Select all

hwnd = OpenWindow(0, 0,0,300,300, "", #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_SystemMenu )
If hwnd
   If CreateGadgetList(hwnd)
      TextGadget(0, 10, 33,  70,  14, "Item:")
      StringGadget( 1, 80, 30, 175,  20, "")
      If CreateToolBar(2,hwnd)
         ToolBarStandardButton(0, #PB_ToolBarIcon_Open)
         Repeat
            EventID = WaitWindowEvent() 
            Select EventID
               Case #PB_Event_Menu
                  menu = EventMenu()
                  Select menu
                     Case 0
                        file.s=OpenFileRequester("Load", "Text (*.txt)|*.txt", "", 0)
                        ; Do some longer fileactions - here Delay(5000)
                        Delay(5000)
                  EndSelect
            EndSelect 
         Until EventID = #PB_Event_CloseWindow
      EndIf
   EndIf
EndIf

Posted: Sat Jun 23, 2007 7:24 am
by Edwin Knoppert
UpdateWindow_() API..

Posted: Sat Jun 23, 2007 8:34 am
by Trond
You could do the file operations in a thread. As long as the window doesn't process events with WaitWindowEvent() it won't refresh.

Posted: Sat Jun 23, 2007 8:40 am
by ts-soft
This can help a bit:

Code: Select all

Case 0
  DisableWindow(0, #True)
  file.s=OpenFileRequester("Load", "Text (*.txt)|*.txt", "", 0)
  ; Do some longer fileactions - here Delay(5000)
  Delay(5000)
  DisableWindow(0, #False) 

Posted: Sat Jun 23, 2007 10:13 am
by Edwin Knoppert
Trond wrote:You could do the file operations in a thread. As long as the window doesn't process events with WaitWindowEvent() it won't refresh.
http://www.hellobasic.com/cgi-bin/forum ... 1177591460

(2nd message)

Posted: Sat Jun 23, 2007 10:21 am
by clipper
Thanks a lot. :)

Posted: Sat Jun 23, 2007 12:52 pm
by Baldrick
Bit late maybe clipper, I am on the Bourbons atm. :twisted:
This might help a little....

Code: Select all

Procedure DoSumStuff(Sumparameter.s) 
 file$=GetFilePart(Sumparameter)
  Debug "Started processing > "+file$
  Delay(5000) 
  Debug "Finished processing > "+file$
EndProcedure 

hwnd = OpenWindow(0, 0,0,300,300, "", #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_SystemMenu ) 
If hwnd 
   If CreateGadgetList(hwnd) 
      TextGadget(0, 10, 33,  70,  14, "Item:") 
      StringGadget( 1, 80, 30, 175,  20, "") 
      If CreateToolBar(2,hwnd) 
         ToolBarStandardButton(0, #PB_ToolBarIcon_Open) 
         Repeat 
            EventID = WaitWindowEvent() 
            Select EventID 
               Case #PB_Event_Menu 
                  menu = EventMenu() 
                  Select menu 
                     Case 0 
                        file.s=OpenFileRequester("Load","", "All files (*.*)|*.*", 0) 
                        ; Do some longer fileactions - here Delay(5000) 
                        If file
                         mythread=CreateThread(@DoSumStuff(),file)
                        EndIf  
                  EndSelect 
            EndSelect 
         Until EventID = #PB_Event_CloseWindow 
      EndIf 
   EndIf 
EndIf 
If IsThread(mythread)
 KillThread(mythread) 
 Debug "thread killed"
  Else 
 Debug "thread not active"
EndIf 
End 
Hmm, pretty sad I am sitting at home on the drink, looking at the forum while talking to some friends on the phone who live 300 Km away. ( who are also on the drink btw) :lol: