Code: Select all
StringGadget(#TBKText, 13, 143, 580, 150, "",#PB_String_Multiline|#WS_VSCROLL|#ESB_DISABLE_LEFT | #ESB_DISABLE_RIGHT)
....
SetGadgetText(#TBKText, TBK(NodeItem)\TBKText)
...
Anyone knows?
Cecil
Code: Select all
StringGadget(#TBKText, 13, 143, 580, 150, "",#PB_String_Multiline|#WS_VSCROLL|#ESB_DISABLE_LEFT | #ESB_DISABLE_RIGHT)
....
SetGadgetText(#TBKText, TBK(NodeItem)\TBKText)
...
Code: Select all
StringGadget(0, 20, Top, 200, GadgetHeight, "", #PB_String_MultiLine | #WS_VSCROLL | #ESB_DISABLE_LEFT | #ESB_DISABLE_RIGHT)
Code: Select all
SetGadgetText(0, "Test")
Because this example only work on XP and use an unauthorizate way of useing the constants.cecilcheah wrote:Code: Select all
StringGadget(#TBKText, 13, 143, 580, 150, "",#PB_String_Multiline|#WS_VSCROLL|#ESB_DISABLE_LEFT | #ESB_DISABLE_RIGHT) .... SetGadgetText(#TBKText, TBK(NodeItem)\TBKText) ...
Code: Select all
Procedure EditorGadgetEnableTextWarp(Id); - Activate the automatic word-warp for a EditorGadget
GID=GadgetID(Id)
dc=GetWindowDC_(GID)
SendMessage_(GID, #EM_SETTARGETDEVICE ,dc ,-1)
ReleaseDC_(GID,dc)
EndProcedure
Someone has solved this? Using a stringgadget in win98cecilcheah wrote:How come when i add the following code in the StringGadget, all my text appears right aligned?
Code: Select all
StringGadget(#TBKText, 13, 143, 580, 150, "",#PB_String_Multiline|#WS_VSCROLL|#ESB_DISABLE_LEFT | #ESB_DISABLE_RIGHT) .... SetGadgetText(#TBKText, TBK(NodeItem)\TBKText) ...
Anyone knows?
Cecil
Code: Select all
Global editFont.l
editFont = LoadFont(0, "Verdana", 10)
; --> Procedure for creating multiline, wordwrap edit control
Procedure CreateWordrapEdit(controlId, x, y, width, height, text$)
; you can add #WS_EX_CLIENTEDGE For border
hEdit = CreateWindowEx_(#WS_EX_LEFT | #WS_EX_LTRREADING | #WS_EX_RIGHTSCROLLBAR, "Edit", text$, #WS_CHILD | #WS_GROUP | #WS_VSCROLL | #WS_TABSTOP | #WS_VISIBLE | #ES_AUTOVSCROLL | #ES_LEFT | #ES_MULTILINE , x, y, width, height, WindowID(0), controlId, GetModuleHandle_(0), 0)
SendMessage_(hEdit, #WM_SETFONT, editFont, 1)
ProcedureReturn hEdit
EndProcedure
; --> Procedure for setting edit control text
Procedure SetEditText(editId, editText$)
result = SendMessage_(editId, #WM_SETTEXT, 0, editText$)
ProcedureReturn result
EndProcedure
; --> Procedure for getting edit control text
Procedure.s GetEditText(editId)
; --> Get the text lenght (we add 1 for ending null)
tlen = SendMessage_(editId, #WM_GETTEXTLENGTH, 0, 0) + 1
editText$ = Space(tlen)
SendMessage_(editId, #WM_GETTEXT, tlen , @editText$)
ProcedureReturn editText$
EndProcedure
If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "My Edit Control") And CreateGadgetList(WindowID(0))
; --> Create our edit control
edit_0 = CreateWordrapEdit(0, 5, 5, 290, 150, "This is my wordrap Edit control")
ButtonGadget(1, 40, 165, 100, 20, "Change text")
ButtonGadget(2, 150, 165, 100, 20, "Get text")
Repeat
event = WaitWindowEvent()
Select event
Case #PB_EventGadget
Select EventGadgetID()
Case 1
; --> Setting the text
SetEditText(edit_0, "This is my new text.")
Case 2
; --> Getting the text
eText$ = GetEditText(edit_0)
MessageRequester("The text is", eText$)
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow
EndIf
End
In this code, how can I set the focus in a created "CreateWordrapEdit"?Sparkie wrote:I'm not at home so I can't test this on Win98, but this is a Win32API multiline Edit Control with wordwrap. I assume that's what you are looking for
I would think the standard PB StringGadget could do the same, but for some reason it always has the #ES_AUTOHSCROLL flag, and I have yet to find a way to prevent it.Code: Select all
Global editFont.l editFont = LoadFont(0, "Verdana", 10) ; --> Procedure for creating multiline, wordwrap edit control Procedure CreateWordrapEdit(controlId, x, y, width, height, text$) ; you can add #WS_EX_CLIENTEDGE For border hEdit = CreateWindowEx_(#WS_EX_LEFT | #WS_EX_LTRREADING | #WS_EX_RIGHTSCROLLBAR, "Edit", text$, #WS_CHILD | #WS_GROUP | #WS_VSCROLL | #WS_TABSTOP | #WS_VISIBLE | #ES_AUTOVSCROLL | #ES_LEFT | #ES_MULTILINE , x, y, width, height, WindowID(0), controlId, GetModuleHandle_(0), 0) SendMessage_(hEdit, #WM_SETFONT, editFont, 1) ProcedureReturn hEdit EndProcedure ; --> Procedure for setting edit control text Procedure SetEditText(editId, editText$) result = SendMessage_(editId, #WM_SETTEXT, 0, editText$) ProcedureReturn result EndProcedure ; --> Procedure for getting edit control text Procedure.s GetEditText(editId) ; --> Get the text lenght (we add 1 for ending null) tlen = SendMessage_(editId, #WM_GETTEXTLENGTH, 0, 0) + 1 editText$ = Space(tlen) SendMessage_(editId, #WM_GETTEXT, tlen , @editText$) ProcedureReturn editText$ EndProcedure If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "My Edit Control") And CreateGadgetList(WindowID(0)) ; --> Create our edit control edit_0 = CreateWordrapEdit(0, 5, 5, 290, 150, "This is my wordrap Edit control") ButtonGadget(1, 40, 165, 100, 20, "Change text") ButtonGadget(2, 150, 165, 100, 20, "Get text") Repeat event = WaitWindowEvent() Select event Case #PB_EventGadget Select EventGadgetID() Case 1 ; --> Setting the text SetEditText(edit_0, "This is my new text.") Case 2 ; --> Getting the text eText$ = GetEditText(edit_0) MessageRequester("The text is", eText$) EndSelect EndSelect Until event = #PB_Event_CloseWindow EndIf End
* Edited to clean it up a little
Code: Select all
SetFocus_(edit_0)