int WSDIFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!InitCommandBars())
{
return -1; // fail to create
}
return 0;
}
BOOL WSDIFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
if (!CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext))
return FALSE;
GenerateCommandBars();
return TRUE;
}
void WSDIFrame::GenerateCommandBars()
{
CXTPCommandBars* pCommandBars = GetCommandBars();
pCommandBars->SetMenu(_T("Menu Bar"), IDR_WHITEBOARD);
HRSRC hRsrs = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_FORM2), "RT_RCDATA");
ASSERT(hRsrs);
if (hRsrs)
{
HGLOBAL hGlobal = LoadResource(AfxGetInstanceHandle(), hRsrs);
if (hGlobal)
{
DWORD dwSize = SizeofResource(AfxGetInstanceHandle(), hRsrs);
LPVOID pData = LockResource(hGlobal);
CMemFile file((BYTE*)pData, dwSize);
CArchive ar(&file, CArchive::load | CArchive::bNoFlushOnDelete);
// I checked here,CMemFile file has the same content as the input form2.xcb file.
// so, the input of LoadDesignerBars should be OK
pCommandBars->LoadDesignerBars(ar);
//but there are some exception here.
//debug info
// Warning: Cannot load CXTPMenuBar from archive. Class not defined.
// CArchive exception: badClass.
// CXTPCommandBars::LoadCommand BarList. Archive exception
}
}
}
BOOL WSDIFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
//create some client panes
//.....
return TRUE;
}
BOOL WSDIFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if(!CFrameWnd::PreCreateWindow(cs))
return FALSE;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.dwExStyle &=~WS_EX_WINDOWEDGE;
cs.dwExStyle &=~WS_EX_DLGMODALFRAME;
return TRUE;
}
//class WSDITemplate : public CSingleDocTemplate
//here is how the WSDIFrame was created
CFrameWnd* WSDITemplate::CreateNewFrame(CDocument* pDoc,
CFrameWnd* pOther)
{
// here m_pFramClass == "WSDIFrame"
m_pFrameWnd = (CFrameWnd*)m_pFrameClass->CreateObject();
m_pFrameWnd->LoadFrame(IDR_WHITEBOARD,WS_CHIL D|WS_VISIBLE,m_pParentWnd,&context))
}
//class CWCSWhiteBoardCtrl : public WSDIControl
//class WSDIControl : public COleControl
//here is how the WSDITemplate was created
CWCSWhiteBoardCtrl::CWCSWhiteBoardCtrl()
{
InitializeIIDs(&IID_DWCSWhiteBoard, &IID_DWCSWhiteBoardEvents);
SetInitialSize(200, 200);
WSDITemplate* temp=new WSDITemplate(
RUNTIME_CLASS(WSDIDoc),
RUNTIME_CLASS(WSDIFrame),
RUNTIME_CLASS(WSDIView));
temp->SetContainerInfo(IDR_WHITEBOARD);
AddDocTemplate(temp);
}