|
-
May 11th, 2004, 08:56 AM
#1
MFC Dialog Problem
Hi there,
Now I have a parent dialog which has a tab control in it and I have a child dialog with a combobox in it. And the child is linked to the parent and the child doesn't have OnInitDlg() function. So if I want to change the font size of the combobox in the child dialog, I would need to change it in the parent dialog (if I'm correct to say that). Now in the parent dialog, inside the OnInitDlg() function, I wrote this:
CClientDC dc ( this ) ;
LOGFONT lf ;
memset ( &lf, 0, sizeof ( LOGFONT ) ) ;
lf.lfHeight = 100 ;
lf.lfWeight = FW_BOLD ;
strcpy ( lf.lfFaceName, "Verdana" ) ;
VERIFY ( m_font.CreatePointFontIndirect ( &lf, &dc ) );
( ( CStatic* ) GetDlgItem ( IDC_COMBO_TIME ) ) -> SetFont ( &m_font ) ;
And when I run it, it gave me error message. Is there any way I could do to change the font of the combobox in the child dialog??
Any help will be appreciated.
Thanks.
Cheers
-one-
-
May 11th, 2004, 09:36 AM
#2
1. You don't need to use CClientDC dc;
2. Why do you cast your GetDlgItem ( IDC_COMBO_TIME ) ) to CStatic* if you want "to change the font of the combobox"?
3.
And the child is linked to the parent and the child doesn't have OnInitDlg() function. So if I want to change the font size of the combobox in the child dialog, I would need to change it in the parent dialog
If your child dialog "doesn't have OnInitDlg() function" - just to add it! Open Class Wizard and add the message handler WM_INITDIALOG for your child. The you could change the font of your child dialog controls in this OnInitDialog().
Otherwise, you will have what you have had - nothing!
-
May 11th, 2004, 09:38 AM
#3
Re: MFC Dialog Problem
Originally posted by Rivaldo
the child doesn't have OnInitDlg() function.
Can't you just give it one? That would be the obvious place to do what you want. If you're trying to run your code from the parent dialog, it will be looking for a control called IDC_COMBO_TIME in the parent dialog (which doesn't have such a control, from your explanation).
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
May 11th, 2004, 07:59 PM
#4
Thanks guys for all the helps.
In the child dialog, there's no WM_INITDIALOG for me to select. So what do I have to do in order to change the font of the child?
Thanks again.
Cheers.
-one-
-
May 12th, 2004, 02:31 AM
#5
In the child dialog, there's no WM_INITDIALOG for me to select
Try to select "Dialog" in combobox "Filter for messages available to class" and the WM_INITDIALOG must appear.
-
May 12th, 2004, 02:58 AM
#6
you can also subclass it..... but that wud be like sending forces to Iraq, a **** to manage....
like y do it the other way when there are simple and easy ways for that..
this is given as an option only....dont try it at home 
cheers
-
May 12th, 2004, 07:22 AM
#7
Millions of thanks guys. I think create the OnInitDlg() in the child dialog works. Beer for everyone. Cheers
-one-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|