求助,工具条的停靠设置?

Watchmen_ 2012-05-06 12:43:06



如何才能实现想图中1、2、3工具条停靠的效果?
...全文
278 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
向立天 2013-03-05
  • 打赏
  • 举报
回复
您好 我是本版版主 此帖已多日无人关注 请您及时结帖 如您认为问题没有解决可按无满意结帖处理 另外本版设置了疑难问题汇总帖 并已在版面置顶 相关规定其帖子中有说明 您可以根据规定提交您帖子的链接 如您目前不想结帖只需回帖说明 我们会删除此结帖通知 见此回复三日内无回应 我们将强制结帖 相关规定详见界面界面版关于版主结帖工作的具体办法
tech_ben 2012-05-17
  • 打赏
  • 举报
回复
大家以前都没有碰到过这个需求吗?
vc_ai_hao_zhe 2012-05-11
  • 打赏
  • 举报
回复
自己编的控制条是在MFC下做的,基类是CSizingControlBar,网上下载的,CSizingControlBar的基类是CControlBar
vc_ai_hao_zhe 2012-05-11
  • 打赏
  • 举报
回复
自己编的控制条是在MFC下做的,基类是CSizingControlBar,从网上下的,CSizingControlBar的基类也是CControlBar。
tech_ben 2012-05-11
  • 打赏
  • 举报
回复
多谢vc_ai_hao_zhe,这个我也下载过,当时还不懂就放下了,我再研究研究。
tech_ben 2012-05-10
  • 打赏
  • 举报
回复
伯仲叔=123
tech_ben 2012-05-10
  • 打赏
  • 举报
回复
吾与Watchmen_共事

皆初学MFC,知选错路,但依性坚持到底。
因无VC经历所以不知深浅,“外来的和尚”狂谈MFC:

它是所谓的库,是可以供自己使用的程序资源:

——1)函数=功能
  2)变量=数据=信息

——⑴消息=管理
  ⑵存储=DATA+CODE=010010100=你的“员工”

——∵风水=生存环境+发展环境+物质环境+精神境界
  ∴用MFC要在意Windows编程环境≈API+SDK+GDI+……+微软的团队协作思想

——∵VC是一种编程“语言”
  ∴要习惯和善于沟通,与机器沟通(程序员也要软硬兼施)、与他人沟通(规范与协作)


这个问题让我一直在读MFC的代码,也希望MFC的先行者和后来者,在确定自己用MFC的前提下,先读懂它再言自己编程实现某些功能,毕竟MFC是个库,至少得先知其是宝库还是烂库才是。

还望众仙明点!

///////////////////////
回来拽(=拖动)此帖题:
1、观,觉其缺省工具条Docking规则是以矩形为剩余控条排位空间,自然简易,只取左上角;
2、察,于剩余矩形空间,居上可任意定位拖动平移,而居左竖线则不可竖动,似有优先先后,dwDockBarMap使然?
3、二倍行高居左上,仲者随之居右肩之左上,剩余空间已非矩形,似菜刀,伯之右竖线不能为叔者徘徊,何参使之?何Function为之?


。。。。。。
tech_ben 2012-05-10
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 的回复:]
我试的是我自己编写的控制条,是可以的,不过用MFC CToolBar做出来的确实不行。对不起了。
[/Quote]
vc_ai_hao_zhe朋友,谈不上什么对不起,都是讨论技术。
请问自己编的控制条是在MFC下做的吗?基类是哪个?
vc_ai_hao_zhe 2012-05-10
  • 打赏
  • 举报
回复
我试的是我自己编写的控制条,是可以的,不过用MFC CToolBar做出来的确实不行。对不起了。
tech_ben 2012-05-10
  • 打赏
  • 举报
回复
如果花钱解决问题,有没有高人感兴趣?
(顺便问一下,帖子里可不可以放联系方式?)
tech_ben 2012-05-09
  • 打赏
  • 举报
回复
MSDN里没有的,可能有关的类贴出来,请高手们帮忙分析分析:


★★★★★★★★★★★★★★★★★★★★★★★★★★★★
//////////////////////////////////////////////////////////////
// toolbar docking support
// 没有基类

class CDockContext
{
public:
// Construction
CDockContext(CControlBar* pBar);

// Attributes
CPoint m_ptLast; // last mouse position during drag
CRect m_rectLast;
CSize m_sizeLast;
BOOL m_bDitherLast;

// Rectangles used during dragging or resizing
CRect m_rectDragHorz;
CRect m_rectDragVert;
CRect m_rectFrameDragHorz;
CRect m_rectFrameDragVert;

CControlBar* m_pBar; // the toolbar that created this context
CFrameWnd* m_pDockSite; // the controlling frame of the CControlBar
DWORD m_dwDockStyle; // allowable dock styles for bar
DWORD m_dwOverDockStyle; // style of dock that rect is over
DWORD m_dwStyle; // style of control bar
BOOL m_bFlip; // if shift key is down
BOOL m_bForceFrame; // if ctrl key is down

CDC* m_pDC; // where to draw during drag
BOOL m_bDragging;
int m_nHitTest;

UINT m_uMRUDockID;
CRect m_rectMRUDockPos;

DWORD m_dwMRUFloatStyle;
CPoint m_ptMRUFloatPos;

// Drag Operations
virtual void StartDrag(CPoint pt);
void Move(CPoint pt); // called when mouse has moved
void EndDrag(); // drop
void OnKey(int nChar, BOOL bDown);

// Resize Operations
virtual void StartResize(int nHitTest, CPoint pt);
void Stretch(CPoint pt);
void EndResize();

// Double Click Operations
virtual void ToggleDocking();

// Operations
void InitLoop();
void CancelLoop();

// Implementation
public:
~CDockContext();
BOOL Track();
void DrawFocusRect(BOOL bRemoveRect = FALSE);
// draws the correct outline
void UpdateState(BOOL* pFlag, BOOL bNewValue);
DWORD CanDock();
CDockBar* GetDockBar(DWORD dwOverDockStyle);
};







★★★★★★★★★★★★★★★★★★★★★★★★★★★★

// CControlBarInfo - used for docking serialization
// 没有基类

class CControlBarInfo
{
public:
// Implementation
CControlBarInfo();

// Attributes
UINT m_nBarID; // ID of this bar
BOOL m_bVisible; // visibility of this bar
BOOL m_bFloating; // whether floating or not
BOOL m_bHorz; // orientation of floating dockbar
BOOL m_bDockBar; // TRUE if a dockbar
CPoint m_pointPos; // topleft point of window

UINT m_nMRUWidth; // MRUWidth for Dynamic Toolbars
BOOL m_bDocking; // TRUE if this bar has a DockContext
UINT m_uMRUDockID; // most recent docked dockbar
CRect m_rectMRUDockPos; // most recent docked position
DWORD m_dwMRUFloatStyle; // most recent floating orientation
CPoint m_ptMRUFloatPos; // most recent floating position

CPtrArray m_arrBarID; // bar IDs for bars contained within this one
CControlBar* m_pBar; // bar which this refers to (transient)

void Serialize(CArchive& ar, CDockState* pDockState);
BOOL LoadState(LPCTSTR lpszProfileName, int nIndex, CDockState* pDockState);
BOOL SaveState(LPCTSTR lpszProfileName, int nIndex);
};





★★★★★★★★★★★★★★★★★★★★★★★★★★★★

// CDockBar - used for docking

class CDockBar : public CControlBar
{
DECLARE_DYNAMIC(CDockBar)

// Construction
public:
CDockBar(BOOL bFloating = FALSE); // TRUE if attached to CMiniDockFrameWnd
BOOL Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID);

// Attributes
BOOL m_bFloating;

virtual BOOL IsDockBar() const;
int GetDockedCount() const;
virtual int GetDockedVisibleCount() const;

// Operations
void DockControlBar(CControlBar* pBar, LPCRECT lpRect = NULL);
void ReDockControlBar(CControlBar* pBar, LPCRECT lpRect = NULL);
BOOL RemoveControlBar(CControlBar*, int nPosExclude = -1, int nAddPlaceHolder = 0);
void RemovePlaceHolder(CControlBar* pBar);

// Implementation
public:
virtual ~CDockBar();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual void DoPaint(CDC* pDC);

// public implementation helpers
void GetBarInfo(CControlBarInfo* pInfo);
void SetBarInfo(CControlBarInfo* pInfo, CFrameWnd* pFrameWnd);
int FindBar(CControlBar* pBar, int nPosExclude = -1);
void ShowAll(BOOL bShow);

CPtrArray m_arrBars; // each element is a CControlBar
protected:
BOOL m_bLayoutQuery;
CRect m_rectLayout;

CControlBar* GetDockedControlBar(int nPos) const;

// implementation helpers
int Insert(CControlBar* pBar, CRect rect, CPoint ptMid);
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);

//{{AFX_MSG(CDockBar)
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
afx_msg void OnNcPaint();
afx_msg void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
afx_msg void OnPaint();
afx_msg LRESULT OnSizeParent(WPARAM, LPARAM);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

friend class CMiniDockFrameWnd;
};






★★★★★★★★★★★★★★★★★★★★★★★★★★★★

class CMiniDockFrameWnd : public CMiniFrameWnd
{
DECLARE_DYNCREATE(CMiniDockFrameWnd)

public:
// Construction
CMiniDockFrameWnd();
virtual BOOL Create(CWnd* pParent, DWORD dwBarStyle);

// Operations
virtual void RecalcLayout(BOOL bNotify = TRUE);

// Implementation
public:
CDockBar m_wndDockBar;

//{{AFX_MSG(CMiniFrameWnd)
afx_msg void OnClose();
afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
//}}AFX_MSG
afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
DECLARE_MESSAGE_MAP()
};






★★★★★★★★★★★★★★★★★★★★★★★★★★★★

这个MSDN里有

class CMiniFrameWnd : public CFrameWnd
{
DECLARE_DYNCREATE(CMiniFrameWnd)

// Constructors
public:
CMiniFrameWnd();
BOOL Create(LPCTSTR lpClassName, LPCTSTR lpWindowName,
DWORD dwStyle, const RECT& rect,
CWnd* pParentWnd = NULL, UINT nID = 0);
BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
DWORD dwStyle, const RECT& rect,
CWnd* pParentWnd = NULL, UINT nID = 0);

// Implementation
public:
~CMiniFrameWnd();

static void AFX_CDECL Initialize();

//{{AFX_MSG(CMiniFrameWnd)
afx_msg BOOL OnNcActivate(BOOL bActive);
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpParams);
afx_msg UINT OnNcHitTest(CPoint point);
afx_msg void OnNcPaint();
afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint pt);
afx_msg void OnLButtonUp(UINT nFlags, CPoint pt);
afx_msg void OnMouseMove(UINT nFlags, CPoint pt);
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnGetMinMaxInfo(MINMAXINFO* pMMI);
afx_msg LRESULT OnGetText(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnGetTextLength(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnFloatStatus(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnQueryCenterWnd(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpcs);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

public:
virtual void CalcWindowRect(LPRECT lpClientRect,
UINT nAdjustType = adjustBorder);

static void PASCAL CalcBorders(LPRECT lpClientRect,
//DWORD dwStyle = WS_THICKFRAME | WS_CAPTION, DWORD dwExStyle = 0);
DWORD dwStyle, DWORD dwExStyle = 0);

protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

protected:
BOOL m_bSysTracking;
BOOL m_bInSys;
BOOL m_bActive;
CString m_strCaption;

void InvertSysMenu();
};
Watchmen_ 2012-05-09
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 的回复:]
我通过这个方法已经实现了,停靠时要从上往下且根据位置来停靠。
[/Quote]

真的吗?

麻烦“vc_ai_hao_zhe”你给截个图看看,最后的效果行吗?

谢谢了!!
Watchmen_ 2012-05-09
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 的回复:]
图中的停靠效果
是你看到的还是自己想出来了
你这个图肯定是做的
不是截的
不过我感觉MFC标准工具条是实现不了的
[/Quote]

我在别的软件界面上看到过,工具条确实能实现这样的停靠效果。

向立天 2012-05-09
  • 打赏
  • 举报
回复
图中的停靠效果
是你看到的还是自己想出来了
你这个图肯定是做的
不是截的
不过我感觉MFC标准工具条是实现不了的
vc_ai_hao_zhe 2012-05-09
  • 打赏
  • 举报
回复
我通过这个方法已经实现了,停靠时要从上往下且根据位置来停靠。
Watchmen_ 2012-05-09
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]
如果想通过代码实现定位可以利用DockControlBar函数,有了这函数,你懂的。
[/Quote]

DockControlBar函数和鼠标移动工具条是一样的,无法实现图中的停靠效果。
vc_ai_hao_zhe 2012-05-09
  • 打赏
  • 举报
回复
如果想通过代码实现定位可以利用DockControlBar函数,有了这函数,你懂的。
tech_ben 2012-05-08
  • 打赏
  • 举报
回复
拖动以后最后定位的函数是哪个?
Watchmen_ 2012-05-08
  • 打赏
  • 举报
回复
My God!!!

这个问题这么难解决吗?望高手们指教一二!
tech_ben 2012-05-07
  • 打赏
  • 举报
回复
我也在想这个问题:

有不等高工具条情况,比如1的高度是234的两倍
通常工具条的布局是ToolBar1、2、3

而如果有1在,4的位置是拖不上去的。

请教:怎样才能实现使某个工具条可以拖放到4的位置,即:4的左上角顶在1的腰间 ???



加载更多回复(1)

15,979

社区成员

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

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