It is currently Thu Jan 17, 2019 8:27 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How 2 design a loading dailog
PostPosted: Fri Dec 07, 2018 4:11 pm 
Offline
New User
New User
User avatar

Joined: Thu Dec 06, 2018 5:46 am
Posts: 6
A program that have many windows.
I want to design a noBoard loading window when the program is working something, while finish the event and next close the loading window.
In loading window show time , user could not do anything
:oops: :oops: :oops: tks


Top
 Profile  
Reply with quote  
 Post subject: Re: How 2 design a loading dailog
PostPosted: Fri Dec 07, 2018 4:35 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1529
Location: Germany
You can do it over Threads and PosteEvent to Main program...

Link to example: viewtopic.php?f=13&t=70645&p=521827

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: How 2 design a loading dailog
PostPosted: Fri Dec 07, 2018 4:53 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 543
Location: France
If you just want to display the elapsed time, just put a sticky and borderLess small window in the foreground and close it when done.

Code:
Enumeration
    #Win   
    #Timer_1_sec
    #Timer_5_sec
    #Btn_Quit
    #Win_Wait
    #Txt_Timer
EndEnumeration

OpenWindow(#Win, 0, 0, 640, 480, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#Btn_Quit, WindowWidth(#Win) - 100, WindowHeight(#Win) - 40, 80, 25, "Quitter")
AddWindowTimer(#Win, #Timer_1_sec, 1000)
AddWindowTimer(#Win, #Timer_5_sec, 5000)

OpenWindow(#Win_Wait, 0, 0, 200, 100, "", #PB_Window_ScreenCentered | #PB_Window_BorderLess)
TextGadget(#Txt_Timer, 50, 50, 100, 15, "", #PB_Text_Center)
SetWindowColor(#Win_Wait, #Gray)
StickyWindow(#Win_Wait, #True)

Repeat
    Select WaitWindowEvent()
        Case #PB_Event_Timer
            Select EventTimer()
                Case #Timer_1_sec
                    If IsWindow(#Win_Wait)
                        i + 1
                        SetGadgetText(#Txt_Timer, Str(i) + " Secs")
                    EndIf
                Case #Timer_5_sec
                    RemoveWindowTimer(#Win, #Timer_5_sec)
                    CloseWindow(#Win_Wait)
            EndSelect
           
        Case #PB_Event_CloseWindow
            Break
           
        Case #PB_Event_Gadget
            Select EventGadget()
                Case #Btn_Quit
                    Break   
            EndSelect
           
    EndSelect
ForEver

:wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: How 2 design a loading dailog
PostPosted: Sat Dec 08, 2018 7:57 am 
Offline
New User
New User
User avatar

Joined: Thu Dec 06, 2018 5:46 am
Posts: 6
yep :D StickyWindow is what I want 2 find. I just cant 2 describe the method
thks :lol:


Top
 Profile  
Reply with quote  
 Post subject: Re: How 2 design a loading dailog
PostPosted: Sun Dec 09, 2018 6:10 am 
Offline
New User
New User
User avatar

Joined: Thu Dec 06, 2018 5:46 am
Posts: 6
there is a new question,
when I run StickyWindow(#Win_Wait, #True) to put the waitingwindow to the topest, I still can control the mainwindow under it, How can I reset the waitingwindow like a MessageRequester box, when it popup I couldnot touch my mainwindow :oops: :oops:


Top
 Profile  
Reply with quote  
 Post subject: Re: How 2 design a loading dailog
PostPosted: Sun Dec 09, 2018 7:27 am 
Offline
New User
New User
User avatar

Joined: Thu Dec 06, 2018 5:46 am
Posts: 6
I have sloved all my problems , post my code after
Code:
Procedure DoEvents()
  Protected Event.l
  Repeat
    Event = WindowEvent()
    If Event = 0
      Sleep_(0)
    EndIf
  Until Event = 0
EndProcedure

;waiting window
Procedure SetLoadingWin(opeOrClo)
  If opeOrClo
    OpenWindow_waiting()
    StickyWindow(Window_waiting, #True)
    SetActiveWindow(Window_waiting)
    DisableWindow(Window_main, #True)
    DoEvents()
  Else
    DisableWindow(Window_main, #False)
    If IsWindow(Window_waiting)
      CloseWindow(Window_waiting)
    EndIf 
  EndIf
EndProcedure

may be of help to others


Top
 Profile  
Reply with quote  
 Post subject: Re: How 2 design a loading dailog
PostPosted: Sun Dec 09, 2018 12:01 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1529
Location: Germany
Something's very important:
1. There should always be only one event loop in the program.
2. Never use a delay in the event loop.
3. Only use WindowEvent() in special cases, otherwise always WaitWindowEvent(...)
4. Use EnableExplicit to avoid typing errors of variables

Added
5. Use not Long (Event.l) for default variables. Use Integer (Event.i). Integer is 32bit on x86 and 64bit on x64 programs.

P.S
Small example...

Update
Code:
;-TOP

EnableExplicit

; -----------------------------------------------------------------------------

Enumeration windows
  #Main
  #Dialog
EndEnumeration

Enumeration menus
  #MainMenu
EndEnumeration

Enumeration menuitems
  #MainMenuExit
  #MainMenuDialog
EndEnumeration

Enumeration gadgets
  #MainList
  #DialogString
  #DialogOk
EndEnumeration

; -----------------------------------------------------------------------------

Global ExitApplication

; -----------------------------------------------------------------------------

Procedure OpenDialogWindow()
 
  If OpenWindow(#Dialog, #PB_Ignore, #PB_Ignore, 300, 80, "Dialog Window", #PB_Window_SystemMenu, WindowID(#Main))
    StringGadget(#DialogString, 10, 10, 280, 25, "")
    ButtonGadget(#DialogOk, 150 - 30, 45, 60, 25 , "Ok")
 
    DisableWindow(#Main, 1)
   
  EndIf
 
EndProcedure

; -----------------------------------------------------------------------------

Procedure DoEventDialog()
  Select Event()
    Case #PB_Event_CloseWindow
      DisableWindow(#main, 0)
      CloseWindow(#Dialog)
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #DialogOk
          AddGadgetItem(#MainList, - 1, GetGadgetText(#DialogString))
          DisableWindow(#main, 0)
          CloseWindow(#Dialog)
      EndSelect
  EndSelect
EndProcedure

; -----------------------------------------------------------------------------

Procedure Main()
  Protected Event
 
  If OpenWindow(#main, #PB_Ignore, #PB_Ignore, 800, 600, "Main Window", #PB_Window_SystemMenu)
   
    CreateMenu(#MainMenu, WindowID(#Main))
    MenuTitle("&File")
    MenuItem(#MainMenuDialog, "&Open Dialog")
    MenuItem(#MainMenuExit, "E&xit")
   
    ListViewGadget(#MainList, 0, 0, WindowWidth(#Main), WindowHeight(#Main) - MenuHeight())
   
    ; Event Loop
    Repeat
      Event = WaitWindowEvent()
      Select Event
        Case #PB_Event_CloseWindow
          If EventWindow() = #Main
            ExitApplication = 1
          EndIf
         
        Case #PB_Event_Menu
          Select EventMenu()
            Case #MainMenuExit
              ExitApplication = 1
            Case #MainMenuDialog
              OpenDialogWindow()
          EndSelect
             
      EndSelect
     
      ; Do dialog events
      Select EventWindow()
        Case #Dialog
          DoEventDialog()
      EndSelect
     
    Until ExitApplication
  EndIf
 
EndProcedure : Main()

End

; -----------------------------------------------------------------------------

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye