自定义类响应mouse右键怎么都不行,高手进来看看!!!!!!up有分!!!第二贴啦
//CStaticDirectX.h
#if !defined(AFX_STATICDIRECTX_H__C4CADE79_6104_46F7_874E_AE48BA16657C__INCLUDED_)
#define AFX_STATICDIRECTX_H__C4CADE79_6104_46F7_874E_AE48BA16657C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// StaticDirectX.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CStaticDirectX window
class CStaticDirectX : public CStatic
{
// Construction
public:
CStaticDirectX();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CStaticDirectX)
//}}AFX_VIRTUAL
// Implementation
public:
int GetMouseX() { return m_lMousex; }
int GetMouseY() { return m_lMousey; }
virtual ~CStaticDirectX();
static CRect GetRect(UINT uID, CDialog *pDlg) // This static function saves re-writing GetRect for every dialog app that needs it
{
CWnd* pWnd = pDlg->GetDlgItem(uID); ASSERT(pWnd);
CRect rect;
pWnd->GetWindowRect( &rect );
pDlg->ScreenToClient( &rect );
return rect;
}
private:
// Mouse control:
long m_lMousex,m_lMousey;
// Generated message map functions
protected:
//{{AFX_MSG(CStaticDirectX)
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(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_STATICDIRECTX_H__C4CADE79_6104_46F7_874E_AE48BA16657C__INCLUDED_)
//// StaticDirectX.cpp : implementation file
//
#include "stdafx.h"
#include "main.h"
#include "StaticDirectX.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStaticDirectX
CStaticDirectX::CStaticDirectX()
{
}
CStaticDirectX::~CStaticDirectX()
{
}
BEGIN_MESSAGE_MAP(CStaticDirectX, CStatic)
//{{AFX_MSG_MAP(CStaticDirectX)
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStaticDirectX message handlers
void CStaticDirectX::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ShowCursor(FALSE);
// CStatic::OnRButtonDown(nFlags, point);
}
void CStaticDirectX::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ShowCursor(FALSE);
// CStatic::OnLButtonDown(nFlags, point);
}
继承的Cstatic怎么OnLButtonDown、OnRButtonDown不起作用呀,我在OninitDialog里
m_mystatic.Create("", WS_VISIBLE|SS_NOTIFY|SS_SUNKEN, CRect(20,240,70,320),this,IDC_STATIC_V11)
OnLButtonDown、OnRButtonDown就可以了,但是
m_mystatic.Create("", WS_VISIBLE|SS_NOTIFY|SS_SUNKEN, CStaticDirectX::GetRect(IDC_STATIC_V1, this),this,IDC_STATIC_V11);
就不行,这说明CStaticDirectX::GetRect(IDC_STATIC_V1, this)有问题,可我又必须用IDC_STATIC_V1的Rect的呀!怎么改??CStaticDirectX::GetRect(IDC_STATIC_V1, this)哪有问题????
前一贴感谢: Saimen(单身情人) 虽没解决,但还是让我找到问题在哪了,并感谢所有up的朋友,决不失言up有分!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!