初学“不规则窗口的实现”中出现的问题 出现这种问题怎样解决呀?error C2509: 'OnNcHitTest' : member function not declared in 'CRound1Dlg' 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 估计是你的OnNcHitTest函数的返回值有问题,一般是返回基类的处理:CDialog::OnNcHitTest(...); 以下是所有代码,大虾们帮我看看到底应该怎样解决 。 马上散分!// round1Dlg.cpp : implementation file//#include "stdafx.h"#include "round1.h"#include "round1Dlg.h"#include <winuser.h>#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog{public: CAboutDlg();// Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL// Implementationprotected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD){ //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT}void CAboutDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CRound1Dlg dialogCRound1Dlg::CRound1Dlg(CWnd* pParent /*=NULL*/) : CDialog(CRound1Dlg::IDD, pParent){ //{{AFX_DATA_INIT(CRound1Dlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);}void CRound1Dlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CRound1Dlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CRound1Dlg, CDialog) //{{AFX_MSG_MAP(CRound1Dlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CRound1Dlg message handlersBOOL CRound1Dlg::OnInitDialog(){ CDialog::OnInitDialog(); CRect rcDialog; GetClientRect(&rcDialog); CRgn rgn; rgn.CreateEllipticRgn(0,0,rcDialog.Width(),rcDialog.Height()); SetWindowRgn((HRGN)rgn,TRUE); return TRUE;}void CRound1Dlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CPaintDC dc(this); dc.SelectStockObject(NULL_PEN); CRect rect; GetClientRect(rect); CBrush brush; CBrush *PBrushOld; brush.CreateSolidBrush(RGB(0,0,255)); PBrushOld=dc.SelectObject(&brush); dc.Ellipse(rect); dc.SelectObject(PBrushOld); }}// The system calls this to obtain the cursor to display while the user drags// the minimized window.HCURSOR CRound1Dlg::OnQueryDragIcon(){ return (HCURSOR) m_hIcon;}UINT CRound1Dlg::OnNcHitTest(CPoint point) { UNIT nHitTest=CDialog::OnNcHitTest(Point); return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;} UINT CRound1Dlg::OnNcHitTest(CPoint point) { UNIT nHitTest=CDialog::OnNcHitTest(Point); return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;}这个函数的声明在.h文件里有吧!你是怎么加这个函数的,应该用类向导 改正楼主几个错误:1. protected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG afx_msg UINT OnNcHitTest( CPoint point );//在这个地方加入消息declare(头文件中) DECLARE_MESSAGE_MAP()2.BEGIN_MESSAGE_MAP(CRound1Dlg, CDialog) //{{AFX_MSG_MAP(CRound1Dlg) ON_WM_NCHITTEST()//在这里加入消息映射。 //}}AFX_MSG_MAP END_MESSAGE_MAP()3.UINT CRound1Dlg::OnNcHitTest(CPoint point){ /*UNIT nHitTest=CDialog::OnNcHitTest(Point);//这句有误,楼主可加上上面后测试*/ UINT nHitTest=CDialog::OnNcHitTest(point);//正确的。 return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;} 十分感谢erzichang的细心帮助,我已经把您指正的3处错误改正了,可是错误提示还是没有改变:error C2509: 'OnNcHitTest' : member function not declared in 'CRound1Dlg'round1.exe - 1 error(s), 0 warning(s) 请(高手)帮忙看看该位图数据该如何还原成图像数据并显示? 利用CFile类,打开文件怎样查找几个文字并替换成别的文字? (急切求助)如何在VC++中嵌入汇编指令关闭和重启电脑(在线等) 多天未解决的连接串 VC下在基于对话框的程序中点击按钮出现确认对话框,怎样编程确认响应? 调用别人的库出现的问题. shell扩展com(IContextMenu的com)怎么调试? 一个关于串行通讯 可能简单的问题,解决者加分 救急!!! CListCtrl如何排序??? 谁能帮我这段managed c++的代码改写成基于mfc的啊? 关于使用多网卡机器的问题
CDialog::OnNcHitTest(...);
//#include "stdafx.h"
#include "round1.h"
#include "round1Dlg.h"
#include <winuser.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
{
public:
CAboutDlg();// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CRound1Dlg dialogCRound1Dlg::CRound1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CRound1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRound1Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}void CRound1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRound1Dlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CRound1Dlg, CDialog)
//{{AFX_MSG_MAP(CRound1Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CRound1Dlg message handlersBOOL CRound1Dlg::OnInitDialog()
{
CDialog::OnInitDialog(); CRect rcDialog;
GetClientRect(&rcDialog);
CRgn rgn;
rgn.CreateEllipticRgn(0,0,rcDialog.Width(),rcDialog.Height());
SetWindowRgn((HRGN)rgn,TRUE);
return TRUE;
}
void CRound1Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
dc.SelectStockObject(NULL_PEN);
CRect rect;
GetClientRect(rect);
CBrush brush;
CBrush *PBrushOld;
brush.CreateSolidBrush(RGB(0,0,255));
PBrushOld=dc.SelectObject(&brush);
dc.Ellipse(rect);
dc.SelectObject(PBrushOld);
}
}// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CRound1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
UINT CRound1Dlg::OnNcHitTest(CPoint point)
{
UNIT nHitTest=CDialog::OnNcHitTest(Point);
return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;
}
{
UNIT nHitTest=CDialog::OnNcHitTest(Point);
return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;
}这个函数的声明在.h文件里有吧!你是怎么加这个函数的,应该用类向导
1. protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
afx_msg UINT OnNcHitTest( CPoint point );//在这个地方加入消息declare(头文件中)
DECLARE_MESSAGE_MAP()
2.BEGIN_MESSAGE_MAP(CRound1Dlg, CDialog)
//{{AFX_MSG_MAP(CRound1Dlg)
ON_WM_NCHITTEST()//在这里加入消息映射。
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
3.
UINT CRound1Dlg::OnNcHitTest(CPoint point)
{
/*UNIT nHitTest=CDialog::OnNcHitTest(Point);//这句有误,楼主可加上上面后测试*/
UINT nHitTest=CDialog::OnNcHitTest(point);//正确的。
return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;
}
round1.exe - 1 error(s), 0 warning(s)