Thread: cursor location

  1. #1
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377

    Red face cursor location

    I need to get the cursor location inside my RichEdit, There is no such thing as EM_GETCURSOR, or anything...
    All i can get is the scroll position of my vscrollbar...
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  2. #2
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    Quote Originally Posted by MSDN
    EM_GETSEL
    The EM_GETSEL message retrieves the starting and ending character positions of the current selection in an edit control. You can send this message to either an edit control or a rich edit control.
    http://msdn.microsoft.com/library/de.../em_getsel.asp

    -r1ck0r

  3. #3
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    I don't want the selection, i just want the current cursor location. Or can i get that from selection???
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  4. #4
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    If no text is selected, both the starting character position and the ending character position will be equal, this value will be the cursor position.

  5. #5
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    thanks.
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  6. #6
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    I need to convert that number to int, do you have any idea how to do that?
    Heres what i tryed:
    Code:
    int		where = 0;
    LPDWORD		where1 = 0;
    
    SendMessage(children.eBook, EM_GETSEL, 0, (LPARAM)where1);
    where = (int)where1; // this doesn't work
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  7. #7
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Code:
    DWORD start;
    DWORD end;
    SendMessage(hwnd, EM_GETSEL, (WPARAM) &start, (LPARAM) &end);
    
    where = end;
    Last edited by anonytmouse; 12-24-2005 at 04:19 AM.

  8. #8
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    291
    althought I have no idea (remember your excelent comment?) , you should get the client rect to get the entire client area, the get the edit rect, and finaly get the cursor position, with some simple calculations you will be able to relate those 10 values to get the cursor position inside the edit

    niara

  9. #9
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    ^That's a whole lot of fuss considering the EM_GETSEL message does the exact thing he wants, why reinvent the wheel?

  10. #10
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Quote Originally Posted by r1ck0r
    ^That's a whole lot of fuss considering the EM_GETSEL message does the exact thing he wants, why reinvent the wheel?
    agree.
    So heres what i want to do...
    I want to write down the current location of cursor on a status control,
    therefor i need the string.
    But i just don't know how todo this...
    Code:
    char text[50];
    int location = 0;
    DWORD where = 0;
    SendMessage(xxx, EM_GETSEL ,............
    location = where; // need to figure this out somehow
    sprintf(text,"Location %i", location);
    If you got any other suggestion on how to do this i will highly appreciate it.
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

Popular pages Recent additions subscribe to a feed