在vs。net2003中 利用gid+ 绘制文字 现在需要在指定的矩形框的中心显示文字,程序如下: Font myFont(L"Arial", 20);
SolidBrush myBrush1(fcolor); StringFormat *sFmat=new StringFormat( )
sFmat->SetLineAlignment(StringAlignmentCenter);
sFmat->SetAlignment(StringAlignmentCenter);
RectF testRect(x1,y1,200,50);
string aa="测试";
gDC->DrawRectangle(myPen,testRect);
gDC->DrawString( ToWChar(aa.c_str()) , 11, &myFont, testRect, sFmat,&myBrush1);但是效果没有达到预期,显示一直靠左,请教为什么,谢谢
SolidBrush myBrush1(fcolor); StringFormat *sFmat=new StringFormat( )
sFmat->SetLineAlignment(StringAlignmentCenter);
sFmat->SetAlignment(StringAlignmentCenter);
RectF testRect(x1,y1,200,50);
string aa="测试";
gDC->DrawRectangle(myPen,testRect);
gDC->DrawString( ToWChar(aa.c_str()) , 11, &myFont, testRect, sFmat,&myBrush1);但是效果没有达到预期,显示一直靠左,请教为什么,谢谢
对应TitleRect进行裁剪
gDC->DrawString( ToWChar(aa.c_str()) , 11, &myFont, testRect, sFmat,&myBrush1); 这个11是什么意思,应该是字符串的长度啊,以这个字符串来看,应该是2,或者写成wcsstr(ToWChar(aa.c_str()) )