EM_GETSEL, WM_COPY brings no effect ?!

After I hook mouse events, I need to get selected text
in the active window.
hActive = GetActiveWindow();
  if ( hActive ) {
    msgResult = SendMessage ( hActive, WM_COPY , 0, 0 );
    .... // tried to copy selection to clipboard
or this way :
    result = SendMessage ( hActive, EM_GETSEL , NULL, NULL);
    ... // tried to get selection without envolving
        // a clipboard
Both of them do nothing ! :((
WM_COPY   doesn't change clipboard's content
EM_GETSEL brings 32 bits full of 0's
On the other hand
      SendMessage ( hActive, WM_CLOSE , 0, 0 );
closes the active window immediately (as it should)

What's the reason that active windows listen's to WM_CLOSE,
but ignores WM_COPY and EM_GETSEL ?
Thank you !
Who is Participating?
alexoConnect With a Mentor Commented:
WM_COPY and EM_GETSEL are specific to edit boxes.  The following explains:

An application sends the WM_COPY message to an edit control or combo box to copy the current selection to the clipboard in CF_TEXT format.  When sent to a combo box, the WM_COPY message is handled by its edit control.  This message has no effect when sent to a combo box with the CBS_DROPDOWNLIST style.

An application sends an EM_GETSEL message to get the starting and ending character positions of the current selection in an edit control.  In a rich edit control, if the selection is not entirely contained in the first 64K, use the message EM_EXGETSEL.

The EM_GETSELTEXT message retrieves the currently selected text in a rich edit control.

Other contols (windows, whatever) implement their own methods of copying data to the clipboard.  Usually by means of WM_COMMAND messages.  You can see it using a tool like Spy++.

The bad news are: there is no UNIVERSAL way of asking a an application to copy data from a window to the clipboard.
geniekAuthor Commented:
Btw : of course, there is some selected text in the active window ..
This depends from Apps. Can be some Apps simple ignore
such message, or , more bad , by message as WM_COPY
delete OS from PC! But WM_CLOSE it is system message
and all Windows application (not DOS!) reacts in same
manner to it(but you can simple write Apps, that
ignore this message, too!).
geniekAuthor Commented:
That what I thought :(( Very possible reason.
They just don't have to react and they don't ...
How can I slove the problem in the other way ?
geniekAuthor Commented:

Thank's a lot !
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.