一个关于分隔栏的问题

一个傻冒 2003-09-19 01:17:51
我怎么才能让分隔栏固定在一个位置上? 让它不能来回的拖动。
...全文
54 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
cameozhang 2003-09-25
  • 打赏
  • 举报
回复
你可以继承CSplitterWnd类,例如为CMySplitter
在这个类中重载三个函数
OnSetCursor
OnMouseMove
OnLButtonDown

删除原来CSplitterWnd的默认返回值,分别代替为
CWnd::OnSetCursor
CWnd::OnMouseMove
无返回

然后在用这个类,生成的分割条就不会响应鼠标拖拽事件了
nonocast 2003-09-25
  • 打赏
  • 举报
回复
Follow the step-by-step guide below to lock your splitter
Step 1

在WorkSpace中的YourPro Classes上右键,在弹出菜单中选择New Class创建一个新的CSplitterWnd的派生类,在Class type中选择generic class,并在base class(es)中填入CSplitterWnd,在Name中随便你填,如CFixedSplitter,他将完成锁定splitter的行为。相信你应该没问题的。

Step 2

在你添加的新类中重载WM_LMUTTONDOWN,WM_MOUSEMOVE和WM_SETCURSOR消息。

代码如下:
void CFixedSplitter::OnLButtonDown(UINT nFlags, CPoint point)
{

// Bypass standard CSplitterWnd processing
CWnd::OnLButtonDown(nFlags, point);
}

void CFixedSplitter::OnMouseMove(UINT nFlags, CPoint point)
{

// Bypass standard CSplitterWnd processing
CWnd::OnMouseMove(nFlags, point);
}

BOOL CFixedSplitter::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// Bypass standard CSplitterWnd processing
return CWnd::OnSetCursor(pWnd, nHitTest, message);
}

Step 3
然后在Frame中加入你的头文件,将原来的CSplitterWnd替换成CFixedSplitter即可

说明:
道理说明白了很简单,就是跳过了CSplitterWnd的OnMouseMove和ObNouseDown,换句话说CSplitterWnd将接受不到来自界面的消息,被我们截获后之间给了CWnd,其实是一种假象,i.e.锁定Splitter
我们的CFixedSplitter还回避了标准的WM_SSETCURSOR,以保证光标不改变成拖动的形状。

如有任何问题,请致信
o_nono@163.net
附带上帖子号

---------------------
May you succeed!
------------------
MicoInNet 2003-09-24
  • 打赏
  • 举报
回复
可是,大哥你错了,不是这个函数。
MicoInNet 2003-09-20
  • 打赏
  • 举报
回复
Thanks very much!
hoffen 2003-09-19
  • 打赏
  • 举报
回复
BOOL CSplitter::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
//return CSplitterWnd::PreTranslateMessage(pMsg);
return true;
}

//overlad the over function and then filter the message to it/s base class,then you can turn your function to reality.
Good luck!!!
hoffen 2003-09-19
  • 打赏
  • 举报
回复
I am troubled with this problem,the MSG Function of sliding for Splitter bar is
CaptureChanged();
but it/s no use to overlad the function
MicoInNet 2003-09-19
  • 打赏
  • 举报
回复
屏蔽拖动的消息就可以了。????

我也想屏蔽掉这个消息,但是我不知道在哪里屏蔽它。我查过了,分隔条移动是系统默认调用函数:
RecalcLayout()
如何屏蔽掉它?是不是重载该类的这个函数?
Kingore 2003-09-19
  • 打赏
  • 举报
回复
屏蔽拖动的消息就可以了。

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧