捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  沪ICP备05001939号 DELPHI盒子 | 盒子论坛 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 论坛检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
盒子资源分类
全部展开 - 全部合拢
根据位图做出漂亮的不规则FORM
关键字:BMP 位图 不规则 界面 FORM
来 自:原创
平 台:Win9x,Win2k/NT 下载所需:0 火柴
深浅度:初级 完成时间:2001/3/1
发布者:mantousoft 发布时间:2003/8/30
编辑器:DELPHI5 语  种:简体中文
分 类:窗体 下载浏览:2117/19650
加入到我的收藏
下载错误报错
登陆以后才能下载
 用户名:
 密 码:
自动登陆(30天有效)
图片如果打不开,说明流量不够了,请稍候下载……
  2000年看到一篇文章做的演示代码,可以根据位图做出漂亮的不规则FORM,大家可以下载演示程序研究一下,包含DELPHI版和VC版。

// 
//   -'`"_     -'`" \ 
//   /   \    /   " 
//  /   /\\__  / ___  \ 
//  |   | \ -"`.-(  \  | 
//  |   | |   | \" | | 
//  |   / / "-" \ \  | 
//  \___/ / (o o) \ (__/ 
//     __| _   _ |__ 
//    (   ( )   ) 
//     \_\.-.___.-./_/ 
//      __ | | __    
//     | \.| |./ | 
//     | '#.  .#' | 
//     |__/ '"" \__| 
//    -/       \- 
// 

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. 

文章作者:mantousoft
文章来源:2ccc.com
作者邮箱:root@2ccc.com
Google
 
本站原创作品,未经作者许可,严禁任何方式转载;转载作品,如果侵犯了您的权益,请联系我们
龙脉加密锁 15元起 Grid++Report 报表 申请支付@网
 相关文章
没有相关文章
相关评论
共有评论6条 当前显示最后6条评论
hjma 2004/2/6 15:31:34
应该加入位图随时间变化而变化的例子,嘿嘿嘿!
chen_cch 2004/3/1 16:54:39
dc_c := CreateCompatibleDC(dc);资源没有释放。
spritesong 2004/4/18 23:16:30
学习中,呵呵!感谢!
xjsd12 2004/8/2 15:02:56
图片大了效果就不好了
andylist 2004/11/29 13:32:10
实用程度好像不是很大!!
69505678 2007/4/10 15:59:59
其实也不用这么费事。
1、将Form1的“TransparentColor”属性设为“True”。
2、将Form1的“TransparentColorValue”属性设为和图片背景相同的颜色,如“clBlue”就可以了。
至于“andylist”所说的实用程度,其实我想可以利用这来画出自己程序的界面,而不是千篇一律的Windows界面。
我要发表评论 查看全部评论
 
  DELPHI盒子版权所有 1999-2023 V4.01 粤ICP备10103342号-1 更新RSS列表