Discussion:
CMFCOutlookBar with CDialog
(too old to reply)
LudoEN
2008-10-16 15:09:03 UTC
Permalink
Hi All!

I developp a new MFC application and i try to use the new MFC feature pack...
Now i've got problems with the CMFCOutlookBar. I want to add tabs into the
CMFCOutlookBar control but this tabs come from CDialog I make in the
ressource editor. Here is the piece of code:

m_studyDlg.Create(IDD_DLG_STUDY, &m_wndOutlookBar);
m_imgPropDlg.Create(IDD_DLG_IMG_PROPERTY, &m_wndOutlookBar);

CMFCOutlookBarTabCtrl* pOutlookBar =
(CMFCOutlookBarTabCtrl*)m_wndOutlookBar.GetUnderlyingWindow();

str.LoadString(IDS_STUDY);
pOutlookBar->AddTab(&m_studyDlg, str, -1, FALSE);

str.LoadString(IDS_IMG_PROPERTY);
pOutlookBar->AddTab(&m_imgPropDlg, str, -1, FALSE);

So this code adds my windows correctly but when I close the application and
restart, the order od the window is wrong and I've got also the wrong title
(the same for each)! Maybe a bug with the SaveState mechanism?

If I use the AddControl method like in the MFC Sample, I can't display my
CDialog windows!

Please, any ideas?
LudoEN
2008-10-17 10:41:17 UTC
Permalink
If someone is interested by this problem, I've got some solutions (after
sevral hours of search...).
First you can't directly add CDialog in a MFCOutlookBar control because
control embedded in the MFCOutlookBar must be derived from CDockablePane to
work properly.

So one solution is to create a CDialog in the ressource editor for example
and add a class with the wizard (CMyDialog) . Then create a class
CMyDockablePane derived from CDockablePane class in which you put a member
CMyDialog myDlg. You should create the dialog in the OnCreate member function
of your CMyDockablePane. Add it should work. The advantage of this method is
that you can handle your control events directly form your CMyDialog class!

Another solution is to use CPaneDialog.

Hope this helps...
Post by LudoEN
Hi All!
I developp a new MFC application and i try to use the new MFC feature pack...
Now i've got problems with the CMFCOutlookBar. I want to add tabs into the
CMFCOutlookBar control but this tabs come from CDialog I make in the
m_studyDlg.Create(IDD_DLG_STUDY, &m_wndOutlookBar);
m_imgPropDlg.Create(IDD_DLG_IMG_PROPERTY, &m_wndOutlookBar);
CMFCOutlookBarTabCtrl* pOutlookBar =
(CMFCOutlookBarTabCtrl*)m_wndOutlookBar.GetUnderlyingWindow();
str.LoadString(IDS_STUDY);
pOutlookBar->AddTab(&m_studyDlg, str, -1, FALSE);
str.LoadString(IDS_IMG_PROPERTY);
pOutlookBar->AddTab(&m_imgPropDlg, str, -1, FALSE);
So this code adds my windows correctly but when I close the application and
restart, the order od the window is wrong and I've got also the wrong title
(the same for each)! Maybe a bug with the SaveState mechanism?
If I use the AddControl method like in the MFC Sample, I can't display my
CDialog windows!
Please, any ideas?
unknown
2008-11-12 12:37:43 UTC
Permalink
Hi,
I have a class CMyPane derviced from CDockablePane.Then I created a dialog CColorDlg derived from CDialog. Now I have done something like this in OnCreate()

m_pDlg = new CColorDlg(this);
m_pDlg->Create(IDD_DLG_COLORS, this);

Also in OnSize() of CMyPane I have written:

CRect rc;
GetClientRect(&rc);
m_pDlg->SetWindowPos(NULL, rc.left, rc.top, rc.right, rc.bottom, 0);

But it's not working for me [:(]. Please suggest something.
Joseph M. Newcomer
2008-11-12 16:00:01 UTC
Permalink
See below...
Post by unknown
Hi,
I have a class CMyPane derviced from CDockablePane.Then I created a dialog CColorDlg derived from CDialog. Now I have done something like this in OnCreate()
m_pDlg = new CColorDlg(this);
m_pDlg->Create(IDD_DLG_COLORS, this);
CRect rc;
GetClientRect(&rc);
m_pDlg->SetWindowPos(NULL, rc.left, rc.top, rc.right, rc.bottom, 0);
****
m_pDlg->SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOMOVE |
SWP_NOZORDER);
****
Post by unknown
But it's not working for me [:(]. Please suggest something.
****
Oh, really? And what does "not working" mean? Does it come out all purple-green, or is
it inverted, or what? How are we to guess what "not working" means?

Is this a child dialog, or a popup? Don't show just one line of the OnSize handler; show
how you determined this code is valid to execute! Did you first check m_pDlg to make sure
it is non-NULL? Do you make sure that the m_pDlg is initialized to NULL, but that only
one Create can ever be done?

Lots of missing code and no description of the problem make it hard to answer a question.
joe
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Doug Harrison [MVP]
2008-11-12 18:09:57 UTC
Permalink
Post by unknown
Hi,
I have a class CMyPane derviced from CDockablePane.Then I created a dialog CColorDlg derived from CDialog. Now I have done something like this in OnCreate()
m_pDlg = new CColorDlg(this);
m_pDlg->Create(IDD_DLG_COLORS, this);
CRect rc;
GetClientRect(&rc);
m_pDlg->SetWindowPos(NULL, rc.left, rc.top, rc.right, rc.bottom, 0);
But it's not working for me [:(]. Please suggest something.
Those last two lines don't make any sense. In CMyPane::OnSize, you're
getting the client rectangle for the CMyPane, yet you're trying to set your
CColorDlg to its size and position. For one, GetClientRect returns client
area coordinates, with left/top always zero, and SetWindowPos on a dialog
may need screen coordinates. In addition, you're trying to make your dialog
the same size as something it contains, which is strange. Maybe you need to
explain the relationship of these windows and what you're trying to
accomplish in a little more detail.
--
Doug Harrison
Visual C++ MVP
Thierry Marneffe
2012-01-08 12:56:48 UTC
Permalink
Hello

I'm really interested to see how it's possible to embed a CDialog-derived class in a CMFCOutlookBar

Can you send me info or sample code by mail ?

Adress: ***@skynet.be

Thanks

Thierry
Post by LudoEN
Hi All!
I developp a new MFC application and i try to use the new MFC feature pack...
Now i've got problems with the CMFCOutlookBar. I want to add tabs into the
CMFCOutlookBar control but this tabs come from CDialog I make in the
m_studyDlg.Create(IDD_DLG_STUDY, &m_wndOutlookBar);
m_imgPropDlg.Create(IDD_DLG_IMG_PROPERTY, &m_wndOutlookBar);
CMFCOutlookBarTabCtrl* pOutlookBar =
(CMFCOutlookBarTabCtrl*)m_wndOutlookBar.GetUnderlyingWindow();
str.LoadString(IDS_STUDY);
pOutlookBar->AddTab(&m_studyDlg, str, -1, FALSE);
str.LoadString(IDS_IMG_PROPERTY);
pOutlookBar->AddTab(&m_imgPropDlg, str, -1, FALSE);
So this code adds my windows correctly but when I close the application and
restart, the order od the window is wrong and I've got also the wrong title
(the same for each)! Maybe a bug with the SaveState mechanism?
If I use the AddControl method like in the MFC Sample, I can't display my
CDialog windows!
Please, any ideas?
Post by LudoEN
If someone is interested by this problem, I've got some solutions (after
sevral hours of search...).
First you can't directly add CDialog in a MFCOutlookBar control because
control embedded in the MFCOutlookBar must be derived from CDockablePane to
work properly.
So one solution is to create a CDialog in the ressource editor for example
and add a class with the wizard (CMyDialog) . Then create a class
CMyDockablePane derived from CDockablePane class in which you put a member
CMyDialog myDlg. You should create the dialog in the OnCreate member function
of your CMyDockablePane. Add it should work. The advantage of this method is
that you can handle your control events directly form your CMyDialog class!
Another solution is to use CPaneDialog.
Hope this helps...
Post by unknown
Hi,
I have a class CMyPane derviced from CDockablePane.Then I created a dialog CColorDlg derived from CDialog. Now I have done something like this in OnCreate()
m_pDlg = new CColorDlg(this);
m_pDlg->Create(IDD_DLG_COLORS, this);
CRect rc;
GetClientRect(&rc);
m_pDlg->SetWindowPos(NULL, rc.left, rc.top, rc.right, rc.bottom, 0);
But it's not working for me [:(]. Please suggest something.
Loading...