⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fununit.pas

📁 delphi窗体设计不规则的窗体。个性化软件可能会用到的。
💻 PAS
字号:
unit fununit;

interface
uses Windows,SysUtils,Graphics;

var
  username,password:string;
  login:boolean;
  reguser:boolean;
  key:string;

//function  createregion(wmask:   tbitmap;   wcolor:   tcolor;   hcontrol:   thandle):   hrgn;
procedure CreatRgnForm( Bmap: TBitMap; WColor: TColor; hand:THandle);

implementation

procedure CreatRgnForm( Bmap: TBitMap; WColor: TColor; hand:THandle);
var
 rgn: HRgn; 
 dc, cdc: HDC; 
 x, y: integer; 
 p: Tpoint; 
 line: boolean; 
 color: Tcolor; 
begin 
 dc := GetWindowDc(hand); 
 cdc := CreateCompatibleDc( dc ); 
 SelectObject( cdc, Bmap.Handle ); 
 //WColor := Img.Picture.Bitmap.Canvas.Pixels[0, 0]; 
 //WColor := GetPixel( cdc, 0, 0 ); 
 BeginPath( dc ); 
 for x := 0 to Bmap.Width - 1 do 
 begin 
   line := false; 
   for y := 0 to Bmap.Height - 1 do 
   begin 
     color := GetPixel( cdc, x, y ); 
     if not( color=WColor) then 
     begin 
       if not line then 
       begin 
         line := true; 
         p.X := x; 
         p.Y := y; 
       end; 
     end; 

     if ( color=WColor)or( y=Bmap.Height - 1 ) then 
     begin 
       if line then 
       begin 
         line := false; 
         MoveToEx( dc, p.X, p.Y, nil ); 
         LineTo(dc, p.X, y ); 
         LineTo(dc, p.X + 1, y ); 
         LineTo(dc, p.X + 1, p.Y ); 
         CloseFigure( dc ); 
       end; 
     end; 
   end; 
 end; 
 EndPath( dc ); 
 Rgn := PathToRegion( dc ); 
 ReleaseDc( hand, dc ); 
 SetWindowRgn( hand , rgn, true ); 
end;
(*
function  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);   
  {启动一个路径分支。
  在这个命令后执行的gdi绘图命令会自动成为路径的一部分。   
  对线段的连接会结合到一起。并且设备场景中任何现成的路径都会被清除。}
  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;   {其实这个x是不用的,因为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);   {上面三个lineto()语句就是画一个2×y的矩形。   
  一定要这样才可以画上每个点!并且连在一起的如果你查查win32   sdk手册你还可以用rectangle(dc,   coord.x,   coord.y,   x   +   2,   y)等其他的画图函数代替从movetoex()开始的四个语句!也是一样的,只要记住要把点画完而且要重叠地画才可以把路径连在一起!}   
                  closefigure(dc);   {描绘到一个路径时,关闭当前打开的图形。万重大侠说不可以少,我不理解,但是多了不错。}   
              end;   
          end;
      end;
  end;
  endpath(dc);   {结束画路径}
  rgn   :=   pathtoregion(dc);   {连接路径为区域的函数。}
  releasedc(hcontrol,   dc);   {释放资源,公式化的必须使用。}
  result   :=   rgn;
end;
*)

end.
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -