- UID
- 5537
- 积分
- 371
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-23
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
做个测试关于CAcUiDockControlBar类的
代码如下:
为什么我在调用test的时候是正常的,DockControlBar也出来了,也显示出文字,但只要双击DockControlBar,使它浮动,之后在双击,使它还原。这样反复几次,就会出现系统资源严重不足的情况,这是怎么回事?
<code>
///////////////////////////////////////////////////////
// h file
//////////////////////////////////////////////////////
class CPropertiyDlg: public CAcUiDockControlBar
//class CPropertiyDlg : public CAcUiDialogBar
{
DECLARE_DYNAMIC(CPropertiyDlg);
// Construction
public:
CPropertiyDlg(); // standard constructor
public:
virtual ~CPropertiyDlg(); // standard constructor
public:
BOOL MsgOut();
Draw();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropertiyDlg)
public:
virtual BOOL Create(CWnd*pParent, LPCSTR lpszTitle);
protected:
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
virtual void SizeChanged(CRect* lpRect,BOOL bFloating,int flags);
//}}AFX_VIRTUAL
private:
CFont m_font;
CDC m_MemDC;
CRect rcClient;
CBitmap m_Bitmap;
bool CanFrameworkTakeFocus() { return false;}
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPropertiyDlg)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
///////////////////////////////////////////////////////
// cpp file
///////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CPropertiyDlg, CAcUiDockControlBar)
CPropertiyDlg::CPropertiyDlg() : CAcUiDockControlBar()
{
//{{AFX_DATA_INIT(CPropertiyDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CPropertiyDlg::~CPropertiyDlg()
{
m_MemDC.DeleteDC();
}
BEGIN_MESSAGE_MAP(CPropertiyDlg, CAcUiDockControlBar)
//{{AFX_MSG_MAP(CPropertiyDlg)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CPropertiyDlg::Create(CWnd*pParent, LPCSTR lpszTitle)
{
CClientDC dc(this);
LOGFONT logFont;
ZeroMemory((void*)&logFont,sizeof(logFont));
strcpy(logFont.lfFaceName,"宋体");
logFont.lfHeight = -12;
logFont.lfWeight = 400;
logFont.lfCharSet = GB2312_CHARSET;
logFont.lfOutPrecision = 3;
logFont.lfClipPrecision = 2;
logFont.lfQuality = 1;
logFont.lfPitchAndFamily = 2;
m_font.CreateFontIndirect(&logFont);
CString strWndClass,strWndNote;
strWndClass = AfxRegisterWndClass (CS_DBLCLKS, LoadCursor (NULL, IDC_ARROW));
CRect rect (0, 0, 200, 450);
if (!CAcUiDockControlBar::Create (strWndClass,
lpszTitle,
WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
rect,
pParent, 0))
return FALSE;
GetClientRect(rcClient); //获取图片框大小
m_MemDC.CreateCompatibleDC(&dc);
m_Bitmap.CreateCompatibleBitmap(&dc,1024,1024);
return TRUE;
}
void CPropertiyDlg::SizeChanged (CRect *lpRect, BOOL bFloating, int flags)
{
GetClientRect(rcClient);
Draw();
}
BOOL CPropertiyDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
//
if ( wParam == 0x1234 ){//如果是m_wndTree
AfxMessageBox("Tree!!ok!!");
}
return CAcUiDockControlBar::OnNotify(wParam, lParam, pResult);
}
void CPropertiyDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (m_MemDC.GetSafeHdc() != NULL)
{
dc.BitBlt(0, 0, rcClient.Width(), rcClient.Height(), &m_MemDC, 0, 0, SRCCOPY);
}
CAcUiDockControlBar::OnPaint();
}
CPropertiyDlg::Draw()
{
GetClientRect(rcClient);
CClientDC dc(this);
m_MemDC.GetSafeHdc();
CBrush bkBrush;
bkBrush.CreateSolidBrush(RGB(255,255,207));
CBrush* pOldBrush = m_MemDC.SelectObject(&bkBrush);
m_MemDC.FillRect(rcClient,&bkBrush); //画背景
m_MemDC.SetViewportOrg(0,0);
m_MemDC.SetViewportExt(rcClient.right,rcClient.bottom);
m_MemDC.SetWindowOrg(0,0);
m_MemDC.SetWindowExt(rcClient.right,rcClient.bottom);
CFont font;
font.CreateFont(20, 0,0,0,FW_NORMAL, 0,0,0,
DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "隶书");
CFont* pOldFont = m_MemDC.SelectObject(&font);
m_MemDC.SetBkMode(TRANSPARENT);
m_MemDC.SetTextColor(RGB(0,255,100));
m_MemDC.TextOut(20, 20, "HELLO");
m_MemDC.SelectObject(&pOldFont);
DeleteObject(bkBrush);
DeleteObject(font);
m_MemDC.SelectObject(m_Bitmap);
m_MemDC.SelectObject(&pOldBrush);
InvalidateRect(rcClient);
}
///////////////////////////////////////////////////////////////////
// 命令调用
//////////////////////////////////////////////////////////////////
void test()
{
CPropertiyDlg *g_pShowMessage;
CMDIFrameWnd *pAcadFrame = acedGetAcadFrame();
if(!g_pShowMessage)
{
g_pShowMessage = new CPropertiyDlg;
CAcModuleResourceOverride resOverride;
const char dlgName[] = "测试";
g_pShowMessage->Create(pAcadFrame, dlgName);
g_pShowMessage->SetToolID (&clsIDControlBar);
g_pShowMessage->EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
g_pShowMessage->DockControlBar( AFX_IDW_DOCKBAR_RIGHT,CRect(0,0,150,200));
} else {
pAcadFrame->ShowControlBar (g_pShowMessage, TRUE, FALSE);
}
pAcadFrame->ShowControlBar (g_pShowMessage, FALSE, FALSE);
}
</code> |
|