I'm trying to see if I replace:
CONTROLCMD(w1,1,@RTGETLINE,a-1,line$,255)
w1 is my window
1 is the rich edit control
a-1 is the line number I want
line$ is the string to store the line text.
with the EM_GETLINE message will make another difference on speed.
a link to it is here:
https://docs.microsoft.com/en-us/windows/win32/controls/em-getline
I'm having trouble translating it into a SENDMESSAGE command, can any one help with this please?
Thanks,
Andy.
Andy, have a look here:
http://www.jasinskionline.com/windowsapi/ref/e/em_getline.html
Brian
Thanks Brian,
That helps but still struggling with it.
Andy.
Andy use something like this:
SendMessage (riched, EM_GETLINE, i, pt) ' get line from richedit control
riched is control handler
i - is your line number
pt is a pointer->Text from a line i
Like Aurel said, this is getting the second line for me just fine
istring buffer[1000]
_SendMessage(GetDlgItem(w1.hwnd, RICHEDIT_1), EM_GETLINE, 1, &buffer)
if the above code keeps failing for some reason, according to MSDN
QuoteThe first word of the buffer specifies the maximum number of characters that can be copied to the buffer.
That would be something like this
istring buffer[1000]
WORD s = 1000 ' 1000 = 256 * 3 + 232
buffer[0] = s >> 8 ' 3
buffer[1] = s & 0xFF ' 232
_SendMessage(GetDlgItem(w1.hwnd, RICHEDIT_1), EM_GETLINE, 1, &buffer)
I think that i use
char Lbuff[1024]
but istring should be fine too.
Thanks guys,
Not had a chance today as the electricity has been off today for over 5 hours.
Will have a go...
Thanks,
Andy.
Well I just tried Fasecero's way, and Aurel's looks correct too.
But I'm obviously making a basic mistake here...
In a console screen I can print the buffer, and the line text if good, but on passing it to a sub routine it does nothing as it's not recognised.
Here are the parameters that the sub routine gets:
SUB ColourLineZ(int LineNoIn,string LineToWords,int Offset)
LineToWords is what the buffer should be.
Help please!
Andy.
Are you remembering that:
IWBASIC defaults to passing by value for all numeric types and passing by reference for strings, UDT's, etc.
When calling a sub the string LineToWords is passed by reference which is the same as a pointer.
So with in the sub you don't use &LineToWords, just use LineToWords.
I think I'm right, if not someone please correct me.
Later,
Clint
Yes ,i think that you have a right .
Andy you can also use type POINTER and cast it <string>tbuffer
Well I've managed to load msftedit.dll and use
uint rHandle = CreateWindowEx(0,MSFTEDIT_CLASS,"",0x50B010C4,110,100,EndButtons-100,480,w1.hwnd,1,GetModuleHandle(0),0)
to create my rich edit control, however, the EM_GETLINE message no longer works...
ISTRING rbuffer[1000]
SENDMESSAGE(HandleIn,EM_GETLINE,a-1,&rbuffer)
HandleIn - handle to the rich edit control
a-1 - the line number I want to get text for
rbuffer - the buffer that stores the line text
If I go back to creating the rich edit control the normal IWB way, the EM_GETLINE code works?
Help please..
Thanks,
Andy.
Why are you using HandleIn instead of rHandle? Or am I wrong!
Brian
Brian,
Forgot to say the code is in a sub routine, rHandle is passed to it as "HandleIn", even so, if I use rHandle directly it still doesn't return any text.
I have also tried Fasecero's alternative way of setting the buffer with a size before hand - still nothing.
Andy.
The new richedit is probably unicode internally. Try EM_GETLINEW with some unicode buffer.
Thanks for that, was wondering the same thing.
I tried what you suggested and to cut a long story short decided that going down this path is becoming very hard work as it is simply not working.
So I have begun trying with my own "undo" buffer for undo's / redo's, and so far it works for characters typed. I will obviously need to do more work on this but it was either a case of spend time solving the built in undo feature or write my own undo / redo code.
Thanks again,
Andy.
:)