为对话框添加菜单,工具栏,状态栏,视图

//加载菜单资源
m_Menu.LoadMenu(IDR_MENU);


//设置当前菜单
SetMenu(&m_Menu);
//创建工具栏
if (!m_wndToolBar.Create(this))
{
return FALSE;
}


//加载工具栏资源
if (!m_wndToolBar.LoadToolBar(IDR_TOOLBAR))
{
return FALSE;
}

//获得旧客户区坐标
CRect rcOldClient;
GetClientRect(rcOldClient);


//获得新客户区坐标
CRect rcNewClient;
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 
0, reposQuery, rcNewClient);

//移动主窗口
CRect rcMain;
GetWindowRect(rcMain);
rcMain.right += rcOldClient.Width() - rcNewClient.Width();
rcMain.bottom += rcOldClient.Height() - rcNewClient.Height();
MoveWindow(rcMain, FALSE);


//移动所有子窗口
CRect rcChild;
CPoint point(rcNewClient.left - rcOldClient.left, rcNewClient.top - rcOldClient.top);
CWnd* pChildWnd = GetWindow(GW_CHILD);
while (pChildWnd != NULL)
{
pChildWnd->GetWindowRect(rcChild);
ScreenToClient(rcChild);
rcChild.OffsetRect(point);
pChildWnd->MoveWindow(rcChild, FALSE);
pChildWnd = pChildWnd->GetNextWindow();
}


//重新定位工具栏
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);


//创建状态栏窗口
if (!m_wndStatusBar.Create(this))
{
return -1;
}


//ID数组
UINT IDArray[2];
for (int n = 0; n < 2; n++)
{
IDArray[n] = 10000 + n;
}


//设置状态栏指示器
m_wndStatusBar.SetIndicators(IDArray, sizeof(IDArray) / sizeof(UINT));


//设置窗格宽度
m_wndStatusBar.SetPaneInfo(0, IDArray[0], SBPS_NORMAL, 100);
m_wndStatusBar.SetPaneInfo(1, IDArray[1], SBPS_STRETCH, 0);


//设置窗格文本
m_wndStatusBar.SetPaneText(0, _T("状态栏:"));
m_wndStatusBar.SetPaneText(1, _T(""));

//获得旧客户区坐标
CRect rcOldClient;
GetClientRect(rcOldClient);


//获得新客户区坐标
CRect rcNewClient;
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 
0, reposQuery, rcNewClient);

//移动主窗口
CRect rcMain;
GetWindowRect(rcMain);
rcMain.right += rcOldClient.Width() - rcNewClient.Width();
rcMain.bottom += rcOldClient.Height() - rcNewClient.Height();
MoveWindow(rcMain, FALSE);


//移动所有子窗口
CRect rcChild;
CPoint point(rcNewClient.left - rcOldClient.left, rcNewClient.top - rcOldClient.top);
CWnd* pChildWnd = GetWindow(GW_CHILD);
while (pChildWnd != NULL)
{
pChildWnd->GetWindowRect(rcChild);
ScreenToClient(rcChild);
rcChild.OffsetRect(point);
pChildWnd->MoveWindow(rcChild, FALSE);
pChildWnd = pChildWnd->GetNextWindow();
}

//重新定位状态栏
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);


CCreateContext context;
context.m_pNewViewClass = RUNTIME_CLASS(CDemoView);
context.m_pCurrentDoc = NULL;
context.m_pNewDocTemplate = NULL;
context.m_pLastView = NULL;
context.m_pCurrentFrame = (CFrameWnd*)this;

m_pView = (CDemoView*)context.m_pNewViewClass->CreateObject();
if (!m_pView->Create(NULL,NULL ,AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), 
this, AFX_IDW_PANE_FIRST, &context))
{
return FALSE;
}

CRect rect;
GetClientRect(rect);
m_pView->MoveWindow(rect);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值