Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Caret fails to show up

92 views
Skip to first unread message

John Smith

unread,
Dec 28, 2011, 5:29:23 AM12/28/11
to
I have a simple non-modal windows with a couple of Edit controls and a few button
controls. The edit controls are subclassed.

When I press a button in the window another similar window with Edit & button
controls pops up. When I close that window I send a WM_USER -message to my first
windows' edit control with SetFocus(myedit_control_hwnd):

case WM_USER:
SetFocus(myedit_control_hwnd);

The problem is that no blinking caret is visible in the Edit control after I have
closed the second window. Focus is on the Edit control (I can type there). If I
click the Edit no caret comes up. If I click another windows and then the edit I
get the caret in the edit control.

I looked the code under debugger and everything seems to go ok with SetFocus. I
tried to do:

case WM_USER:
SetFocus(myedit_control_hwnd); // no error
i=ShowCaret(myedit_control_hwnd); //error 5 'Access Denied'

What am I doing wrong?

r_z_...@pen_fact.com

unread,
Dec 30, 2011, 12:54:09 PM12/30/11
to
On Wed, 28 Dec 2011 12:29:23 +0200, John Smith
<do_no...@invalid.address.com> wrote:

>I have a simple non-modal windows with a couple of Edit controls and a few button
>controls. The edit controls are subclassed.
>
>When I press a button in the window another similar window with Edit & button
>controls pops up. When I close that window I send a WM_USER -message to my first
>windows' edit control with SetFocus(myedit_control_hwnd):
>
>case WM_USER:
> SetFocus(myedit_control_hwnd);
>
>The problem is that no blinking caret is visible in the Edit control after I have
>closed the second window. Focus is on the Edit control (I can type there). If I
>click the Edit no caret comes up. If I click another windows and then the edit I
>get the caret in the edit control.

It might be related to timing, so you may need to make sure the window
that is closing is closed before you call SetFocus.

My code for edit/text boxes calls SetFocus in response to WM_SETFOCUS
messages. I haven't worked with, or looked at, this code for a while
and it looks odd now. But I assure you it was well tested.


>
>I looked the code under debugger and everything seems to go ok with SetFocus. I
>tried to do:
>
>case WM_USER:
> SetFocus(myedit_control_hwnd); // no error
> i=ShowCaret(myedit_control_hwnd); //error 5 'Access Denied'
>
>What am I doing wrong?

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
20 Park Plaza, Suite 400
Boston, MA 02116
www.penfact.com
Useful reading (be sure to read its disclaimer first):
http://catb.org/~esr/faqs/smart-questions.html

John Smith

unread,
Dec 31, 2011, 4:21:30 AM12/31/11
to
r_z_aret@pen_fact.com wrote:

>On Wed, 28 Dec 2011 12:29:23 +0200, John Smith
><do_no...@invalid.address.com> wrote:
>
>>I have a simple non-modal windows with a couple of Edit controls and a few button
>>controls. The edit controls are subclassed.
>>
>>When I press a button in the window another similar window with Edit & button
>>controls pops up. When I close that window I send a WM_USER -message to my first
>>windows' edit control with SetFocus(myedit_control_hwnd):
>>
>>case WM_USER:
>> SetFocus(myedit_control_hwnd);
>>
>>The problem is that no blinking caret is visible in the Edit control after I have
>>closed the second window. Focus is on the Edit control (I can type there). If I
>>click the Edit no caret comes up. If I click another windows and then the edit I
>>get the caret in the edit control.
>
>It might be related to timing, so you may need to make sure the window
>that is closing is closed before you call SetFocus.
>
>My code for edit/text boxes calls SetFocus in response to WM_SETFOCUS
>messages. I haven't worked with, or looked at, this code for a while
>and it looks odd now. But I assure you it was well tested.

Can you show how you handle WM_KILLFOCUS & WM_SETFOCUS

John Smith

unread,
Dec 31, 2011, 5:57:24 AM12/31/11
to
OK. I got it solved. My WM_KILLFOCUS returned 0 on some situation.
0 new messages