桌面精灵

作者在 2010-01-25 17:28:01 发布以下内容
unit MainUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, Menus, JPEG;

type
  TMainForm = class(TForm)
    Timer1: TTimer;
    PopupMenu1: TPopupMenu;
    N11: TMenuItem;
    N21: TMenuItem;
    N1: TMenuItem;
    N2: TMenuItem;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure N11Click(Sender: TObject);
    procedure N21Click(Sender: TObject);
  private
    { Private declarations }
  public
    procedure HideBG(var Message: TWMEraseBkgnd);Message WM_ERASEBKGND;
    { Public declarations }
  end;

var
  MainForm: TMainForm;
  AppPath: String;
implementation

{$R *.DFM}
procedure TMainForm.HideBG;
begin
  brush.Style:= bsClear;
  Inherited;
end;

procedure TMainForm.FormCreate(Sender: TObject);
var
  Setting: LongInt;
begin
  if BorderStyle= bsNone then Exit;
  Setting:= GetWindowLong(Handle, gwl_style);
  if (Setting and ws_Caption)= ws_Caption then
    begin
      case BorderStyle of
        bsSingle,
        bsSizeable: SetWindowLong(Handle, gwl_Style, Setting and (Not(ws_Caption))or ws_border);
        bsDialog: SetWindowLong(Handle, gwl_Style, Setting and (Not(ws_Caption))or ds_modalframe or ws_dlgframe);
      end;
    end;
   Height:= Height- getSystemMetrics(sm_cyCaption);
   Refresh;
end;

procedure TMainForm.Timer1Timer(Sender: TObject);
begin
  if MainForm.Top>= Screen.Height then
    MainForm.Top:= 0
  else
    MainForm.Top:= MainForm.Top+ 1;
end;

procedure TMainForm.N2Click(Sender: TObject);
begin
  Close;
end;

procedure TMainForm.FormShow(Sender: TObject);
begin
  AppPath:= ExtractFilePath(ParamStr(0));
  Image1.Picture.LoadFromFile(AppPath+ '1.jpg');
  MainForm.Width:= Image1.Picture.Width;
  MainForm.Height:= Image1.Picture.Height;
  MainForm.Top:= 0;
end;

procedure TMainForm.N11Click(Sender: TObject);
begin
  Image1.Picture.LoadFromFile(AppPath+ '1.jpg');
  MainForm.Width:= Image1.Picture.Width;
  MainForm.Height:= Image1.Picture.Height;
end;

procedure TMainForm.N21Click(Sender: TObject);
begin
  Image1.Picture.LoadFromFile(AppPath+ '2.jpg');
  MainForm.Width:= Image1.Picture.Width;
  MainForm.Height:= Image1.Picture.Height;
end;

end.

编程点滴 | 阅读 1490 次
文章评论,共0条
游客请输入验证码
浏览2354390次