RECT rectnew5;
SetRect(&rectnew5,330,200,480,320);
HBRUSH hbrush5;
hbrush5=CreateSolidBrush(RGB(143,188,143));
FillRect(hdc,&rectnew5,hbrush5);if (int a=DrawText(hdc,"请选择你要走的位置",18,&rectnew5,DT_VCENTER))
{
int a=GetLastError();
a=87(参数不对)
}执行失败!
a= GetLastError()得到a= 87,说是参数不对,但是我没发现参数哪里不对啊!!编译能通过! 恳求帮忙!
SetRect(&rectnew5,330,200,480,320);
HBRUSH hbrush5;
hbrush5=CreateSolidBrush(RGB(143,188,143));
FillRect(hdc,&rectnew5,hbrush5);if (int a=DrawText(hdc,"请选择你要走的位置",18,&rectnew5,DT_VCENTER))
{
int a=GetLastError();
a=87(参数不对)
}执行失败!
a= GetLastError()得到a= 87,说是参数不对,但是我没发现参数哪里不对啊!!编译能通过! 恳求帮忙!
if (a==0)
{
int a=GetLastError();
a=87(参数不对)
}
画对了,是你判断不对!
SetRect(&rectnew5,330,200,480,320);
HBRUSH hbrush5;
hbrush5=CreateSolidBrush(RGB(143,188,143));
FillRect(hdc,&rectnew5,hbrush5); if (int a=DrawText(hdc,"请选择你要走的位置",18,&rectnew5,DT_VCENTER))
{
int a=GetLastError();
a=87(参数不对) }
====================
18不正确,应该是19,应该有结束符\0
SetRect(&rectnew5,330,200,480,320);
HBRUSH hbrush5;
hbrush5=CreateSolidBrush(RGB(143,188,143));
FillRect(hdc,&rectnew5,hbrush5);
char *pText = "请选择你要走的位置",if (int a=DrawText(hdc,pText,strlen(pText),&rectnew5,DT_VCENTER))
{
int a=GetLastError();
a=87(参数不对) }
Return ValuesThe height of the text indicates success. Zero indicates failure. To get extended error information, call GetLastError.
static int times=1;
static int times2=1;
rect.left=0;
rect.top=0;
rect.right=XBW;
rect.bottom=YBW;
hdc=GetDC(hWnd);
ShowRect(hdc,&rect);
SetFocus(hWnd);
//TextOut()
char *pText = "请选择你要走的位置";
if (DrawText(hdc,"请选择你要走的位置",strlen(pText),&rectnew5,DT_VCENTER))
{
int a=GetLastError();
}
执行失败!换成textout(hdc...) 同一个hdc,执行正确! case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// hdc=GetDC(hWnd);
// TODO: Add any drawing code here...
RECT rect;
GetClientRect(hWnd, &rect);
ShowRect(hdc,&rect);
DrawIcon(hdc,138,275,g_hIconBox);
RECT rectnew5;
SetRect(&rectnew5,330,200,480,320);
HBRUSH hbrush5;
hbrush5=CreateSolidBrush(RGB(143,188,143));
FillRect(hdc,&rectnew5,hbrush5); // DrawText(hdc,"请选择棋子",19,&rectnew5,DT_VCENTER);
EndPaint(hWnd, &ps);
break;在这里面执行正确!
换成 if (DrawText(hdc,pText,strlen(pText),&rectnew5,DT_VCENTER))
int a=GetLastError();
a=87(参数不对);
HDC hDC;
PAINTSTRUCT ps;
HBITMAP hBM;
RECT rect;
HBRUSH hBrush;
char *pText = "请选择你要走的位置";case WM_LBUTTONDOWN:
hDC = GetDC(hWnd);
SetRect(&rect, 330, 200, 480, 320);
hBrush = CreateSolidBrush(RGB(143, 188, 143));
FillRect(hDC,&rect,hBrush); if (!DrawText(hDC, pText, strlen(pText), &rect, DT_VCENTER))
{
int a = GetLastError();
} break;试了下,没问题,你再试试
static int times=1;
static int times2=1;
rect.left=0;
rect.top=0;
rect.right=XBW;
rect.bottom=YBW;
hdc=GetDC(hWnd);
ShowRect(hdc,&rect);
SetFocus(hWnd); ==这里的ShowRect干啥了?有没有成功获取到rect呢?最好仔细调试一下,看看是否某个参数是异常的
忘了吗?