AddGadgetItem()...What??
AddGadgetItem()...What??
Good Afternoon,
I'm back with a crazy question.
If I open a window -
add an editor gadget -
add the read only attribute -
open a text file -
then try to display the text file in the editor gadget -
with the '-1' parameter, the file appears proper without scrollbars &
with the '0' parameter, the file appears backwards (last line first) with scrollbars
[code]
If OpenWindow(0, 132, 152, 650, 350, "Officer Phone List")
If CreateGadgetList(WindowID(0)) And LoadFont(0, "Arial", 11)
EditorGadget(0, 8, 8, 635, 335)
SetGadgetAttribute(0, #PB_Editor_ReadOnly, 1)
If ReadFile(0, "Text.txt")
While Eof(0) = 0
AddGadgetItem(0, -1, ReadString(0))
Wend
CloseFile(0)
Else
MessageRequester("Information","Couldn't open the file!")
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
CloseWindow (0)
EndIf
End
[/code]
Why does the text file appear in the gadget backwards?
Help!!
Enjoy the day,
Earl
I'm back with a crazy question.
If I open a window -
add an editor gadget -
add the read only attribute -
open a text file -
then try to display the text file in the editor gadget -
with the '-1' parameter, the file appears proper without scrollbars &
with the '0' parameter, the file appears backwards (last line first) with scrollbars
[code]
If OpenWindow(0, 132, 152, 650, 350, "Officer Phone List")
If CreateGadgetList(WindowID(0)) And LoadFont(0, "Arial", 11)
EditorGadget(0, 8, 8, 635, 335)
SetGadgetAttribute(0, #PB_Editor_ReadOnly, 1)
If ReadFile(0, "Text.txt")
While Eof(0) = 0
AddGadgetItem(0, -1, ReadString(0))
Wend
CloseFile(0)
Else
MessageRequester("Information","Couldn't open the file!")
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
CloseWindow (0)
EndIf
End
[/code]
Why does the text file appear in the gadget backwards?
Help!!
Enjoy the day,
Earl
Hi, in the command
the value of -1 instructs Purebasic to add the new line to the end of the editor gadget which means that the lines will appear in the correct order.
However, the command
instructs PB to position each new line at row 0 which is the first line in the editor gadget. This causes the lines to be placed in reverse order.
By the way, does anyone else have the problem of the scrollbars disappearing when SetGadgetAttribute(0, #PB_Editor_ReadOnly, 1) is used? Actually a part of the scrollbar remains!
Code: Select all
AddGadgetItem(0, -1, ReadString(0))
However, the command
Code: Select all
AddGadgetItem(0, 0, ReadString(0))
By the way, does anyone else have the problem of the scrollbars disappearing when SetGadgetAttribute(0, #PB_Editor_ReadOnly, 1) is used? Actually a part of the scrollbar remains!
I may look like a mule, but I'm not a complete ass.
I'd agree if Windows worked this way, but it doesn't.
Code: Select all
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
EditorGadget(0, 8, 8, 306, 133)
SendMessage_(GadgetID(0), #EM_SETREADONLY, 1, 0)
For a = 0 To 50
AddGadgetItem(0, a, "Line "+Str(a))
Next
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
I may look like a mule, but I'm not a complete ass.
hmm.. do I understand LoadFont incorrectly or do you miss this (or similar) from somewhere your code?
update: corrected FontID() and typing errors 
Code: Select all
SetGadgetFont(0,FontID(0))

-
- Enthusiast
- Posts: 326
- Joined: Mon Jan 01, 2007 7:20 pm