Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use EM_GETSEL?

884 views
Skip to first unread message

Frank

unread,
Sep 16, 2002, 1:35:38 PM9/16/02
to
I am writing an ActiveX control, similar to an EditBox. I
need to determine the cursor position and whether or not
text is selected during the OnChar method. It's my
understanding that I should use the SendMessage with
EM_GETSEL; but I can't seem to figure out how to use it
correctly.

Does any one have or know of an example of using
EM_GETSEL? I'm using C++ 6.0.

Thanks,
Frank.

Frank

unread,
Sep 16, 2002, 2:56:57 PM9/16/02
to

Jeff Partch

unread,
Sep 16, 2002, 6:27:46 PM9/16/02
to
"Frank" <frank...@yahoo.com> wrote in message
news:1470d01c25da7$78e72110$37ef2ecf@TKMSFTNGXA13...

DWORD dwStart = 0, dwEnd = 0;
SendMessage(hWndEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);

--
Jeff Partch [MVP]

Frank

unread,
Sep 17, 2002, 9:12:23 AM9/17/02
to
Thanks Jeff.

For some reason it wouldn't let me do that, it was forcing me to use a
different send message; but chopping off the hWnd and calling
CWnd::SendMessage worked using the rest of the call.

Thanks again.

"Jeff Partch" <je...@mvps.org> wrote in message
news:uzx9eAdXCHA.1912@tkmsftngp09...

Jeff Partch

unread,
Sep 17, 2002, 9:39:19 AM9/17/02
to
"Frank" <frank...@yahoo.com> wrote in message news:ey2HyukXCHA.2496@tkmsftngp09...

> Thanks Jeff.
>
> For some reason it wouldn't let me do that, it was forcing me to use a
> different send message; but chopping off the hWnd and calling
> CWnd::SendMessage worked using the rest of the call.

Sorry about posting an SDK sample to the MFC group, Frank. I don't know what I was thinking. Glad
you got it sorted out, but FYI in an MFC app the CEdit class also has an overloaded GetSel member
function that wraps this form of the SendMessage/EM_GETSEL call and is possibly slightly easier to
use -- if only because it requires less typing.

--
Jeff Partch [MVP]

0 new messages