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

Problem "including a CFormView in a CControlBar"????

38 views
Skip to first unread message

kin-zaze

unread,
Mar 23, 2000, 3:00:00 AM3/23/00
to
hi,

i try to implement an application in which i'd like to put a left navigate
bar so i've implemented a class name CMybar::CControlbar
but i would like to know how we can "put" or "create" or "attach" a view
inside that toolbar cause i would like to implement a navigate bar such as
the one we can see in outlook

any help would be greatly appreciate
best regards kin-zaze

M. Shams Mukhtar

unread,
Mar 23, 2000, 3:00:00 AM3/23/00
to
Its some what tricky, and undocumented but i did this all ok

Here are the steps to do that ok:

Step 1: Add a function like this to your FormView Class:
***************************************************************

/** Note: pParent and pContext is a must in CreateView for doc/view ok */
BOOL CMyFormView::CreateView(CWnd* pParent, CCreateContext* pContext)
{
DWORD dwStyle = AFX_WS_DEFAULT_VIEW;
// dwStyle &= ~WS_BORDER;

// Create with the right size (wrong position)
CRect rect(0,0,300,300);

/** Note:> Upon this Create(...) WM_CREATE message is sent
so OnCreate(..) will be called
pContext != NULL then this will be added or registered
to the document i.e. pContext->m_pCurrentDoc->AddView(this);
>>this attaches this view to the current document
>>this function also sets the view’s document pointer
to this document.
*/

if (!Create(NULL, NULL, dwStyle,
rect, pParent, AFX_IDW_PANE_FIRST, pContext))
{
TRACE0("Warning: couldn't create treeview pane!. \n");
return FALSE;
}

return TRUE;
}

------

step 2: Add these two protected member pointer to your Control-Bar class like:

class CMyBar
{
protected:
CMyFormView* m_pFormView;
CCreateContext* m_pContext;

...
};

step 3:use this constructor for your Control Bar like for CMyBar:

CMyBar::CMyBar(CCreateContext* pContext /* =NULL*/ )
{
m_pContext = pContext;
CRuntimeClass* pFactory = RUNTIME_CLASS(CLeftView);
m_pFormView = (CMyFormView *)(pFactory->CreateObject() );
}

step 4: Add a ON_WM_CREATE Handler into your Control-Bar class like this

BEGIN_MESSAGE_MAP(CMyBar, CControlBar)
//{{AFX_MSG_MAP(CMyBar)
ON_WM_CREATE()


//}}AFX_MSG_MAP
END_MESSAGE_MAP()

step 5: Add OnCreate(...) to your Control_bar class

/////////////////////////////////////////////////////////////////////////////
// CMyBar message handlers

int CMyBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (baseCMyBar::OnCreate(lpCreateStruct) == -1)
return -1;

if (m_pFormView )
{
m_pFormView->CreateView(this, m_pContext);
}
return 0;
}

step 6: Finally in your Frame-window or Your Child-Frame window(if MDI)
override
the OnCreateClient(...) like this ok

BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
pContext)
{

// .....


// Now create Control windows
if(!CreateControlBars(pContext) )
return -1; // fail to create

return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}

BOOL CChildFrame::CreateControlBars(CCreateContext* pContext)
{
m_pwndDockBar = new CMyBar( pContext) ;

if (!m_pwndDockBar->Create(_T("Resources"), this, CSize(80, 80),
TRUE, 123)) //AFX_IDW_CONTROLBAR_FIRST + 33))
{
TRACE0("Failed to create mybar\n");
return FALSE; // fail to create
}

return TRUE;
}

---------------------------

so thats iti, i hope this will help you out ok


shams
www.xpersoft.com
shams....@usa.net
--------------------------------

0 new messages