//加载菜单资源
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);
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);