//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 windowclass 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/////////////////////////////////////////////////////////////////////////////
// CStaticDirectXCStaticDirectX::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 handlersvoid 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, CStaticDirectX::GetRect(IDC_STATIC_V1, this),(CWnd*)this);
运行结果m_mystatic创建成功了,可以看到效果,可就是OnLButtonDown、OnRButtonDown不起作用,大家帮忙看看。
#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 windowclass 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/////////////////////////////////////////////////////////////////////////////
// CStaticDirectXCStaticDirectX::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 handlersvoid 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, CStaticDirectX::GetRect(IDC_STATIC_V1, this),(CWnd*)this);
运行结果m_mystatic创建成功了,可以看到效果,可就是OnLButtonDown、OnRButtonDown不起作用,大家帮忙看看。
解决方案 »
- VC Win7 系统创建服务启动失败
- 如何在自定义类中动态创建Picture控件,并加载显示图片
- socket 服务器端如何发消息给制定客户端?
- 大家在看《Programming Windows程式开发设计指南》的时候遇到过程序调试不出的问题吗?
- 怎样取一个字符串的后3位?
- 判断是否存在 某文件, 用什么函数?包含什么头文件?? 还有 直接拷贝文件的。
- 请问:如何得到当前运行程序的系统路径?
- 如何在控制台程序中扑获键盘消息?
- 急!急!急!急!急!====谁知道哪有解lzh(lha)格式的压缩文件的控制台程序(没有图形界面)====
- 大家来解释下这现象~~~
- vc的winsock控件的麻烦,急切请教高手!
- 急! 动态链接库使用问题
已经加上了呀
m_mystatic.Create("", WS_VISIBLE|SS_NOTIFY|SS_SUNKEN, CStaticDirectX::GetRect(IDC_STATIC_V1, this),(CWnd*)this);你好象加了没有 ID 号定义?
WS_VISIBLE|SS_NOTIFY|SS_SUNKEN|SS_CENTER,
CRect(20,240,70,320),this,IDC_RUNTIME_SEL))
{
return FALSE;
}这是我动态生成时用的,可以点的
我重起一下
if (!m_VideoNo1.Create("saf", WS_VISIBLE|SS_NOTIFY|SS_SUNKEN, CStaticDirectX::GetRect(IDC_STATIC_V1, this),this,IDC_STATIC_V11))
{
return FALSE;
}
还是不行呀,点了没反应,高手快来呀!!!!!!!!