can't get the statusbar to work
Posted: Wed Nov 21, 2007 4:01 pm
Hi, i've made this simple text reader but the only problem i am having is that i can't get the statusbar to show the filename and path. 

Code: Select all
;============================================================================================================================
; Gadget and window constants
;============================================================================================================================
Enumeration ;- Window Constants
#Window_0
EndEnumeration
Enumeration ;- MenuBar Constants
#StatusBar_0
#MenuBar_0
EndEnumeration
Enumeration
#MENU_1
#MENU_2
#MENU_3
EndEnumeration
Enumeration ;- Gadget Constants
#Editor_0
EndEnumeration
Global ProgQuit.l
;============================================================================================================================
; Main window module
;============================================================================================================================
Procedure Open_Window_0()
If OpenWindow(#Window_0, 215, 0, 600, 300, "Text Reader", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
If CreateStatusBar(#StatusBar_0, WindowID(#Window_0))
AddStatusBarField(600)
EndIf
StatusBarText(0, 0, GetExtensionPart(FullPathName$) ,#PB_StatusBar_BorderLess )
If CreateMenu(#MenuBar_0, WindowID(#Window_0))
MenuTitle("File")
MenuItem(#MENU_1, "Open")
MenuItem(#MENU_2, "Save")
MenuBar()
MenuItem(#MENU_3, "Exit")
EndIf
If CreateGadgetList(WindowID(#Window_0))
EditorGadget(#Editor_0, 0, 0, 600, 260)
EndIf
EndIf
ProcedureReturn WindowID(#Window_0)
EndProcedure
;============================================================================================================================
;
;============================================================================================================================
Procedure ReadAFile()
FileName.s = OpenFileRequester("Select a file","","Text (.txt)|*.txt|All files (*.*)|*.*",0)
If FileName.s <> ""
FileId.l = ReadFile(#PB_Any, FileName.s)
If FileId.l
While Eof(FileId.l) = 0
Temp.s = ReadString(FileId.l)
AddGadgetItem(#Editor_0, -1, Temp.s)
Wend
CloseFile(FileId.l)
EndIf
EndIf
EndProcedure
;============================================================================================================================
; Try to open the main window now
;============================================================================================================================
If Open_Window_0()
;--------------------------------------------------
ProgQuit = 0
;--------------------------------------------------
Repeat ; Start of the event loop
;------------------------------------------------
Select WaitWindowEvent() ; This line waits until an event is received from Windows
;----------------------------------------------
Case #PB_Event_CloseWindow
;--------------------------------------------
Select EventWindow()
;------------------------------------------
Case #Window_0 : ProgQuit = 1
;------------------------------------------
EndSelect
;--------------------------------------------
Case #PB_Event_Menu
;--------------------------------------------
Select EventMenu()
;------------------------------------------
Case #MENU_1 : ReadAFile()
Case #MENU_2
Case #MENU_3 : ProgQuit = 1
;------------------------------------------
EndSelect
;--------------------------------------------
Case #PB_Event_Gadget
;--------------------------------------------
Select EventGadget()
;------------------------------------------
Case #Editor_0
;------------------------------------------
EndSelect
;--------------------------------------------
EndSelect
;------------------------------------------------
Until ProgQuit = 1 ; End of the event loop
;--------------------------------------------------
CloseWindow(#Window_0)
;--------------------------------------------------
EndIf
End