• C# 区域填充


            protected override void WndProc(ref Message m)
    {
    base.WndProc(ref m);
    switch (m.Msg)
    {
    case WinUser.WM_CREATE:
    break;
    case WinUser.WM_PAINT:
    break;
    case WinUser.WM_LBUTTONDOWN:
    POINT point;
    point.x = WinUser.LOWORD((int)m.LParam);
    point.y = WinUser.HIWORD((int)m.LParam);
    ElliRgns(this.Handle, point);
    break;
    }
    }

    /// <summary>
    /// 创建椭圆区域, 并进行填充
    /// </summary>
    /// <param name="hwnd"></param>
    /// <param name="point"></param>
    unsafe void ElliRgns(IntPtr hwnd, POINT point)
    {
    RECT rect, rectClient;
    IntPtr hrgn;
    IntPtr hBrush, hBrushOld;

    //DC
    IntPtr hdc = Win32Native.GetDC(hwnd);
    Win32Native.GetClientRect(hwnd, &rectClient);

    //点周围一块区域
    rect.left = point.x - 40;
    rect.right = point.x + 40;
    rect.top = point.y - 30;
    rect.bottom = point.y + 30;

    //创建区域
    hrgn = Win32Native.CreateEllipticRgnIndirect(&rect);

    //创建画刷
    hBrush = Win32Native.CreateSolidBrush(WinUser.RGB(0, 255, 0));
    hBrushOld = Win32Native.SelectObject(hdc, hBrush);

    //为 DC 选择画刷
    Win32Native.SelectObject(hdc, hBrush);

    //绘制区域
    Win32Native.PaintRgn(hdc, hrgn);

    //稀放资源
    hBrush = Win32Native.SelectObject(hdc, hBrushOld);
    Win32Native.DeleteObject(hBrush);
    Win32Native.DeleteObject(hrgn);
    Win32Native.DeleteDC(hdc);
    }

  • 相关阅读:
    python模块导入
    linux总结shell
    linux和shell关系
    gdb调试工具
    C语言.c和.h
    CSS cursor 属性
    html dom SetInterVal()
    css hover伪类选择器与JQuery hover()方法
    CSS 清除浮动 clear 属性
    block,inline和inline-block概念和区别
  • 原文地址:https://www.cnblogs.com/LinFx/p/2203116.html
Copyright © 2020-2023  润新知