LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    RECT rect;
    HPEN hPen, hOldPen;

    switch (message)
    {
    case WM_PAINT:
        hdc = BeginPaint(hwnd, &ps);
        GetClientRect(hwnd, &rect);
    //1.获取画笔
        //hPen=GetStockObject(BLACK_PEN);
    //2.自己新建画笔
//方法一:
        //封闭图像时,使用线宽中间作为边界,所以会比想要的大小多出来一部分(线宽大小)
        //hPen = CreatePen(PS_SOLID, 100, RGB(255,0,0));
        //对于虚线而言,若是线宽大于1则会显示实现,原来线条的样式失效
        //hPen = CreatePen(PS_DASH ,0.1, RGB(255, 0, 0));
        //hPen = CreatePen(PS_DASHDOT, 0.1, RGB(255, 0, 0));
        //hPen = CreatePen(PS_DASHDOTDOT, 0.1, RGB(255, 0, 0));
        //用于封闭图像的使用:在后面可以进行填充    边框向内压缩
        //hPen = CreatePen(PS_INSIDEFRAME, 10, RGB(255, 0, 0));


//方法二:
        LOGPEN pen[10];
        for (int i = 0; i < 10;i++)
        {
            pen[i].lopnStyle = PS_SOLID;
            pen[i].lopnWidth.x = (i + 1) * 5;
            pen[i].lopnColor = RGB(20 * i, 0, 0);
        }
        //设置多个画笔样式
        //使用createpenindorect直接取出样式使用,代码简洁明了,也更加具有可重用性
        for (int i = 0; i < 10;i++)
        {
            hPen = CreatePenIndirect(&pen[i]);

            hOldPen = SelectObject(hdc, hPen);

            Ellipse(hdc, 100+30*i, 100, 300+30*i, 200);

            DeleteObject(hPen);
        }



//         MoveToEx(hdc, rect.left, (rect.bottom-rect.top) / 2, NULL);
//         LineTo(hdc, rect.right, (rect.bottom - rect.top) / 2);


        //只能删除自己定义的对象,系统带有的不允许删除
        //DeleteObject(hPen);
        SelectObject(hdc, hOldPen);

        EndPaint(hwnd, &ps);

        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }


    return DefWindowProc(hwnd, message, wParam, lParam);
}