设为首页收藏本站

SKY外语、计算机论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 6289|回复: 4
打印 上一主题 下一主题

[MFC] 窗口是如何添加的

[复制链接]

1

主题

0

好友

4

积分

新手上路

Rank: 1

性别
保密
跳转到指定楼层
楼主
发表于 2013-11-22 17:27:47 |只看该作者 |倒序浏览
求助:左边栏有窗格,它是怎么填充到视图里面的。我没找到窗口的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();
//}

分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享淘帖0 收藏收藏0 评分评分

200

主题

3

好友

2253

积分

管理员

Rank: 9Rank: 9Rank: 9

性别
保密

热心会员 推广达人 宣传达人 灌水之王 突出贡献 优秀版主 荣誉管理 论坛元老 最佳新人 活跃会员

沙发
发表于 2013-11-23 12:45:33 |只看该作者
你能截个图说明下吗?或者把工程上传一下,不能直接上传,需要用链接
回复

使用道具 评分 举报

200

主题

3

好友

2253

积分

管理员

Rank: 9Rank: 9Rank: 9

性别
保密

热心会员 推广达人 宣传达人 灌水之王 突出贡献 优秀版主 荣誉管理 论坛元老 最佳新人 活跃会员

板凳
发表于 2013-11-23 12:46:15 |只看该作者
还有,把那个表情转义去掉,好多代码变成表情了
回复

使用道具 评分 举报

27

主题

1

好友

637

积分

高级会员

Rank: 4

性别
保密

最佳新人

地板
发表于 2013-11-24 19:53:35 |只看该作者
是C#么......这代码完全看不明白
回复

使用道具 评分 举报

0

主题

0

好友

486

积分

版主

Rank: 7Rank: 7Rank: 7

生肖
星座
水瓶座
性别

最佳新人 活跃会员 论坛元老

5#
发表于 2013-12-30 10:55:23 |只看该作者
在OnCreateClient里面通过窗口切分来划分窗口
回复

使用道具 评分 举报

您需要登录后才可以回帖 登录 | 立即注册


手机版|SKY外语计算机学习 ( 粤ICP备12031577 )    

GMT+8, 2024-5-3 22:45 , Processed in 0.326154 second(s), 240 queries .

回顶部