隨筆 - 6  文章 - 129  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 827222
          • 排名 - 49

          最新評論

          閱讀排行榜

          評論排行榜

          unit Unit1;

          interface

          uses
            Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
            Dialogs, ImgList, Menus, ExtCtrls, BmpRgn,  StdCtrls, IniFiles,
            Buttons;

          type
            TForm1 = class(TForm)
              img1: TImage;
              bvl1: TBevel;
              lbl1: TLabel;
              procedure FormCreate(Sender: TObject);
            private
              { Private declarations }
              procedure WMEraseBkGnd( Var Msg: TWMEraseBkGnd ); message WM_ERASEBKGND;
              procedure WMNCHitTest( Var msg: TWMNCHitTest ); message WM_NCHITTEST;
            public
              { Public declarations }
              procedure SetTheRegion;
              procedure AppException(Sender: TObject; E: Exception);
            end;

          var
            Form1: TForm1;

          implementation

          {$R *.dfm}
          // This routine takes care of drawing the bitmap on the form.
          procedure TForm1.WMEraseBkGnd(var Msg: TWMEraseBkGnd);
          var
            Brush: TBrush;
          begin
            Brush := TBrush.Create;
            Brush.Color := Color;
            FillRect( Msg.DC, ClientRect, Brush.Handle);
            Brush.Free;
            with img1.Picture.Bitmap do
              BitBlt( Msg.DC, 0, 0, Width, Height, Canvas.Handle, 0, 0, SRCCOPY);
            Msg.Result := 1;
          end;

          // This routine takes care of letting the user move the form
          // around on the desktop.
          procedure TForm1.WMNCHitTest( var msg: TWMNCHitTest );
          var
            i: integer;
            p: TPoint;
            AControl: TControl;
            MouseOnControl: boolean;
          begin
            inherited;
            if msg.result = HTCLIENT then begin
              p.x := msg.XPos;
              p.y := msg.YPos;
              p := ScreenToClient( p);
              MouseOnControl := false;
              for i := 0 to ControlCount-1 do begin
                if not MouseOnControl
                then begin
                  AControl := Controls[i];
                  if ((AControl is TWinControl) or (AControl is TGraphicControl))
                    and (AControl.Visible) then
                  begin
                       MouseOnControl := PtInRect( AControl.BoundsRect, p);
                  end;
                end
                else
                  break;
              end;
              if (not MouseOnControl) then
                msg.Result := HTCAPTION;
            end;
          end;

          procedure TForm1.SetTheRegion;
          var
            HR: HRGN;
          begin
            HR := BmpToRegion( Self, img1.Picture.Bitmap);
            SetWindowRgn( handle, HR, true);
            Invalidate;
          end;

          procedure TForm1.FormCreate(Sender: TObject);
          begin
              Application.OnException := AppException;
              SetTheRegion;
          end;

          procedure TForm1.AppException(Sender: TObject; E: Exception);
          begin
            Application.ProcessMessages;
            Application.ShowException(E);
            Application.Terminate;
          end;

          end.
          注意:
          (1) img1: TImage;的Visible屬性必須設(shè)置為false

          (2) BmpRgn 為外部dcu文件,需要導(dǎo)入




          posted on 2010-02-22 11:48 Ke 閱讀(388) 評論(0)  編輯  收藏 所屬分類: delphi
          主站蜘蛛池模板: 大英县| 梧州市| 德惠市| 新乡县| 同江市| 玉溪市| 巫山县| 贺兰县| 大冶市| 平武县| 汉中市| 鸡东县| 虹口区| 婺源县| 宜章县| 西昌市| 深水埗区| 天津市| 阿鲁科尔沁旗| 巫溪县| 南江县| 枣阳市| 康平县| 铜陵市| 兴化市| 武乡县| 高雄市| 会理县| 萝北县| 阿拉尔市| 赫章县| 通化市| 托里县| 娄底市| 东乌| 中阳县| 潮州市| 仲巴县| 嘉荫县| 都昌县| 贡嘎县|