|对话框窗口切分|
来源:互联网 发布:mac 用什么三维软件 编辑:程序博客网 时间:2024/06/08 07:02
-------------------------------------------------------------------------------------------
|对话框窗口切分|
-------------------------------------------------------------------------------------------
.h文件
CFrameWnd *m_pMyFrame;
CSplitterWnd m_cSplitter;
CSplitterWnd m_cSplitterone;
virtual BOOL OnInitDialog();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
.cpp文件中
BOOL CLoadAdjustmentInventoryDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect cRect;
GetWindowRect(&cRect);
ScreenToClient(&cRect);
m_pMyFrame->MoveWindow(&cRect);
m_pMyFrame->ShowWindow(SW_SHOW);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
int CLoadAdjustmentInventoryDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: 在此添加您专用的创建代码
CString strMyClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW,
::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH),
::LoadIcon(NULL, IDI_APPLICATION));
// Create the frame window with "this" as the parent
m_pMyFrame = new CFrameWnd;
m_pMyFrame->Create(strMyClass,"", WS_CHILD, CRect(0,0,300,300), this);
m_pMyFrame->ShowWindow(SW_SHOW);
// and finally, create the splitter with the frame as the parent
m_cSplitter.CreateStatic(m_pMyFrame,2, 1); //在Frame里切分视图窗口为1×2,就是一行两列
m_cSplitterone.CreateStatic(&m_cSplitter,1,2,WS_CHILD|WS_VISIBLE,m_cSplitter.IdFromRowCol(1,0));
m_cSplitter.CreateView(0,0, RUNTIME_CLASS(CThereAreStockSegmentationDlg),CSize(100,100), NULL);//第一行一列
m_cSplitterone.CreateView(0,0, RUNTIME_CLASS(CThereAreStockSegmentationoneDlg),CSize(100,100), NULL);
m_cSplitterone.CreateView(0,1, RUNTIME_CLASS(CThereAreStockSegmentationtwoDlg),CSize(100,100), NULL);//第一行二列
return 0;
}
说说切分后不能移动,不能拖拉
第1步:首先要创建一个新的CSplitterWnd派生类,它将完成锁定分割器的行为,我们把这个类称为CFixedSplitter。
class CFixedSplitter: public CSplitterWnd{};
第2步:使用ClassWizard在CFixedSplitter类中增加句柄来处理WM_LBUTTONDOWN,WM_MOUSEMOVE和WM_SETCURSOR消息。这些消息的具体实现见下面的代码。它们达
到了锁定分割器的目的。
void CFixedSplitter::OnLButtonDown(UINT nFlags, CPoint point)
{
//回避标准的CSplitterWnd处理过程CSplitterWnd::OnLButtonDown(UINT nFlags, CPoint point);
CWnd::OnLButtonDown(nFlags, point);
}
void CFixedSplitter::OnMouseMove(UINT nFlags, CPoint point)
{
//回避标准的CSplitterWnd::OnMouseMove(nFlags, point);
CWnd::OnMouseMove(nFlags, point);
}
BOOL CFixedSplitter::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
//回避标准的CSplitterWnd::OnSetCursor(pWnd, nHitTest, message);
return CWnd::OnSetCursor(pWnd, nHitTest, message);
}
最后把CSplitterWnd m_cSplitter声明,修改为:CFixedSplitter m_cSplitter; 完成!
-------------------------------------------------------------------------------------------
|对话框窗口切分|
-------------------------------------------------------------------------------------------
.h文件
CFrameWnd *m_pMyFrame;
CSplitterWnd m_cSplitter;
CSplitterWnd m_cSplitterone;
virtual BOOL OnInitDialog();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
.cpp文件中
BOOL CLoadAdjustmentInventoryDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect cRect;
GetWindowRect(&cRect);
ScreenToClient(&cRect);
m_pMyFrame->MoveWindow(&cRect);
m_pMyFrame->ShowWindow(SW_SHOW);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
int CLoadAdjustmentInventoryDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: 在此添加您专用的创建代码
CString strMyClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW,
::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH),
::LoadIcon(NULL, IDI_APPLICATION));
// Create the frame window with "this" as the parent
m_pMyFrame = new CFrameWnd;
m_pMyFrame->Create(strMyClass,"", WS_CHILD, CRect(0,0,300,300), this);
m_pMyFrame->ShowWindow(SW_SHOW);
// and finally, create the splitter with the frame as the parent
m_cSplitter.CreateStatic(m_pMyFrame,2, 1); //在Frame里切分视图窗口为1×2,就是一行两列
m_cSplitterone.CreateStatic(&m_cSplitter,1,2,WS_CHILD|WS_VISIBLE,m_cSplitter.IdFromRowCol(1,0));
m_cSplitter.CreateView(0,0, RUNTIME_CLASS(CThereAreStockSegmentationDlg),CSize(100,100), NULL);//第一行一列
m_cSplitterone.CreateView(0,0, RUNTIME_CLASS(CThereAreStockSegmentationoneDlg),CSize(100,100), NULL);
m_cSplitterone.CreateView(0,1, RUNTIME_CLASS(CThereAreStockSegmentationtwoDlg),CSize(100,100), NULL);//第一行二列
return 0;
}
说说切分后不能移动,不能拖拉
第1步:首先要创建一个新的CSplitterWnd派生类,它将完成锁定分割器的行为,我们把这个类称为CFixedSplitter。
class CFixedSplitter: public CSplitterWnd{};
第2步:使用ClassWizard在CFixedSplitter类中增加句柄来处理WM_LBUTTONDOWN,WM_MOUSEMOVE和WM_SETCURSOR消息。这些消息的具体实现见下面的代码。它们达
到了锁定分割器的目的。
void CFixedSplitter::OnLButtonDown(UINT nFlags, CPoint point)
{
//回避标准的CSplitterWnd处理过程CSplitterWnd::OnLButtonDown(UINT nFlags, CPoint point);
CWnd::OnLButtonDown(nFlags, point);
}
void CFixedSplitter::OnMouseMove(UINT nFlags, CPoint point)
{
//回避标准的CSplitterWnd::OnMouseMove(nFlags, point);
CWnd::OnMouseMove(nFlags, point);
}
BOOL CFixedSplitter::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
//回避标准的CSplitterWnd::OnSetCursor(pWnd, nHitTest, message);
return CWnd::OnSetCursor(pWnd, nHitTest, message);
}
最后把CSplitterWnd m_cSplitter声明,修改为:CFixedSplitter m_cSplitter; 完成!
-------------------------------------------------------------------------------------------
0 0
- |对话框窗口切分|
- 切分窗口
- 窗口切分
- 窗口切分
- 切分窗口
- 窗口切分的静态切分
- VS2013-切分对话框
- C#中切分窗口
- 三分窗口(静态切分)
- MDI,SDI切分窗口
- splitter st 切分窗口
- 使用CSplitterWnd切分窗口
- 【MFC】窗口切分
- 如何切分窗口
- SDI中的窗口切分
- 窗口切分代码。
- MFC 窗口静态切分
- 三叉切分窗口
- hdu 5088 Revenge of Nim II(高斯消元)
- 求字母的个数
- git提交到github
- .net读取Excel批注
- NSString与NSMutableString的常用操作
- |对话框窗口切分|
- Java程序员笔试面试之String5
- 第十周项目2:解密字符
- 【传统网络】交换机三种端口模式Access、Hybrid和Trunk的报文处理对比
- 杭电oj 1870-愚人节的礼物
- 忽略大小写比较字符串大小
- |对话框与对话框中发送消息实例|
- Linux 动态库剖析
- 网络编程