我的程序的参数是正确的,却出现编译错误:“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); //错误处
} 展开
// 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); //错误处
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询