Click here to Skip to main content
13,091,554 members (63,509 online)
Rate this:
Please Sign up or sign in to 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();
	pWndMain->OnKeyDown(nChar, nRepCnt, nFlags);

Any suggestions please?
Posted 31-Mar-11 21:28pm
Updated 31-Mar-11 21:33pm
Toniyo Jackson 1-Apr-11 3:33am
Use pre tag for code
she-programmer 1-Apr-11 3:44am
ok - sorry, I did not know about these.
she-programmer 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 1 Apr 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100