Thread: CRichEditCtrl - where's the cursor?

  1. #1
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856

    CRichEditCtrl - where's the cursor?

    I've added a "row, column" pane to the status bar of my frame wnd.
    When the rich edit ctrl receives the selchange notification, I'm determining what the selection is and updating the pane. My problem is that GetSel() always returns the left most selection as min and the right most selection as max and I'm determining the column by calc'ing the (cpMin - LineIndex()). Obviously if the user has selected text toward the right, the cursor will be at the cpMax position, but I'm still retrieving the row from the beginning of the selection.
    Do you have any ideas about how I can go about determining where the cursor itself is within the selection (either at min or max)? Or a better way to retrieve the current row of the cursor?

    Thanks bunches yo.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    No, I don't at first glance. Why do you need the current cursor posistion in a selection anyways?

    gg

  3. #3
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    originally posted by me
    I've added a "row, column" pane to the status bar of my frame wnd.... I'm still retrieving the row from the beginning of the selection.
    Hehe. In a pane on the status bar I am displaying the position of the cursor in the current document (ie: "Ln 1, Col 10" means the cursor is in the first row in the tenth column.
    I update this text every time the selection changes (which is basically whenever the cursor moves). The only way I can figure to determine the column of the cursor is to GetSel(). However, GetSel() returns the selection independent of the location of the cursor. So if I hold down shift and arrow to the right, the column will not change from the left end of the selection.
    Does that make any sense?

    So, again, I need a way to determine definitely what column the cursor is in.

    Hey codeplug, what does "gg" stand for? "Good game" or something?

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Sometimes I don't see the forest for the tree's (or something like that).

    Try GetCaretPos(), and read the Carets Overview.

    "gg" are my initials in rl

    gg

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You can use the EM_CHARFROMPOS message to translate the client coordinates of the caret posistion into a character index. I don't think CRichEditCtrl has a front-end for that message.

    gg

  6. #6
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Sweet. It works. Is there any question you can't answer?

    Thanks gg. Big help, as always.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Custom Animated Cursor
    By willc0de4food in forum Windows Programming
    Replies: 3
    Last Post: 05-13-2005, 10:05 PM
  2. Context Menu cursor problem
    By dWorkVan in forum Windows Programming
    Replies: 4
    Last Post: 07-14-2003, 11:42 AM
  3. cursor
    By Mr Learn in forum C Programming
    Replies: 1
    Last Post: 04-19-2002, 11:30 PM
  4. cursor remains in openGL fullscreen
    By Ken Fitlike in forum Game Programming
    Replies: 5
    Last Post: 03-14-2002, 08:52 PM
  5. Mouse in 800x600 24Bit Mode?
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 11-11-2001, 01:38 AM