CEedit MFC question
-
I want to display a text file , using the CEdit controller. Though i dont want the user the be able to edit the text, only mark the text if he wants to copy something. If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white. This is the code i have now: CEdit * p = static_cast(GetDlgItem(IDC_Readme)); p->SetWindowText("Text"); p->SetMargins(2,2);
-
I want to display a text file , using the CEdit controller. Though i dont want the user the be able to edit the text, only mark the text if he wants to copy something. If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white. This is the code i have now: CEdit * p = static_cast(GetDlgItem(IDC_Readme)); p->SetWindowText("Text"); p->SetMargins(2,2);
You don't need to make the edit-box to be read-only. You only have to manage the WM_KEYDOWN message, like this:
BOOL CTestDlg::PreTranslateMessage( MSG *pMsg ) { if ( pMsg -> message == WM_KEYDOWN ) { CEdit *p = (CEdit *) GetDlgItem( IDC_Readme ); if ( GetFocus( ) == p ) return TRUE; } return CDialog::PreTranslateMessage( pMsg ); }
I don't know what is the name of your application's main dialog class. In my example it's CTestDlg. Don't forget to declare this overriden function in that class. Good luck! -
You don't need to make the edit-box to be read-only. You only have to manage the WM_KEYDOWN message, like this:
BOOL CTestDlg::PreTranslateMessage( MSG *pMsg ) { if ( pMsg -> message == WM_KEYDOWN ) { CEdit *p = (CEdit *) GetDlgItem( IDC_Readme ); if ( GetFocus( ) == p ) return TRUE; } return CDialog::PreTranslateMessage( pMsg ); }
I don't know what is the name of your application's main dialog class. In my example it's CTestDlg. Don't forget to declare this overriden function in that class. Good luck!thanks, worked great!
-
I want to display a text file , using the CEdit controller. Though i dont want the user the be able to edit the text, only mark the text if he wants to copy something. If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white. This is the code i have now: CEdit * p = static_cast(GetDlgItem(IDC_Readme)); p->SetWindowText("Text"); p->SetMargins(2,2);
-
I want to display a text file , using the CEdit controller. Though i dont want the user the be able to edit the text, only mark the text if he wants to copy something. If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white. This is the code i have now: CEdit * p = static_cast(GetDlgItem(IDC_Readme)); p->SetWindowText("Text"); p->SetMargins(2,2);
FredrickNorge wrote:
If i set the readonly parameter, it is exactly the way i want it, except its color background is greyed, i want the white.
Hanle OnCtlColr message and repaint the ctrl with white color
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you