CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    8

    Caret position??

    I'm using Dundas's grid control, and am trying to implement a type-ahead feature for drop down boxes. I've gotten fairly far, but I am having a problem with moving the caret. Here's what I am doing:
    pWndEdit->SetWindowText(strTemp);

    CPoint point;
    CSize size;
    CDC * pDC;

    pDC = pWndEdit->GetDC();
    size = pDC->GetTextExtent(m_strCurrent);
    point = pWndEdit->GetCaretPos();
    point.x += size.cx;

    pWndEdit->HideCaret();
    pWndEdit->SetCaretPos(point);
    pWndEdit->ShowCaret();




    I read somewhere that you should hide, reposition, and then show the caret, but it didn't seem to help... If I do a GetCaretPos() just after this, the position is correct, but it never moves in the display. Anybody got any ideas? pWndEdit is just a CWnd and not a CEdit, so I don't have nice features like SetSel.

    Thanks so much for your help!!!
    Mindy


  2. #2
    Join Date
    Apr 1999
    Posts
    53

    Re: Caret position??

    Hi,

    You might need to invalidate and refresh the area of the window where the caret is to be erased and redrawn. For an experiment, try something crude like UpdateAllViews(NULL) and see if that makes a difference.

    Yours,
    Wes Rogers


  3. #3
    Join Date
    Apr 1999
    Posts
    8

    Re: Caret position??

    I found that I was able to get access to a CEdit, after all, so I just used SetSel. The caret is still at the end of the selection, but I inspected the way Internet Explorer does their type ahead and it does it the same way. So, I figure that is good enough. =) Thanks for you suggestion!
    Mindy


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured