Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CMFCOutlookBar with CDialog

396 views
Skip to first unread message

LudoEN

unread,
Oct 16, 2008, 11:09:03 AM10/16/08
to
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

unread,
Oct 17, 2008, 6:41:17 AM10/17/08
to
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...

avinashbhardwaj

unread,
Nov 12, 2008, 7:37:43 AM11/12/08
to
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

unread,
Nov 12, 2008, 11:00:01 AM11/12/08
to
See below...

On Wed, 12 Nov 2008 04:37:43 -0800, Avinash Bhardwaj wrote:

>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);

****
m_pDlg->SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOMOVE |
SWP_NOZORDER);
****


>
>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: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Doug Harrison [MVP]

unread,
Nov 12, 2008, 1:09:57 PM11/12/08
to
On Wed, 12 Nov 2008 04:37:43 -0800, Avinash Bhardwaj wrote:

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

unread,
Jan 8, 2012, 7:56:48 AM1/8/12
to
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: thierry....@skynet.be

Thanks

Thierry
>> On Friday, October 17, 2008 6:41 AM LudoE wrote:

>> 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...
>>
>> "LudoEN" wrote:


0 new messages