Click here to Skip to main content
15,992,699 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am creating an MFC SDI explorer style application (it has a splitter bar and the right-hand pane is the text-edit area, left-hand pane is the tree-view)

My right-hand pane is a CRichEditView.

I want to be able to detect when a user has edited the text so that a flag is set to show that a change has been made but has not been saved. I have tried several ways of doing this e.g. catching WM_KEYDOWN in PreTranslateMessage, but this seems to catch everything and prevents the keypresses from editing the view. I have also tried adding ON_WM_KEYDOWN() to the message map in the MyView.cpp. Again, this seems to prevent the keystrokes from having any affect on the text in the view. I want to allow the user to edit the text in the view, but the application to know that this has been done.

I then tried setting the flag and then calling the function that I am overriding, as below, but it doesn't compile and the error is:
error C2248: 'CWnd::OnKeyDown' : cannot access protected member declared in class 'CWnd'
void CBWE8View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	int i = 1;
	CWnd* pWndMain = AfxGetMainWnd();
	//CWnd::OnKeyDown();
	pWndMain->OnKeyDown(nChar, nRepCnt, nFlags);
}

Any suggestions please?
Posted
Updated 31-Mar-11 21:33pm
v2
Comments
Toniyo Jackson 1-Apr-11 3:33am    
Use pre tag for code
Jackie Lloyd 1-Apr-11 3:44am    
ok - sorry, I did not know about these.
Jackie Lloyd 1-Apr-11 3:45am    
um, do I just use <pre> code...... </pre> or do I have to change 'pre' for another word?

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