TA的每日心情 | 开心 2025-6-8 10:03 |
---|
签到天数: 58 天 [LV.5]常住居民I
管理员
- 积分
- 1605
|
2024-07-23
2024-06-29
void SNativeWnd2::OnPaint(HDC hdc){
PAINTSTRUCT ps;
hdc = BeginPaint(m_hWnd,&ps);
RECT rcWnd;
GetClientRect(&rcWnd);
HBRUSH hbr = CreateSolidBrush(RGBA(88,88,88,255));
FillRect(hdc,&rcWnd,hbr);
DeleteObject(hbr);
SetTextColor(hdc,RGBA(255,0,0,255));
LOGFONT lf={0};
lf.lfHeight = 50;
strcpy(lf.lfFaceName,"Ani");
HFONT hFont = CreateFontIndirect(&lf);
HFONT oldFont = SelectObject(hdc,hFont);
std::string str = "hello soui";
SIZE sz={0};
GetTextExtentPoint32(hdc,str.c_str(),str.length(),&sz);
HPEN pen = CreatePen(PS_SOLID,1,RGBA(0,0,255,255));
HPEN oldPen = SelectObject(hdc,pen);
HBRUSH br = CreateSolidBrush(RGBA(128,128,128,255));
HBRUSH oldBr = SelectObject(hdc,br);
Rectangle(hdc,10,10,10+sz.cx,10+sz.cy);
Rectangle(hdc,0,100,64,164);
TextOut(hdc,10,10,str.c_str(),-1);
SelectObject(hdc,oldBr);
DeleteObject(br);
SelectObject(hdc,oldPen);
DeleteObject(pen);
SelectObject(hdc,oldFont);
DeleteObject(hFont);
//draw hbitmap
HDC memdc = CreateCompatibleDC(hdc);
HBITMAP oldBmp = SelectObject(memdc,m_bmp);
RECT rc2={0,100,64,100+64};
//BitBlt(hdc,rc2.left,rc2.top,rc2.right-rc2.left,rc2.bottom-rc2.top,memdc,64,64,SRCCOPY);
BLENDFUNCTION bf;
AlphaBlend(hdc,100,100,128,128,memdc,0,0,64,64,bf);
SelectObject(memdc,oldBmp);
DeleteDC(memdc);
EndPaint(m_hWnd,&ps);
}
【筑基】sosoft 21:55:23
这是ubuntu上运行效果,代码和win32一样。
【筑基】sosoft 21:57:45
这个模块做好了,win32程序移植到linux就不难了。
|
|