December 04, 2020, 04:32:35 am

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


EM_GETLINE message

Started by Andy, March 31, 2020, 05:08:46 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian


Andy

Thanks Brian,

That helps but still struggling with it.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

aurelCB

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
forum for hobby programming:<br />https://aurelsoft.ucoz.com

fasecero

March 31, 2020, 04:47:15 pm #4 Last Edit: March 31, 2020, 04:58:44 pm by fasecero
Like Aurel said, this is getting the second line for me just fine

Code Select
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

Code Select
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)

aurelCB

I think that i use 
char Lbuff[1024]

but istring should be fine too.
forum for hobby programming:<br />https://aurelsoft.ucoz.com

Andy

Thanks guys,

Not had a chance today as the electricity has been off today for over 5 hours.

Will have a go...

Thanks,

Andy.
 
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

ckoehn

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

aurelCB

Yes ,i think that you have a right .
Andy you can also use type POINTER and cast it <string>tbuffer
forum for hobby programming:<br />https://aurelsoft.ucoz.com

Andy

July 02, 2020, 03:43:26 am #10 Last Edit: July 02, 2020, 04:03:35 am by Andy
Well I've managed to load msftedit.dll and use

Code Select
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...

Code Select
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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

Why are you using HandleIn instead of rHandle? Or am I wrong!

Brian

Andy

July 02, 2020, 04:42:18 am #12 Last Edit: July 02, 2020, 05:11:50 am by Andy
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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

The new richedit is probably unicode internally. Try EM_GETLINEW with some unicode buffer.

Andy

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.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.