在2008VC++中TextOut使用
intx,y;charstr[20]="";x=LOWORD(lParam);//获取鼠标x坐标值y=HIWORD(lParam);//获取鼠标y坐标值SetTextCo...
int x,y;
char str[20] = "";
x = LOWORD(lParam); //获取鼠标x坐标值
y = HIWORD(lParam); //获取鼠标y坐标值
SetTextColor(hdc,RGB(255,0,0));
TextOut(hdc,10,10,"鼠标坐标",strlen("鼠标坐标"));
sprintf(str,"X坐标:&d",x);
TextOut(hdc,30,30,str,strlen(str));
sprintf(str,"Y坐标:&d",y);
TextOut(hdc,30,50,str,strlen(str));
我这样的程序怎么改呢 ? 展开
char str[20] = "";
x = LOWORD(lParam); //获取鼠标x坐标值
y = HIWORD(lParam); //获取鼠标y坐标值
SetTextColor(hdc,RGB(255,0,0));
TextOut(hdc,10,10,"鼠标坐标",strlen("鼠标坐标"));
sprintf(str,"X坐标:&d",x);
TextOut(hdc,30,30,str,strlen(str));
sprintf(str,"Y坐标:&d",y);
TextOut(hdc,30,50,str,strlen(str));
我这样的程序怎么改呢 ? 展开
2个回答
推荐于2016-10-24
展开全部
估计你的问题是字符集的问题;
VS2008默认用的是Unicode字符集,要加上_T()宏,例如
pDC->TextOut(x,y,_T("输出文字"));
或者
CString str = _T("输出文字");
pDC->TextOut(x,y,str);
这样改:
int x,y;
TCHAR str[20];
x = LOWORD(lParam); //获取鼠标x坐标值
y = HIWORD(lParam); //获取鼠标y坐标值
SetTextColor(hdc,RGB(255,0,0));
TextOut(hdc,10,10,_T("鼠标坐标"),strlen(_T("鼠标坐标")));
wsprintf(str,_T("X坐标:&d"),x);
TextOut(hdc,30,30,str,strlen(str));
wsprintf(str,_T("Y坐标:&d"),y);
TextOut(hdc,30,50,str,strlen(str));
VS2008默认用的是Unicode字符集,要加上_T()宏,例如
pDC->TextOut(x,y,_T("输出文字"));
或者
CString str = _T("输出文字");
pDC->TextOut(x,y,str);
这样改:
int x,y;
TCHAR str[20];
x = LOWORD(lParam); //获取鼠标x坐标值
y = HIWORD(lParam); //获取鼠标y坐标值
SetTextColor(hdc,RGB(255,0,0));
TextOut(hdc,10,10,_T("鼠标坐标"),strlen(_T("鼠标坐标")));
wsprintf(str,_T("X坐标:&d"),x);
TextOut(hdc,30,30,str,strlen(str));
wsprintf(str,_T("Y坐标:&d"),y);
TextOut(hdc,30,50,str,strlen(str));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询