15,979
社区成员
发帖
与我相关
我的任务
分享
int SMainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: 在此添加您专用的创建代码
SetWindowText(_T("蓝调分享小平台"));
CRect cClientRect;
GetClientRect(&cClientRect);
cClientRect.right = 800;
cClientRect.bottom = 500;
MoveWindow(&cClientRect);
CenterWindow(GetParent());
// 将主窗口变为圆角窗口
CRgn hRgnClient;
hRgnClient.CreateRoundRectRgn(0,0,800,500,5,5);
CRgn hRgnButton;
hRgnButton.CreateRoundRectRgn(19,0,120+1,40+1,3,3);
hRgnClient.CombineRgn(&hRgnButton,&hRgnClient,RGN_OR);
SetWindowRgn(hRgnClient,FALSE);
return 0;
}
void SMainWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
//dc.CreateCompatibleDC()
dc.SelectStockObject(NULL_PEN);
Graphics graphics(dc.m_hDC);
Image image(L"background.bmp");
Image iguan(L"1.png");
RectF rect(0,iguan.GetHeight(),image.GetWidth(),image.GetHeight());
RectF guanRect(0,0,iguan.GetWidth(),iguan.GetHeight());
graphics.DrawImage(&image,rect,0,0,image.GetWidth(),image.GetHeight(),UnitPixel);
graphics.DrawImage(&iguan,guanRect,0,0,iguan.GetWidth(),iguan.GetHeight(),UnitPixel);
//UpdateWindow();
// 不为绘图消息调用 CWnd::OnPaint()
}