zoukankan      html  css  js  c++  java
  • 绘制不规则图片、窗体与图形

    1、Tshape控件使用后鼠标的识别区域为矩形,而内部可以绘制多种形状,如何控制其识别区域呢?

      在Form上放个Panel,使用CreatePolygonRgn()这个API,创建出一块多边形区域,然后调用SetWindowRgn(Panel1.Handle,hRgn{CreatePolygonRgn()的返回值},true);将Panel剪切成你想要的形状  

    SetWindowRgn

    The SetWindowRgn function sets the window region of a window. The window region determines the area within the window where the system permits drawing. The system does not display any portion of a window that lies outside of the window region

    int SetWindowRgn(
      HWND hWnd,     // handle to window
      HRGN hRgn,     // handle to region
      BOOL bRedraw   // window redraw option
    );

    2、Delphi制作“五星”不规则窗体的思路及代码

    http://www.hongkevip.com/bianchengzhishi/Delphi/7907.html

    3、绘制椭圆图形

    unit Unit1;
    interfaceuses  
        Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs;
    type  
        TForm1 = class(TForm)    
            procedure FormPaint(Sender: TObject);  
        end;
    var 
         Form1: TForm1;
    implementation
    {$R *.dfm}
    procedure TForm1.FormPaint(Sender: TObject);
    const  n = 50;
    var  Rgn: HRGN;  x1,y1,x2,y2: Integer;
    begin  
        x1 := n; 
        y1 := n div 2; 
        x2 := ClientWidth - n; 
        y2 := ClientHeight - n;  {建立椭圆区域}
    //  Rgn := CreateEllipticRgn(x1, y1, x2, y2);  
        Rgn := CreateEllipticRgnIndirect(Rect(x1,y1,x2,y2)); {目的同上一行, 函数不同}  {填充区域}  
        Canvas.Brush.Color := clSilver;  
        Canvas.Brush.Style := bsCross;  
        FillRgn(Canvas.Handle, Rgn, Canvas.Brush.Handle);  {绘制区域边界}  
        Canvas.Brush.Color := clRed; 
         Canvas.Brush.Style := bsSolid;  
        FrameRgn(Canvas.Handle, Rgn, Canvas.Brush.Handle, 2, 2);        
        DeleteObject(Rgn);
    end;
    end.   
  • 相关阅读:
    ETL讲解(很详细!!!)
    必须掌握的30种SQL语句优化
    亿级Web系统搭建——单机到分布式集群
    运行第一个容器
    Docker 架构详解
    容器 What, Why, How
    Docker 组件如何协作?
    部署 DevStack
    通过例子学习 Keystone
    创建 Image
  • 原文地址:https://www.cnblogs.com/zhrong/p/5709437.html
Copyright © 2011-2022 走看看