EM_GETSEL / EM_SETSEL not working

This is a discussion on EM_GETSEL / EM_SETSEL not working within the Windows Programming forums, part of the Platform Specific Boards category; I have a subclassed edit control. when a user clicks the control and the WM_SETFOCUS message is sent I need ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    2

    EM_GETSEL / EM_SETSEL not working

    I have a subclassed edit control.

    when a user clicks the control and the WM_SETFOCUS message is sent I need to determine the character location of the carat.

    If I send an EM_GETSEL to the control in the WM_SETFOCUS handler I always get 0,0 back. I can send messages to get the text and to get the text length and they work fine.

    If I send the EM_GETSEL message to the control from any place other than the WM_SETFOCUS handler it works fine. The same holds true for the EM_SETSEL message.

    Any help/workaround is appreciated.

    LarryMc

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Old story...

    Guy walks into his doctors office. Hooks his thumb over the edge of the desk and whacks it with his shoe...

    He looks at the doctor and says: "Doc, it hurt like all get every time I do that..."

    Do you know what the doctor's response was?

    Yep... doc says:"Then don't do it."


    At the moment the WM_SETFOCUS is sent, the edit control does not have a caret. The idea is that you should set the caret and selection when you receive that message. So the best answer is...

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    2
    The idea is that you should set the caret and selection when you receive that message

    If that's the case then why doesn't the EM_SETSEL set the selection in the WM_SETFOCUS handler?

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Perhaps you should try processing the EN_SETFOCUS and EN_KILLFOCUS notifications in your message loop instead...

    Edit Control

    Also, do a little searching in this sub-forum, I recently ran into a real mess when trying to restore focus after the window is backgrounded, you might find some help in that thread.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why is this not working
    By mouse666666 in forum C Programming
    Replies: 3
    Last Post: 02-08-2010, 10:25 PM
  2. Replies: 9
    Last Post: 03-30-2009, 04:09 AM
  3. Why isn't this working?
    By incognito in forum Windows Programming
    Replies: 1
    Last Post: 12-18-2003, 12:59 PM
  4. PC not working!
    By Xoid in forum Tech Board
    Replies: 12
    Last Post: 06-12-2003, 03:27 AM
  5. Why is this not working??? PLEASE HELP ANYONE!!!!
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 06-26-2002, 01:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21