我的程序的参数是正确的,却出现编译错误:“AfxBeginThread”: 2 个重载中没有一个可以转换所有参数类型

#defineDRAW_COMMANDWM_USER+45//Calgorithm_ChessBoard_Page20Dlg对话框HANDLEh_Draw;intBoar... #define DRAW_COMMAND WM_USER+45

// Calgorithm_ChessBoard_Page20Dlg 对话框

HANDLE h_Draw;
int Board[16][16], tile;

HANDLE Calgorithm_ChessBoard_Page20Dlg::hEvent=NULL;

Calgorithm_ChessBoard_Page20Dlg::Calgorithm_ChessBoard_Page20Dlg(CWnd* pParent /*=NULL*/)
: CDialog(Calgorithm_ChessBoard_Page20Dlg::IDD, pParent),flag(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void Calgorithm_ChessBoard_Page20Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(Calgorithm_ChessBoard_Page20Dlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(DRAW_COMMAND,inDraw)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BEGIN, &Calgorithm_ChessBoard_Page20Dlg::OnBnClickedBegin)
END_MESSAGE_MAP()

void Calgorithm_ChessBoard_Page20Dlg::OnPaint()
{
CPaintDC dc(this);

if (IsIconic())
{
// 用于绘制的设备上下文

SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

// 使图标在工作区矩形中居中
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;
// 绘制图标

}
else
{
CDialog::OnPaint();

for ( int i=0; i<=16; i++ )
{
dc.MoveTo(i*WIDTH,0);
dc.LineTo(i*WIDTH,16*WIDTH);
dc.MoveTo(0,i*WIDTH);
dc.LineTo(16*WIDTH,i*WIDTH);
}
}
}

void ChessBoard(int tr,int tc,int dr,int dc,int size)
{
Sleep(1000);
if ( size == 1 ) return;
int t=tile++, s=size/2; //???

if ( dr < tr+s && dc<tc+s )
{
ChessBoard(tr,tc,dr,dc,s);
}
else
{
Board[tr+s-1][tc+s-1] = t;
AfxGetMainWnd()->PostMessageW(DRAW_COMMAND,0,0);
ChessBoard(tr,tc,tr+s-1,tc+s-1,s);
}
if ( dr<tr+s && dc>=tc+s )
{
ChessBoard(tr,tc+s,dr,dc,s);
}
else
{
Board[tr+s-1][tc+s] = t;
AfxGetMainWnd()->PostMessageW(DRAW_COMMAND,0,0);
ChessBoard(tr,tc+s,tr+s-1,tc+s,s);
}
if ( dr>=tr+s && dc<tc+s )
{
ChessBoard(tr+s, tc, dr, dc, s);
}
else
{
Board[tr+s][tc+s-1]=t;
AfxGetMainWnd()->PostMessageW(DRAW_COMMAND,0,0);
ChessBoard(tr+s,tc,tr+s,tc+s-1,s);
}
if( dr>=tr+s && dc>= tc+s )
{
ChessBoard(tr+s,tc+s,dr,dc,s);
}
else
{
Board[tr+s][tc+s]=t;
AfxGetMainWnd()->PostMessageW(DRAW_COMMAND,0,0);
ChessBoard(tr+s,tc+s,tr+s,tc+s,s);
}

}

UINT __cdecl threadFun()
{
ChessBoard(0,0,1,1,16);
}

void Calgorithm_ChessBoard_Page20Dlg::inDraw()
{
CClientDC dc(this);
for (int i=0;i<16;i++)
{
for (int j=0;j<16;j++)
{
brush.Detach();
brush.CreateSolidBrush(RGB(Board[i][j]*99%255,125,125));
dc.SelectObject(&brush);
dc.Rectangle(i*WIDTH,j*WIDTH,(1+i)*WIDTH,(1+j)*WIDTH);
}
}

}

void Calgorithm_ChessBoard_Page20Dlg::OnBnClickedBegin()
{
AfxBeginThread(threadFun,this,THREAD_PRIORITY_NORMAL,0,0,NULL); //错误处
}
展开
 我来答
Imanok
推荐于2018-04-05 · 超过28用户采纳过TA的回答
知道答主
回答量:73
采纳率:0%
帮助的人:0
展开全部
threadFun的声明不符合AfxBeginThread的需求

要按这个需求:
UINT MyControllingFunction( LPVOID pParam );

修改为这个看看:
UINT __cdecl threadFun( LPVOID pParam )
{
ChessBoard(0,0,1,1,16);
}
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式