窗体融合技术中CMainFrame窗口的"numeric identifier"是什么?

guanyuqi 2009-08-11 01:44:50
程序中有如下语句:
m_DockBarID = GetParent()->GetDlgCtrlID()

m_DockBarID为UINT型,GetParent()的值为CMainFrame窗口,想问下当拖动浮动窗体(此窗体继承自CControlBar类)停靠在主框架窗口的上、下、左、右时,m_DockBarID的值是否可为AFX_IDW_DOCKBAR_TOP、AFX_IDW_DOCKBAR_BOTTOM、AFX_IDW_DOCKBAR_LEFT、AFX_IDW_DOCKBAR_RIGHT。如是这样的话,那通过对CMainFrame窗口调用GetDlgCtrlID()函数得到的值是通过什么机制分配给CMainFrame窗口的呢?是程序员通过代码分配还是MFC分配什么的?

下面为程序部分代码


// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINFRM_H__8C66E807_ECA7_4601_A8E2_47F74CAD0FA1__INCLUDED_)
#define AFX_MAINFRM_H__8C66E807_ECA7_4601_A8E2_47F74CAD0FA1__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Tools.h";
#include "DockBarCtrl.h"
class CMainFrame : public CFrameWnd
{

protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:
CTools m_ToolDlg;
CDockBarCtrl m_DockBar;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;

// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINFRM_H__8C66E807_ECA7_4601_A8E2_47F74CAD0FA1__INCLUDED_)


// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "窗体融合技术.h"

#include "MainFrm.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)
//{{AFX_MSG_MAP(CMainFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
// TODO: add member initialization code here

}

CMainFrame::~CMainFrame()
{
}

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("Failed to create toolbar\n");
return -1; // fail to create
}

if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}

// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);

m_DockBar.Create(this,&m_ToolDlg,IDD_TOOLS_DIALOG);

m_DockBar.SetBarStyle(m_DockBar.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC);


m_DockBar.EnableDocking(CBRS_ALIGN_ANY);

DockControlBar(&m_DockBar);

return 0;
}





#if !defined(AFX_DOCKBARCTRL_H__52BCC555_E091_4BCA_9991_2B2A36F655AB__INCLUDED_)
#define AFX_DOCKBARCTRL_H__52BCC555_E091_4BCA_9991_2B2A36F655AB__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DockBarCtrl.h : header file
//
#include "afxpriv.h"
/////////////////////////////////////////////////////////////////////////////
// CDockBarCtrl window

class CDockBarCtrl : public CControlBar
{
// Construction
public:
CDockBarCtrl();

// Attributes
public:
UINT m_DockBarID;

CDialog *m_pDlg; //关联的对话框
CBrush m_bkBrush; //背景画刷
CString m_Caption; //窗口标题

CRect m_FloatRect; //浮动时的窗口区域
CRect m_VerRect; //拖入时,在左\右显示时的区域
CRect m_HorRect; //拖入时,在上\下显示时的区域

//确定控制条的非客户区域部分
int m_ncTBandHeight; //非客户区域上边条高度
int m_ncRBandWidth; //右边条的宽度
int m_ncLBandWidth ; //确定左边条的宽度
int m_ncBBandHeight; // 确定底边条的宽度

//定义标题栏按钮的显示区域

CRect m_closeRC; //关闭按钮的显示区域
CRect m_maxRc; //最大化按钮的显示区域

int m_ncLeftWidth ; //记录垂直显示时的非客户区域左边条宽度
int m_ncTopHeight; // 记录水平显示时的非客户区域上边条的宽度

COLORREF m_TopBandColor,m_BottomBandColor; //标题线条的颜色

BOOL m_IsTraking; //是否处于调整控制条大小状态
BOOL m_IsInRect; //判断控制条是否处于停靠状态

CPoint m_OldPos; //鼠标按下时原始点位置
CRect m_Bandrc; //拖动的边条区域

CRect m_temprc; //临时的区域
int m_TopInterval,m_LeftInterval; //控制条相对父窗口的位置

int m_HitTest;
CSize m_Min; //当控制条处于浮动状态时,限制用户改变控制小的最小区域


// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDockBarCtrl)
public:
virtual BOOL Create(CWnd* pParentWnd, CDialog* pDialog, UINT nID, DWORD dwStyle= WS_CHILD | WS_VISIBLE | CBRS_LEFT, CCreateContext* pContext = NULL);
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
//}}AFX_VIRTUAL

// Implementation
public:
void DrawDashLine(CRect rect);
void EndTracking();
void BeginTracking();
void DrowTitleLine(CDC* pDC);
virtual ~CDockBarCtrl();

//实现父类的抽象方法
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
// Generated message map functions
protected:
//{{AFX_MSG(CDockBarCtrl)
afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
afx_msg void OnNcPaint();
afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
afx_msg UINT OnNcHitTest(CPoint point);
afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG

DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DOCKBARCTRL_H__52BCC555_E091_4BCA_9991_2B2A36F655AB__INCLUDED_)


// DockBarCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "窗体融合技术.h"
#include "DockBarCtrl.h"
#include "Tools.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDockBarCtrl

CDockBarCtrl::CDockBarCtrl()
{
m_bkBrush.CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
m_Caption = "窗口融合技术";

m_ncTBandHeight = 20;
m_ncLBandWidth = 3;
m_ncRBandWidth = 6;
m_ncBBandHeight = 3;
m_TopBandColor = GetSysColor(COLOR_BTNHILIGHT);
m_BottomBandColor = GetSysColor(COLOR_BTNSHADOW);
m_IsTraking = FALSE;
m_IsInRect = FALSE;
m_Min = CSize(32,32);
}

CDockBarCtrl::~CDockBarCtrl()
{

}

BEGIN_MESSAGE_MAP(CDockBarCtrl, CControlBar)
//{{AFX_MSG_MAP(CDockBarCtrl)
ON_WM_WINDOWPOSCHANGED()
ON_WM_NCCALCSIZE()
ON_WM_NCPAINT()
ON_WM_NCLBUTTONDOWN()
ON_WM_NCHITTEST()
ON_WM_NCLBUTTONDBLCLK()
ON_WM_LBUTTONDBLCLK()
ON_WM_SETCURSOR()
ON_WM_MOUSEMOVE()
ON_WM_NCLBUTTONUP()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDockBarCtrl message handlers
void CDockBarCtrl::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
{
CWnd::UpdateDialogControls(pTarget, bDisableIfNoHndler);
}

BOOL CDockBarCtrl::Create(CWnd* pParentWnd, CDialog* pDialog, UINT nID, DWORD dwStyle, CCreateContext* pContext)
{
ASSERT_VALID(pParentWnd);

ASSERT(!((dwStyle& CBRS_SIZE_DYNAMIC)&&(dwStyle&CBRS_SIZE_FIXED )));

m_dwStyle = dwStyle & CBRS_ALL;
//注册窗口类
CString classname;
classname = AfxRegisterWndClass(CS_DBLCLKS,LoadCursor(NULL,IDC_ARROW),m_bkBrush,0);

//创建窗口类
CWnd::Create(classname,m_Caption,dwStyle,CRect(0,0,0,0),pParentWnd,0);

m_pDlg = pDialog;
m_pDlg->Create(nID,this);

m_pDlg->GetWindowRect(m_FloatRect);

m_HorRect.CopyRect(m_FloatRect);
m_VerRect.CopyRect(m_FloatRect);

return true;
}


...全文
34 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
界面
创建于2007-09-28

1.5w+

社区成员

VC/MFC 界面
申请成为版主
帖子事件
创建了帖子
2009-08-11 01:44
社区公告
暂无公告