15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


SetCaretPos() in multiple views

Spencer Jones -- Spencer@azure.com
Thursday, August 15, 1996

Environment: VC++ 4.1 and Windows NT 3.51

I am writing a text editor based application from scratch and I have a
confusing problem with the caret. I am using the GetCaretPos() and
SetCaretPos() functions to get the position of the caret and set it
after the display is updated. However if I have more than one document
the caret is being placed at the position of the previous document (view
of the document).

For example if I open two documents and type "text" into one, the caret
would appear after the position of "text" in the 'blank' second document
view when it is put into focus. This is not true on all occasions it
always happens if I close one of the documents and the second is then
re-focused? It happens on re-sizing the document also, the caret
flickers between the place set in the current document and the place in
the other displayed document.

I store the position of the caret on a kill focus in a document member
variable and reset it on the set focus. I am not overriding any resizing
functions, but do override the OnDraw function. The view is based on a
CScrollView.

Does the SetCaretPos() update all views regardless? Or is there
something else quirky happening here?


Spencer Jones.
Chief Software Developer.
Azure Limited. ( http://www.azure.com )



Chet Murphy -- cmurphy@modelworks.com
Friday, August 16, 1996

Spencer,

You need to create the caret in OnKillFocus and destroy it in OnSetFocus
for each view.

Chet Murphy
ModelWorks Software
cmurphy@modelworks.com
http://www.modelworks.com/express

----------
> From: Spencer Jones 
> To: 'MFC List' 
> Subject: SetCaretPos() in multiple views
> Date: Thursday, August 15, 1996 6:20 AM
> 
> Environment: VC++ 4.1 and Windows NT 3.51
> 
> I am writing a text editor based application from scratch and I have a
> confusing problem with the caret. I am using the GetCaretPos() and
> SetCaretPos() functions to get the position of the caret and set it
> after the display is updated. However if I have more than one document
> the caret is being placed at the position of the previous document (view
> of the document).
> 
> For example if I open two documents and type "text" into one, the caret
> would appear after the position of "text" in the 'blank' second document
> view when it is put into focus. This is not true on all occasions it
> always happens if I close one of the documents and the second is then
> re-focused? It happens on re-sizing the document also, the caret
> flickers between the place set in the current document and the place in
> the other displayed document.
> 
> I store the position of the caret on a kill focus in a document member
> variable and reset it on the set focus. I am not overriding any resizing
> functions, but do override the OnDraw function. The view is based on a
> CScrollView.
> 
> Does the SetCaretPos() update all views regardless? Or is there
> something else quirky happening here?
> 
> 
> Spencer Jones.
> Chief Software Developer.
> Azure Limited. ( http://www.azure.com )




| Вернуться в корень Архива |