Обрезка кареткиC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Обрезка каретки

Сообщение Anonymous »


I'm writing my own control. It contains the caret. I use the SetCaretPos() function to move the caret. And it works well when I move the caret inside the window:


Изображение


But when I set a negative y-coordinate for SetCaretPos(), the caret is drawn outside the control window:

SetCaretPos(10, -5);
Изображение


Then I used IntersectClipRect() function to create new clipping region:

RECT rcClip, rcClient; GetClientRect(hEditWnd_MultyLine, &rcClient); CopyRect(&rcClip, &rcClient); rcClip.left += 2;//add left margin rcClip.right -= 2;//add right margin rcClip.top += 2;//add top margin rcClip.bottom -= 2;//add bottom margin HDC _hdc = GetDC(mywnd_hwnd); IntersectClipRect(_hdc, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom); ReleaseDC(mywnd_hwnd, _hdc); And it works fine only for graphics operations like FillRect(), but it has no effect on the caret drawing - there is no caret clipping:


Изображение


My question is - how to clip caret drawing when its y-coordinate is negative? I need this:


Изображение



Источник: https://stackoverflow.com/questions/780 ... -the-caret
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»