人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

根據位圖做出漂亮的不規則FORM

根據位圖做出漂亮的不規則FORM

更新時間:2022-09-30 文章作者:未知 信息來源:網絡 閱讀次數:

unit Unit1;  

interface  

uses  
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  
  ExtCtrls, StdCtrls, Buttons;  

type  
  TForm1 = class(TForm)  
    Image1: TImage;  
    Button1: TButton;  
    procedure FormCreate(Sender: TObject);  
    procedure Button1Click(Sender: TObject);  
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;  
      Shift: TShiftState; X, Y: Integer);  
  private  
    function CreateRegion(wMask: TBitmap; wColor: TColor;  
      hControl: THandle): HRGN;  
    { Private declarations }  
  public  
    { Public declarations }  
  end;  

var  
  Form1: TForm1;  

implementation  

{$R *.DFM}  

function Tform1.CreateRegion(wMask:TBitmap;wColor:TColor;hControl:THandle): HRGN;  
var  
  dc, dc_c: HDC;  
  rgn: HRGN;  
  x, y: integer;  
  coord: TPoint;  
  line: boolean;  
  color: TColor;  
begin  
  dc := GetWindowDC(hControl);  
  dc_c := CreateCompatibleDC(dc);  
  SelectObject(dc_c, wMask.Handle);  
  BeginPath(dc);  
  for x:=0 to wMask.Width-1 do  
  begin  
    line := false;  
    for y:=0 to wMask.Height-1 do  
    begin  
      color := GetPixel(dc_c, x, y);  
      if not (color = wColor) then  
      begin  
        if not line then  
        begin  
          line := true;  
          coord.x := x;  
          coord.y := y;  
        end;  
      end;  
      if (color = wColor) or (y=wMask.Height-1) then  
      begin  
        if line then  
        begin  
          line := false;  
          MoveToEx(dc, coord.x, coord.y, nil);  
          LineTo(dc, coord.x, y);  
          LineTo(dc, coord.x + 1, y);  
          LineTo(dc, coord.x + 1, coord.y);  
          CloseFigure(dc);  
        end;  
      end;  
    end;  
  end;  
  EndPath(dc);  
  rgn := PathToRegion(dc);  
  ReleaseDC(hControl, dc);  
  Result := rgn;  
end;  

procedure TForm1.FormCreate(Sender: TObject);  
var  
  w1:TBitmap;  
  w2:TColor;  
  rgn: HRGN;  
begin  
  w1:=TBitmap.Create;  
  w1.Assign(image1.Picture.Bitmap);  
  w2:=w1.Canvas.Pixels[0,0];  
  rgn := CreateRegion(w1,w2,Handle);  
  if rgn<>0 then  
  begin  
     SetWindowRgn(Handle, rgn, true);  
  end;  
  w1.Free;  
end;  

procedure TForm1.Button1Click(Sender: TObject);  
begin  
  Close;  
end;  

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;  
  Shift: TShiftState; X, Y: Integer);  
begin  
  ReleaseCapture;  
  SendMessage(Handle, WM_SYSCOMMAND, $F012, 0);  
end;  

end.

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 大关县| 龙井市| 台湾省| 和平区| 辽宁省| 赣榆县| 澄江县| 黄山市| 云林县| 宜兰市| 景洪市| 克山县| 黑水县| 浮梁县| 海盐县| 石柱| 隆化县| 绥江县| 虹口区| 新田县| 郎溪县| 鸡东县| 临清市| 平泉县| 绥德县| 贵溪市| 九江市| 金堂县| 奉新县| 通化市| 五河县| 望谟县| 青田县| 桐乡市| 城固县| 文安县| 孝义市| 塘沽区| 乌鲁木齐市| 吴旗县| 东丽区|