pDC->DrawIcon()函数使用时,LoadIcon(IDI_ICON1)中的IDI_ICON1为32*32时可以画到界面上,当IDI_ICON1为16*32时就画不到界面上了,大家帮我看看这是怎么回事?谢谢了

解决方案 »

  1.   

    我用的也是32 * 32;
    问题描述: 一个对话框,一个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);
    }欢迎访问我的空间看看
      

  2.   

    DrawIconEx
    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); 
      

  3.   


    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); 
      

  4.   

    估计是你算的left,top, right,bottom不对。
      

  5.   

    哎,弄不了,只能转成bmp来画了。
      

  6.   

    也许是因为是非standard ICON,所以不能使用DrawIcon/DrawIconEx()来画吧
      

  7.   


    用GetLastError看看到底是什么错误。
      

  8.   


    vc6下用没问题,难道你psdk太低了