"set the first word of this buffer..."

G

Guest

I need to extract text from a single-line edit control using this:
SendMessage( // returns LRESULT in lResult
(HWND) hWndControl, // handle to destination control
(UINT) EM_GETLINE, // message ID
(WPARAM) wParam, // = (WPARAM) () wParam;
(LPARAM) lParam // = (LPARAM) (LPCTSTR) lParam;
);

where lParam is a buffer for text.
The docs say:
"Before sending the message, set the first word of this buffer to the size,
in TCHARs, of the buffer. For ANSI text, this is the number of bytes; for
Unicode text, this is the number of characters. The size in the first word
is overwritten by the copied line."

How to do that if the buffer is:
TCHAR[200] buffer;
 
V

Victor Bazarov

I need to extract text from a single-line edit control using this:
SendMessage( // returns LRESULT in lResult
(HWND) hWndControl, // handle to destination control
(UINT) EM_GETLINE, // message ID
(WPARAM) wParam, // = (WPARAM) () wParam;
(LPARAM) lParam // = (LPARAM) (LPCTSTR) lParam;
);

where lParam is a buffer for text.
The docs say:
"Before sending the message, set the first word of this buffer to the
size, in TCHARs, of the buffer. For ANSI text, this is the number of
bytes; for Unicode text, this is the number of characters. The size
in the first word is overwritten by the copied line."

How to do that if the buffer is:
TCHAR[200] buffer;

Please post Windows programming questions to a Windows newsgroup. I
recommend 'comp.os.ms-windows.programmer' (and below). In C++ there is
no legal way to do what you're told to do. The code you are supposed
to write (if I read your description correctly) has undefined behaviour.

V
 
R

Ron Natalie

I need to extract text from a single-line edit control using this:
SendMessage( // returns LRESULT in lResult
(HWND) hWndControl, // handle to destination control
(UINT) EM_GETLINE, // message ID
(WPARAM) wParam, // = (WPARAM) () wParam;
(LPARAM) lParam // = (LPARAM) (LPCTSTR) lParam;
);

where lParam is a buffer for text.
The docs say:
"Before sending the message, set the first word of this buffer to the size,
in TCHARs, of the buffer. For ANSI text, this is the number of bytes; for
Unicode text, this is the number of characters. The size in the first word
is overwritten by the copied line."

How to do that if the buffer is:
TCHAR[200] buffer;
You really will do better asking these Windows questions in a group with
microsoft in it's name. Unfortunately, the windows messaging system
relies on casting pointers to integral types all over the place.

((WORD*)buffer)[0] = 200;

Yes it is hideous.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top