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

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 827295
          • 排名 - 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屬性必須設置為false

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




          posted on 2010-02-22 11:48 Ke 閱讀(389) 評論(0)  編輯  收藏 所屬分類: delphi
          主站蜘蛛池模板: 华宁县| 白水县| 阿瓦提县| 梁河县| 彰武县| 铜川市| 寻乌县| 渝北区| 修水县| 新安县| 翁源县| 安龙县| 浙江省| 张家港市| 辉县市| 南充市| 遂溪县| 雷州市| 甘南县| 开鲁县| 山丹县| 郯城县| 芜湖县| 石嘴山市| 贞丰县| 洛阳市| 延边| 广饶县| 娄烦县| 三穗县| 彩票| 左贡县| 灌云县| 高州市| 色达县| 桦甸市| 高唐县| 平果县| 仙桃市| 会宁县| 同仁县|