Re: SetCaretPos within OnPaint method of user control



On Mon, 31 Mar 2008 10:15:32 -0700, Steve Richter <StephenRichter@xxxxxxxxx> wrote:

How do I SetCaretPos within the OnPaint method of a user control?

The caret either does not display or is not positioned where I expect
it to be. I am guessing SetCaretPos is working outside the confines
and relative location of the ClipRectangle.

I doubt the issue has anything to do with the ClipRectangle.

in the code that follows, the caret ends up hugging the far left
border of the Form, nowhere near where the user control is located.

Have you tried passing the control's own window handle to the ShowCaret() function?

For what it's worth, the OnPaint() method isn't really a great place to be relocating and showing the caret anyway. The only thing you should be doing in there is actual drawing. I don't think that's related to your problem, but I think you'll be better off in the long run setting and showing the caret in a more appropriate place (like in the OnEnter() override for showing it, and there and wherever else user interaction would move the caret for setting the position).

Pete
.



Relevant Pages

  • Re: SetCaretPos within OnPaint method of user control
    ... I doubt the issue has anything to do with the ClipRectangle. ... nowhere near where the user control is located. ... relocating and showing the caret anyway. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CWnd Caret status
    ... Any window that is showing the ... caret should destroy that caret before your application gets the focus. ...
    (microsoft.public.vc.mfc)
  • Re: CWnd Caret status
    ... Sorry, I misready your post. ... Why would the caret not be showing? ... assuming this would be in a edit type control. ... It's the caret not the cursor that I'm having trouble with. ...
    (microsoft.public.vc.mfc)