我从CWnd继承了一个类,发现一个很怪的现象:如果我在这个类上绘图的话CPU占用率很低,几乎是0。但是始终显示一个表示忙的漏斗光标,这样用起来很不爽。我的绘图操作没有占资源的话,是什么造成出现表示忙的漏斗光标?有懂这个的指点一下,万分感谢。
下面是我的代码:// NewWnd.cpp : implementation file
//#include "stdafx.h"
#include "NewWnd.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CNewWndCNewWnd::CNewWnd()
{
m_nStyle = 0;
m_clBkColor = RGB( 255, 255, 255 );
m_bShowCursor = FALSE;
m_bTopMost = TRUE;
}CNewWnd::~CNewWnd()
{}
BEGIN_MESSAGE_MAP(CNewWnd, CWnd)
//{{AFX_MSG_MAP(CNewWnd)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewWnd message handlers
int CNewWnd::Create( CWnd* pParentWnd, UINT nStyle, UINT nID )
{
m_nStyle = nStyle;
return CreateEx(
0,
NULL,
NULL,
WS_POPUP | WS_VISIBLE,
CRect( 0, 0, 0, 0 ),
pParentWnd,
nID );
}
BOOL CNewWnd::PreCreateWindow(CREATESTRUCT& cs)
{
static CString sClassName;
if ( sClassName.IsEmpty() )
{
sClassName = AfxRegisterWndClass( 0 );
} cs.hMenu = NULL;
cs.lpszClass = sClassName;
cs.style = WS_POPUP;
cs.dwExStyle |= WS_EX_TOOLWINDOW;
return CWnd::PreCreateWindow(cs);
}
void CNewWnd::SetBKColor(COLORREF clbk)
{
m_clBkColor = clbk;
this->Invalidate();
}
void CNewWnd::OnShowWindow(BOOL bShow, UINT nStatus)
{
CWnd::OnShowWindow(bShow, nStatus);
SetForegroundWindow();
SetActiveWindow(); ShowCursor( m_bShowCursor );
}
void CNewWnd::OnPaint()
{
CPaintDC dc(this);
RECT rc;
this->GetClientRect( &rc );
dc.FillSolidRect( &rc, m_clBkColor );
}我把OnPaint里面的代码注释掉也没有解决,很是郁闷:(
下面是我的代码:// NewWnd.cpp : implementation file
//#include "stdafx.h"
#include "NewWnd.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CNewWndCNewWnd::CNewWnd()
{
m_nStyle = 0;
m_clBkColor = RGB( 255, 255, 255 );
m_bShowCursor = FALSE;
m_bTopMost = TRUE;
}CNewWnd::~CNewWnd()
{}
BEGIN_MESSAGE_MAP(CNewWnd, CWnd)
//{{AFX_MSG_MAP(CNewWnd)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewWnd message handlers
int CNewWnd::Create( CWnd* pParentWnd, UINT nStyle, UINT nID )
{
m_nStyle = nStyle;
return CreateEx(
0,
NULL,
NULL,
WS_POPUP | WS_VISIBLE,
CRect( 0, 0, 0, 0 ),
pParentWnd,
nID );
}
BOOL CNewWnd::PreCreateWindow(CREATESTRUCT& cs)
{
static CString sClassName;
if ( sClassName.IsEmpty() )
{
sClassName = AfxRegisterWndClass( 0 );
} cs.hMenu = NULL;
cs.lpszClass = sClassName;
cs.style = WS_POPUP;
cs.dwExStyle |= WS_EX_TOOLWINDOW;
return CWnd::PreCreateWindow(cs);
}
void CNewWnd::SetBKColor(COLORREF clbk)
{
m_clBkColor = clbk;
this->Invalidate();
}
void CNewWnd::OnShowWindow(BOOL bShow, UINT nStatus)
{
CWnd::OnShowWindow(bShow, nStatus);
SetForegroundWindow();
SetActiveWindow(); ShowCursor( m_bShowCursor );
}
void CNewWnd::OnPaint()
{
CPaintDC dc(this);
RECT rc;
this->GetClientRect( &rc );
dc.FillSolidRect( &rc, m_clBkColor );
}我把OnPaint里面的代码注释掉也没有解决,很是郁闷:(
解决方案 »
- 【100分,求指点】新手做小程序,准备写好后开源。想得到指点!
- 请问个问题
- ShellExecute()调用函数问题
- 求高手给个选择文件夹的代码,谢谢
- 关于WSAAsyncSelect的一个简单问题!可是我却不会!
- 对SetRect的不解~ 大虾们帮我解释解释啊~
- 如何把ie内嵌到自己的dialog中,最好有例子,谢谢[email protected]
- 一个Release版的怪问题!100分——在线等待。
- 怎样设置 clistctrl 中的字体?
- 请教大侠,在OICQ的通讯中,俩个客户端是怎么样进行的,是经过服务器那,还是他们间建立通道,能否详细讲一下,或提供个类子啊!!多谢了!
- vc里是不是不能用vector类型?
- 一个简单的问题,对话框的显示
{
CWnd::OnShowWindow(bShow, nStatus);
SetForegroundWindow();
SetActiveWindow(); ShowCursor( m_bShowCursor );
}
????