pDC->DrawIcon()函数使用时,LoadIcon(IDI_ICON1)中的IDI_ICON1为32*32时可以画到界面上,当IDI_ICON1为16*32时就画不到界面上了,大家帮我看看这是怎么回事?谢谢了
解决方案 »
- 女朋友没了。。。。。
- malloc申请空间时遇到的问题unhandled exception in xxx.exe 0xC0000005:Access Violation
- 如何给日期格式的字符串加上一天?
- atl的shell扩展编程,调用CDialog类,出现运行错误?怎么解决
- 关于使用CButtonST类的问题
- 如何在windows下用gcc?
- 矛盾file "..\..\Lib\dll\SkinMagicLib.lib"
- 有人知道如何立即退出函数吗?
- 小弟初学,关于IMoniker有一些疑惑的地方
- 怎样在对话框中显示CListView类的窗口?
- 求蓝牙编程资料
- 《Visual C++网络通信编程实用案例精选》NetTrafficButton的莫名问题
问题描述: 一个对话框,一个cstatic控件,放在对话框上面,cstatic控件映射变量为CTestrRect m_staticDr;
对话框类为CMy1111Dlg
void CMy1111Dlg::OnLButtonDown(UINT nFlags, CPoint point)
{
ClientToScreen(&m_staticDr.m_clientRect);
if (m_staticDr.m_clientRect.PtInRect(point))
{
MessageBox(_T("客户区坐标部单击了"), "", MB_YESNO);
}
或者
if (m_staticDr.m_clientRect.PtInRect(point))
{
MessageBox(_T("客户区坐标部单击了"), "", MB_YESNO);
}
}方法2:
void CMy1111Dlg::OnLButtonDown(UINT nFlags, CPoint point)
{
if (m_staticDr.m_windRect.PtInRect(point))
{
MessageBox(_T("窗口区坐标内部单击了"), "", MB_YESNO);
}
}
不论方法一或者用方法二,都不能很准确的做出反应,也就是鼠标点击了矩形区域,但是程序没有获取到!
如果更改了对话框的风格为没有标题栏,则方法二基本可以!class CTestRect : public CStatic
{
public: CRect m_clientRect;
CRect m_windRect;
// Operations
public:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CTestRect();
// Generated message map functions
protected:
//{{AFX_MSG(CTestRect)
afx_msg void OnPaint();
//}}AFX_MSG DECLARE_MESSAGE_MAP()
};void CTestRect::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
GetClientRect(&m_clientRect);
GetWindowRect(&m_windRect);
CStatic::PreSubclassWindow();
}void CTestRect::OnPaint()
{
CPaintDC dc(this); // device context for painting
CBrush br(RGB(255, 0, 128)), *pOldBr = NULL;
pOldBr = dc.SelectObject(&br);
dc.Ellipse(&m_clientRect); dc.SelectObject(pOldBr);
}欢迎访问我的空间看看
This function draws an icon in the specified device context, performing the raster operations as specified.BOOL DrawIconEx(
HDC hdc,
int xLeft,
int yTop,
HICON hIcon,
int cxWidth, //绘制的宽度
int cyWidth, //绘制的高度
UINT istepIfAniCur,
HBRUSH hbrFlickerFreeDraw,
UINT diFlags);
CRect rcIcon(CPoint(10, 10), CSize(16, 32));
::DrawIconEx(dc.GetSafeHdc(), rcIcon.left, rcIcon.top, m_hIcon, rcIcon.Width(), rcIcon.Height(), 0, NULL, DI_NORMAL);
用GetLastError看看到底是什么错误。
vc6下用没问题,难道你psdk太低了