Click here to Skip to main content
15,904,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i have this unusual problem that i just cant seem to figure out.

i am using a dialog with CHtmlEditView, i need to write some functionality when the HTMLEditView looses control.
i tried handling the WM_KILLFOCUS event for the same, but it gets invoked when i click the HTMLEditView instead of clicking elsewhere :(

Kindly do help me with the same.


i tried handling the pretranslate message for the dialog. but the function never gets called
<pre lang="c++"> BOOL ::PreTranslateMessage( MSG* pMsg )
    {
        if (pMsg->message == WM_KILLFOCUS )
        {
                   AfxMessageBox( _T( "KILL" ));
        }
        return CHtmlEditView::PreTranslateMessage( pMsg );


can anyone please please help me.... :(
Posted
Updated 15-Jan-12 23:59pm
v3
Comments
Sergey Alexandrovich Kryukov 13-Jan-12 2:56am    
What does it mean "looses control"? Focus and control are different things.
--SA
Member 8112150 13-Jan-12 3:10am    
i m really sorry.. i meant looses focus..

1 solution

This is normal behavior. You simply need to understand: you don't need anything else. Of course, if you click "elsewhere", which should mean "not on other focusable control", the windows message WM_KILLFOCUS is not sent, but focus is not shifted. The focus is a keyboard focus: at any given moment, only one control of the whole system can have it. The only way to loose focus is to focus some other control. Indirectly, it can also happen with activation of the top-level window, which is not focusable but gives the focus to one of its controls, it any.

In all cases, when a control looses focus, it gets the message WM_KILLFOCUS before it happens, see http://msdn.microsoft.com/en-us/library/windows/desktop/ms646282%28v=vs.85%29.aspx[^].

—SA
 
Share this answer
 
Comments
Member 8112150 13-Jan-12 3:13am    
Hi,

Thanks for your help.
but by "elsewhere" i meant other focusable controls.. the WM_KILLFOCUS message is sent only when i click on the CHTMLEditView control..
does this have something to do with the HTMLEditView control?
because my dialog box has other buttons whose WM_KILLFOCUS message behavior is as expected..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900