I have an MFC application and I made a class called CCustomFilter.. it basically brings up a dialog with some edit boxes, etc.. the user is able to enter a mask and apply the filter..
Now, from the main dialog I am instantiating it as follows:
CCustomFilter outdata; outdata.m_Numerator = 1; outdata.m_Denominator = 1; outdata.DoModal();
Of-course, I've got proper data exchange entries and this works fine... now here is my problem:
I'm trying to change the fonts of the edit boxes in the CCustomFilter dialog once it's created. The problem is, that I can't do it before DoModal() because at that point the dialog is not yet created. I can't do it after DoModal() because it has no effect. This is what I've tried:
CRichEditCtrl* m_RichEditCtrl1 = (CRichEditCtrl*)CCustomFilter::GetDlgItem(IDC_CF_CUSTOMMASK); CFont font; font.CreatePointFont(120, _T("Courier")); m_RichEditCtrl1->SetFont(&font,1); m_RichEditCtrl1->SetWindowTextW(_T(""));
I tried this from the CCustomFilter class, and I tried calling the function as public from outside (once the dialog is created) and as private from within CCustomFilter, inside the constructor, inside the Create function, and as a separate function.
I've also tried using this approach from the main dialog:
CRichEditCtrl* m_RichEditCtrl1 = (CRichEditCtrl*)outdata.GetDlgItem(IDC_CF_CUSTOMMASK); CFont font; font.CreatePointFont(120, _T("Courier")); m_RichEditCtrl1->SetFont(&font,1); m_RichEditCtrl1->SetWindowTextW(_T("")); outdata.DoModal();
None of this works! It seems I cannot make any changes to the dialog before or after DoModal(). Don't ask me why the dialog has to be instantiated like this. I'm working with other people and this is how it has to be.
I need to be able to use SetFont.
Thanks in advance. Any advice is appreciated!
EDIT: I should also add that the actual font change procedure works fine.. I've used it in other dialogs. It's only when I use DoModal ..