SKY外语计算机学习
标题:
窗口是如何添加的
[打印本页]
作者:
小小鸟/mg
时间:
2013-11-22 17:27
标题:
窗口是如何添加的
求助:左边栏有窗格,它是怎么填充到视图里面的。我没找到窗口的ID。谢谢。
// MainFrm.cpp : CMainFrame 类的实现
//
#include "stdafx.h"
#include "AutoNavi.h"
#include "MainFrm.h"
#include "autonavidoc.h"
#include "autonaviview.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
// ON_WM_KEYDOWN()
// ON_WM_KEYUP()
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // 状态行指示器
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
// CMainFrame 构造/析构
CMainFrame::CMainFrame()
{
// TODO: 在此添加成员初始化代码
m_bSplitterCreated = false;
m_bLapTop = false;
m_pSplitterWnd = NULL;
m_pSplitterWnd2 = NULL;
}
CMainFrame::~CMainFrame()
{
if ( m_pSplitterWnd )
delete m_pSplitterWnd;
if ( m_pSplitterWnd2 )
delete m_pSplitterWnd2;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("未能创建工具栏\n");
return -1; // 未能创建
}
//if (!m_wndStatusBar.Create(this) ||
// !m_wndStatusBar.SetIndicators(indicators,
// sizeof(indicators)/sizeof(UINT)))
//{
// TRACE0("未能创建状态栏\n");
// return -1; // 未能创建
//}
//添加状态栏面板
m_wndStatusBar.Create(this);
UINT Indicates[4];
for (int i = 0; i<4;i++)
Indicates[i] = 50+i;
m_wndStatusBar.SetIndicators(Indicates,4);
CRect rect;
GetClientRect(rect);
UINT PaneWidth = rect.Width()/6;
//设置面板宽度
for(int n = 0;n<3;n++)
m_wndStatusBar.SetPaneInfo(n,50+n*10,SBPS_NORMAL,PaneWidth);
//设置状态栏面板文本
m_wndStatusBar.SetPaneInfo(0,50,SBPS_NORMAL,400);
m_wndStatusBar.SetPaneInfo(3,111,SBPS_NORMAL,800);
m_strbar1 = "";
m_strbar2 = "";
m_strbar3 = "";
m_strbar4 = "";
UpdatePaneText();
// TODO: 如果不需要可停靠工具栏,则删除这三行
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
AfxGetMainWnd()-> SetMenu(NULL);
AfxGetMainWnd()-> DrawMenuBar();
m_wndToolBar.ShowWindow(FALSE);
return 0;
}
void CMainFrame::UpdatePaneText()
{
m_wndStatusBar.SetPaneText(0,m_strbar1);
m_wndStatusBar.SetPaneText(1,m_strbar2);
m_wndStatusBar.SetPaneText(2,m_strbar3);
m_wndStatusBar.SetPaneText(3,m_strbar4);
}
BOOL CMainFrame:
reCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd:
reCreateWindow(cs) )
return FALSE;
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
return TRUE;
}
// CMainFrame 诊断
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame:
ump(CDumpContext& dc) const
{
CFrameWnd:
ump(dc);
}
#endif //_DEBUG
// CMainFrame 消息处理程序
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
//窗口切分如下,
// | | |
// | | |
// |Wnd2(TOP_SIDE) | |
// |(处理栏) | |
// | | |
// |—————————— |
// | | |
// |Wnd2(BOTTOM_SIDE) | Wnd(RIGHT_SIDE) |
// |(信息栏) | |
// | | |
m_pSplitterWnd = new ST_SplitterWnd(); //最大的分窗口
m_pSplitterWnd->Create(this,NULL,RUNTIME_CLASS(CAutoNaviView),pContext,true); //水平分最大窗口,RIGHT_SIDE 为主窗
//left side
m_pSplitterWnd2 = m_pSplitterWnd->AddSubDivision(LEFT_SIDE,
RUNTIME_CLASS(CProView),RUNTIME_CLASS(CInfView),pContext,false); //将左分上下分,要能够动态
//以上部分把窗口分好了,下面是设置各个窗口大小
{
m_pSplitterWnd->SetSize(LEFT_SIDE,RE_EXPLORER_X);
m_pSplitterWnd->SetMinSize(LEFT_SIDE,RE_EXPLORER_X_MIN);
m_pSplitterWnd2->SetSize(TOP_SIDE,RE_EXPLORER_Y+RE_PLATFORM_LAPTOP_Y-RE_PLATFORM_DESKTOP_Y);
m_pSplitterWnd2->SetMinSize(TOP_SIDE,RE_EXPLORER_Y_MIN);
m_bLapTop = true;
}
m_pSplitterWnd->SetInitialStatus();
m_bSplitterCreated = true;
return TRUE;
}
CInfView *CMainFrame::GetpInfView()
{
CInfView *pView = (CInfView *)(m_pSplitterWnd2->GetPane(BOTTOM_SIDE,LEFT_SIDE));
ASSERT(pView);
return pView;
}
CProView *CMainFrame::GetpProView()
{
CProView *pView = (CProView *)(m_pSplitterWnd2->GetPane(TOP_SIDE,LEFT_SIDE));
ASSERT(pView);
return pView;
}
CAutoNaviView *CMainFrame::GetpView()
{
CAutoNaviView *pView = (CAutoNaviView *)(m_pSplitterWnd->GetPane(TOP_SIDE,RIGHT_SIDE));
ASSERT(pView);
return pView;
}
void CMainFrame::SetpViewShow(IplImage *img,bool bdis)
{
GetpView()->SetShow(img,bdis);
}
void CMainFrame::SetViewTimer(BOOL bopen)
{
if (bopen)
GetpView()->SetTimer(1,100,NULL);
else
GetpView()->KillTimer(1);
}
void CMainFrame::SetAddPlaces(BOOL badd,BOOL bdis)
{
GetpView()->SetAddPlaces(badd,bdis);
}
void CMainFrame:
eleteMapPlace(int item)
{
GetpView()->DeleteMapPlace(item);
}
void CMainFrame::UnSetChargePlace(BOOL have)
{
GetpView()->UnSetChargePlace(have);
}
void CMainFrame::UnSetPreChargePlace(BOOL have)
{
GetpView()->UnSetPreChargePlace(have);
}
void CMainFrame::SaveAsMapPlaces()
{
GetpView()->SaveAsMapPlaces();
}
void CMainFrame::RecordCurrentPlace(BOOL bdis)
{
GetpView()->RecordCurrentPlace(bdis);
}
void CMainFrame::SelectGoalPlaces(int id)
{
GetpView()->SelectGoalPlaces(id);
}
void CMainFrame::SetAsChargePlace(int id)
{
GetpView()->SetAsChargePlace(id);
}
void CMainFrame::SetAsPreChargePlace(int id)
{
GetpView()->SetAsPreChargePlace(id);
}
void CMainFrame:
oadMapPlaces()
{
GetpView()->LoadMapPlaces();
}
void CMainFrame::SaveMap()
{
GetpView()->SaveMap();
}
void CMainFrame::SetDisPlaces(BOOL bdis)
{
GetpView()->SetDisPlaces(bdis);
}
void CMainFrame::GotoSelectedPlace()
{
GetpView()->GotoSelectedPlace();
}
void CMainFrame::GotoCharge()
{
GetpView()->GotoCharge();
}
BOOL CMainFrame::GetbChargeplace()
{
return GetpView()->GetbChargeplace();
}
void CMainFrame::SetRobot_InitialPose()
{
GetpView()->SetRobot_InitialPose();
}
void CMainFrame::BeginRecevSMS()
{
GetpView()->BeginRecevSMS();
}
void CMainFrame::EndRecevSMS()
{
GetpView()->EndRecevSMS();
}
ComuLcm CMainFrame::GetLCM()
{
return GetpView()->GetLCM();
}
//void CMainFrame::SetRobot_InitialPose()
//{
// GetpView()->SetRobot_InitialPose();
//}
作者:
admin
时间:
2013-11-23 12:45
你能截个图说明下吗?或者把工程上传一下,不能直接上传,需要用链接
作者:
admin
时间:
2013-11-23 12:46
还有,把那个表情转义去掉,好多代码变成表情了
作者:
刺客
时间:
2013-11-24 19:53
是C#么......这代码完全看不明白
作者:
骏马
时间:
2013-12-30 10:55
在OnCreateClient里面通过窗口切分来划分窗口
欢迎光临 SKY外语计算机学习 (http://skywj.com/)
Powered by Discuz! X2.5