XP 下用GDI写的程序,图片显示,但是文本不显示,求解?????

[复制链接]
查看11 | 回复7 | 2021-1-27 06:27:17 | 显示全部楼层 |阅读模式
XP下用GDI写的程序,图片显示,但是文本不显示,求解?????
分 -->
回复

使用道具 举报

千问 | 2021-1-27 06:27:17 | 显示全部楼层
原因和解决方法
回复

使用道具 举报

千问 | 2021-1-27 06:27:17 | 显示全部楼层
仅供参考:#pragmacomment(lib,"user32")
#pragmacomment(lib,"gdi32")
#include
LRESULTCALLBACKWndProc(HWNDhWnd,UINTmessage,WPARAMwParam,LPARAMlParam){
PAINTSTRUCTps;
HDChdc;
HFONThfont,ohfont;
RECTr;
COLORREFoc;
switch(message){
caseWM_CLOSE://按Alt+F4退出
PostQuitMessage(0);
break;
caseWM_PAINT:
BeginPaint(hWnd,&ps);
hdc=ps.hdc;//thedevicecontexttodrawin
GetClientRect(hWnd,&r);//Obtainthewindow'sclientrectangle
hfont=CreateFont(200,0,0,0,0,0,0,0,0,0,0,0,0,"宋体");
ohfont=(HFONT)SelectObject(hdc,hfont);
oc=SetTextColor(hdc,0x00C080FF);
SetBkMode(hdc,TRANSPARENT);
TextOut(hdc,r.left+r.right/2-600,r.top+r.bottom/2-100,"最短画图程序",12);
SelectObject(hdc,ohfont);
SetTextColor(hdc,oc);
DeleteObject(hfont);
EndPaint(hWnd,&ps);
break;
default:
returnDefWindowProc(hWnd,message,wParam,lParam);
}
return0;
}
intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){
MSGmsg={0};
WNDCLASSwc={0};
HBRUSHhbrh;
hbrh=CreateSolidBrush(0x00000000);
wc.lpfnWndProc=WndProc;
wc.hInstance=hInstance;
wc.hbrBackground=hbrh;
wc.lpszClassName="minwindowsapp";
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
if(FAILED(RegisterClass(&wc)))return1;
if(FAILED(CreateWindow(wc.lpszClassName,
"MinimalWindowsApplication",
WS_POPUP|WS_VISIBLE,
0,
0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
0,
0,
hInstance,
NULL)))
return2;
while(GetMessage(&msg,NULL,0,0)>0){
DispatchMessage(&msg);
}
DeleteObject(hbrh);
return0;
}

回复

使用道具 举报

千问 | 2021-1-27 06:27:17 | 显示全部楼层
XP下不行
回复

使用道具 举报

千问 | 2021-1-27 06:27:17 | 显示全部楼层
在XP下
这样
oc=SetTextColor(hdc,0x00C080FF);
SetBkMode(hdc,TRANSPARENT);
TextOut(hdc,r.left+r.right/2-600,r.top+r.bottom/2-100,"最短画图程序",12);
字就和失真了差不多,难看死了

回复

使用道具 举报

千问 | 2021-1-27 06:27:17 | 显示全部楼层
改用GDI+
回复

使用道具 举报

千问 | 2021-1-27 06:27:17 | 显示全部楼层
http://www.codeproject.com/Articles/865246/Outline-Text-Part
回复

使用道具 举报

千问 | 2021-1-27 06:27:17 | 显示全部楼层
楼上不如放个大招,来个图片半透明效果,估记底下的字就显示了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行