can't get the statusbar to work

Just starting out? Need help? Post your questions and find answers here.
cegy
User
User
Posts: 10
Joined: Fri Aug 19, 2005 2:39 pm

can't get the statusbar to work

Post by cegy »

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
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

First of all

Code: Select all

StatusBarText(0, 0, GetExtensionPart(FullPathName$)  ,#PB_StatusBar_BorderLess )
should be

Code: Select all

StatusBarText(#StatusBar_0, 0, GetExtensionPart(FullPathName$)  ,#PB_StatusBar_BorderLess )
and secondly where did you declare FullPathName$?
It helps a lot to add EnableExplizit at the top of your code...
Windows 7 & PureBasic 4.4
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Add this line after line 56 (after selecting file to open)

Code: Select all

StatusBarText(#StatusBar_0, 0, FileName)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
cegy
User
User
Posts: 10
Joined: Fri Aug 19, 2005 2:39 pm

Post by cegy »

Sparkie wrote:Add this line after line 56 (after selecting file to open)

Code: Select all

StatusBarText(#StatusBar_0, 0, FileName)
Thanks mate :)
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

You're welcome :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply