Larry
New Member
Posts: 40
|
Post by Larry on Apr 12, 2019 12:00:55 GMT -5
I am trying to get the text editor control to word wrap without having to use api calls. The following 2 lines of code should be theoretically all one would need, but yet it still does not word wrap. Also when I name a button as default so all I have to di is hit enter to activate that button, it does not work either I use #handle.default.
Any help would be greatly appreciated
texteditor #journal.ted,15, 5, 980, 625 stylebits #journal.ted, 0,_ES_AUTOHSCROLL or _WS_HSCROLL,0,0
|
|
|
Post by tsh73 on Apr 12, 2019 12:31:46 GMT -5
It works this way only in Dialog window
|
|
|
Post by Rod on Apr 12, 2019 12:41:38 GMT -5
Only a textbox will respond to stylebits. The texteditor is not a native windows control, its a custom "widget" and will not respond to stylebits. Look at Alyce's site and look at her rich text editor control for a more flexible solution.
|
|
Larry
New Member
Posts: 40
|
Post by Larry on Apr 12, 2019 15:53:10 GMT -5
Only a textbox will respond to stylebits. The texteditor is not a native windows control, its a custom "widget" and will not respond to stylebits. Look at Alyce's site and look at her rich text editor control for a more flexible solution. Thanks Rod, I've seen that example, and I'm quite sure I have it. I just have to look for it. It would make a nicer program in the long run.
|
|
Larry
New Member
Posts: 40
|
Post by Larry on Apr 13, 2019 11:19:41 GMT -5
Only a textbox will respond to stylebits. The texteditor is not a native windows control, its a custom "widget" and will not respond to stylebits. Look at Alyce's site and look at her rich text editor control for a more flexible solution.
Ok Rod I turned the texteditor control into a textbox, now I have the problem that everything word wraps even stuff like song lyrics that I do not want to word wrap. How do I get it to only word wrap on certain types of files?
I messed with Alyce's rich text editor control trying to figure it out, but for whatever reason I have no clue how to change the font, or the color, or anything in it for that matter. I should be able with it to change the font to whatever size I wand and make the text whatever color etc. The problem is I do not understand how to modify the program from the default settings.
|
|
|
Post by Rod on Apr 13, 2019 13:06:09 GMT -5
There are several controls that will display text, even a browser or graphicbox. Each has their own method of wrapping or not text. Most will respond to the control characters CR LF and wrap early. You should show us the kind of text and display you are aiming for to get specific advice. Ie how wide in total when should it wrap and what should wrap early. Text display is a lot more complex than folks think.
|
|
Larry
New Member
Posts: 40
|
Post by Larry on Apr 13, 2019 16:25:42 GMT -5
There are several controls that will display text, even a browser or graphicbox. Each has their own method of wrapping or not text. Most will respond to the control characters CR LF and wrap early. You should show us the kind of text and display you are aiming for to get specific advice. Ie how wide in total when should it wrap and what should wrap early. Text display is a lot more complex than folks think. The textedit control is 980 wide by 625 high. that version works well except for the word wrapping. The Textbox version is the same width and height but it wraps everything even if it is not suppposed to be wrapped. Essentially I am doing standard text I put brackets around any chapter titles. I put a "`" on a line by itself to tell it to start a new paragraph. Other than that, I just type the text into the textedit control and save it. Songs for example should be a line at a time, while books and short stories should be wrapped in paragraph form.
Hope this helps.
|
|
|
Post by metro on Apr 13, 2019 19:15:41 GMT -5
I am trying to get the text editor control to word wrap without having to use api calls. The following 2 lines of code should be theoretically all one would need, but yet it still does not word wrap. Also when I name a button as default so all I have to di is hit enter to activate that button, it does not work either I use #handle.default.
Any help would be greatly appreciated
texteditor #journal.ted,15, 5, 980, 625 stylebits #journal.ted, 0,_ES_AUTOHSCROLL or _WS_HSCROLL,0,0 The original brief called for no API but if frustration gets the better of you this may fit (fill) the bill
I'm not sure where I got it from, I seem to collect a lot of other peoples code. I tip my hat to the unknown coder EDIT....am I correct LB5 has word wrap for the texteditor
nomainwin WindowWidth=900:WindowHeight=600 UpperLeftX=1:UpperLeftY=1
Menu #Tedit, "&File", "&Open", [open],_ "&Save", [save], "E&xit", [quit] Menu #Tedit, "&Edit", "&Cut", [cut],_ "C&opy", [copy], "&Paste", [paste],_ "&Undo", [undo] Menu #Tedit, "&Font", "&Arial 14", [arial14],_ "A&rial 18", [arial18],_ "&Courier New 14", [courier14],_ "Courier &New 18",[courier18]
open "Barebones Texteditor" for window as #Tedit print #Tedit, "trapclose [quit]" print #Tedit, "resizehandler [resizeIt]"
hT=CreateTextEdit(hwnd(#Tedit), 1, 1, 800, 500)
call SetFocus hT
wait
[quit] if hFont<>0 then call DeleteObject hFont close #Tedit
[resizeIt] ww=WindowWidth:wh=WindowHeight call MoveWindow hT, 1, 1, ww-2, wh-2 wait
[open] filedialog "Open","*.txt",file$ if file$="" then wait open file$ for input as #f txt$=input$(#f, lof(#f)) close #f call SetWindowText hT, txt$ wait
[save] filedialog "Save","*.txt",sfile$ if sfile$="" then wait if right$(sfile$,4)<>".txt" then sfile$=sfile$+".txt" end if open sfile$ for output as #f txt$=GetWindowText$(hT) print #f, txt$ close #f wait
[cut] ret = SendMessageLong(hT,_WM_CUT,0,0) wait
[copy] ret = SendMessageLong(hT,_WM_COPY,0,0) wait
[paste] ret = SendMessageLong(hT,_WM_PASTE,0,0) wait
[undo] ret = SendMessageLong(hT,_WM_UNDO,0,0) wait
[arial14] if hFont<>0 then call DeleteObject hFont hFont=CreateFont("arial",14) ret = SendMessageLong(hT,_WM_SETFONT,hFont,1) wait
[arial18] if hFont<>0 then call DeleteObject hFont hFont=CreateFont("arial",18) ret = SendMessageLong(hT,_WM_SETFONT,hFont,1) wait
[courier14] if hFont<>0 then call DeleteObject hFont hFont=CreateFont("courier new",14) ret = SendMessageLong(hT,_WM_SETFONT,hFont,1) wait
[courier18] if hFont<>0 then call DeleteObject hFont hFont=CreateFont("courier new",18) ret = SendMessageLong(hT,_WM_SETFONT,hFont,1) wait
Function SendMessagePtr(hWnd,msg,w,p$) calldll #user32, "SendMessageA", hWnd as ulong, _ msg as long, w as long, p$ as ptr,_ SendMessagePtr as long end function
function SendMessageLong(hWnd,msg,w,l) calldll #user32, "SendMessageA", hWnd as ulong, _ msg as long, w as long, l as long,_ SendMessageLong as long end function
sub SetFocus hWnd calldll #user32, "SetFocus", hWnd as ulong,_ result as ulong end sub
sub SetWindowText hWnd, txt$ calldll #user32, "SetWindowTextA", hWnd as ulong,_ txt$ as ptr, result as void end sub
function GetWindowText$(hWnd) total = GetWindowTextLength(hWnd) Title$=space$(total)+Chr$(0):l= Len(Title$)
calldll #user32, "GetWindowTextA", hWnd as ulong,_ Title$ as ptr, l as long, result as long GetWindowText$=trim$(Title$) end function
function GetWindowTextLength(hW) calldll #user32, "GetWindowTextLengthA",_ hW as ulong,_ GetWindowTextLength as long end function
Function CreateTextEdit(hW, x, y, w, h) style = _WS_CHILDWINDOW OR _WS_BORDER _ OR _WS_VISIBLE or _ES_MULTILINE or _WS_VSCROLL hInst=GetWindowLong(hW, _GWL_HINSTANCE)
calldll #user32, "CreateWindowExA",_ 0 as long,"EDIT" as ptr,_ "" as ptr, style as long,_ x as long,y as long,w as long,h as long,_ hW as ulong, 0 as long, hInst as ulong,_ 0 as long, CreateTextEdit as ulong end function
Function GetWindowLong(hW, type) calldll #user32, "GetWindowLongA", _ hW as ulong, type as long,_ GetWindowLong as ulong End Function
Function CreateFont(fontname$, fontheight) fontname$ = fontname$ + chr$(0) Calldll #gdi32, "CreateFontA",_ fontheight as long,_ 0 as long,0 as long,0 as long,_ 0 as long,0 as long,0 as long,_ 0 as long,0 as long,0 as long,_ 0 as long,0 as long,0 as long,_ fontname$ as PTR,_ CreateFont as ulong end function
sub DeleteObject hObject calldll #gdi32,"DeleteObject",_ hObject as ulong,_ r as long end sub
sub MoveWindow hW, x, y, w, h calldll #user32, "MoveWindow",_ hW as ulong, x as long, y as long,_ w as long, h as long,_ 1 as boolean, result as long end sub
|
|
|
Post by Rod on Apr 14, 2019 3:20:02 GMT -5
I am not sure I have grasped the problem just yet. Text is controlled by "control" characters if you want some text to be longer than the display and some to be wrapped within it you would need to insert control characters. By changing how the control itself works you apply the rule to all text.
nomainwin texteditor #main.te 0, 0, 200, 200 open "Text" for window as #main #main "trapclose [quit]" nl$=chr$(13)+chr$(10) t$(1)="this is short line one." t$(2)="this is short"+nl$+"line two forced to wrap early." t$(3)="this is a very long line that does not wrap it just keeps going." t$(4)="this is a very long line that does"+nl$+"not keep going we force it to wrap." for n= 1 to 4 #main.te t$(n) next wait [quit] close #main end
|
|