zoukankan      html  css  js  c++  java
  • win32-封装BeginPaint

    Graphics* StartPaint(HWND win, HDC* hdc, PAINTSTRUCT* ps)
    {
        *hdc = BeginPaint(win, ps);
        return new Graphics(*hdc);
    }
    
    
     case WM_PAINT:
            {
                HDC hdc;
                PAINTSTRUCT ps;
                Graphics* g = StartPaint(hWnd, &hdc, &ps);           
                SolidBrush solidBrush(Color(255, 255, 0, 0));           
                Point point1 = Point(0, 0);
                Point point2 = Point(0, 10);
                Point point3 = Point(10, 10);
                Point point4 = Point(10, 0);
                Point points[4] = {point1,point2,point3,point4};
                g->FillPolygon(&solidBrush, points, 4);
                delete g;
                EndPaint(hWnd, &ps);
            }
            break;

    更好的方法:

    std::unique_ptr<Graphics> StartPaint(    ...) 
    { 
        ... 
        return std::make_unique<Graphics>(*hdc); 
    }
    
    auto g = StartPaint(...);
  • 相关阅读:
    GDOI模拟赛Round 1
    Codeforces 241B
    Codeforces 325E
    Codeforces 235E
    Codeforces 293B
    Codeforces 263E
    快速傅里叶变换FFT
    后缀自动机
    NOI2011 Day2
    NOI2014 Day2
  • 原文地址:https://www.cnblogs.com/strive-sun/p/12849101.html
Copyright © 2011-2022 走看看