[4.0] Statusbar and threads (and chopped off text)

Just starting out? Need help? Post your questions and find answers here.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

[4.0] Statusbar and threads (and chopped off text)

Post by Trond »

1.
If the text of a statusbar field is set without the last, optional
parameter, then it becomes sunken again, even if it previously was
set to be raised or borderless. When I don't set the appearance I
don't expect it to change.

2.
The statusbar text is chopped off at 33

Code: Select all

OpenWindow(0, 0, 0, 440, 50, "StatusBar", #PB_Window_ScreenCentered | #PB_Window_Maximize)
CreateStatusBar(0, WindowID(0))
  AddStatusBarField(100000) ; Should be enough
Text.s
For I = 0 To 100
  Text.s + Str(I) + ", "
Next
StatusBarText(0, 0, Text)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
3.

Code: Select all

; Run this program, and verify that you can close the window by
; clicking the X. Then, run it again, click the title bar once and
; try to close the window. It won't close! You can't even move it.
Procedure ScrollStatusbar(Void)
  CreateStatusBar(0, WindowID(0))
  Repeat
    Delay(50)
  ForEver
EndProcedure
OpenWindow(0, 0, 0, 512, 300, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateThread(@ScrollStatusbar(), 0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Code: Select all

; Program ends even though the thread still runs (with and without
; threadsafe). Not a problem by itself, but watch the next snippet.
Procedure Apple(Void)
  Repeat
    For I = 0 To 800
      Delay(50)
    Next
  ForEver
EndProcedure
ID = CreateThread(@Apple(), 0)
Debug IsThread(ID)

Code: Select all

; Program is waiting for thread! Either this is a bug or the above
; is a bug. (With or without threadsafe.)
Procedure ScrollStatusbar(Void)
  CreateStatusBar(0, WindowID(0))
  Repeat
    Delay(50)
  ForEver
EndProcedure
OpenWindow(0, 0, 0, 512, 300, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateThread(@ScrollStatusbar(), 0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Code: Select all

; In fact, something more serious seems to be wrong:
Close = 0
Procedure ScrollStatusbar(Void)
  CreateStatusBar(0, WindowID(0))
  Repeat
    Delay(50)
  Until Close = 1
EndProcedure
OpenWindow(0, 0, 0, 512, 300, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateThread(@ScrollStatusbar(), 0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Close = 1
Fred
Administrator
Administrator
Posts: 18274
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

1. In Purebasic, when a flags isn't specified, its default value is used.

2. After some investigation, it seems to be a Windows limitation:

Code: Select all

OpenWindow(0, 0, 0, 1040, 50, "StatusBar", #PB_Window_ScreenCentered | #PB_Window_Maximize)
CreateStatusBar(0, WindowID(0))
  AddStatusBarField(800) ; Should be enough
  AddStatusBarField(500) ; Should be enough
Text.s
For I = 0 To 100
  Text.s + Str(I) + ", "
Next
;StatusBarText(0, 0, Text)
;StatusBarText(0, 1, Text)

; With API it's the same
;
SendMessage_(StatusBarID(0), #SB_SETTEXT, 0, Text)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
3. You can't create a control in another thread, or you will have to process the event loop in this thread. This is a Windows behaviour.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

3. You can't create a control in another thread, or you will have to process the event loop in this thread. This is a Windows behaviour.
But, it's not possible to process only the events of that gadget. So in reality it's only possible to have gadgets created in one thread in the entire program. That should be added to the manual.
Post Reply