Click to See Complete Forum and Search --> : Caret position??


Mindy
June 4th, 1999, 01:10 PM
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

Wes Rogers
June 4th, 1999, 03:24 PM
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

Mindy
June 7th, 1999, 10:35 AM
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