相框

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

interface

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

type
  TMainForm = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
  private
    procedure WMNCPaint(var Msg: TWMNCPaint); message WM_NCPAINT;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.DFM}
procedure TMainForm.WMNCPaint(var Msg: TWMNCPaint);
var
  DC: hDC;
  Pen: hPen;
  OldPen: hPen;
  OldBrush: hBrush;
begin
  inherited;   //获取窗口文本上下文
  DC:= GetWindowDC(Handle);
  Msg.Result:= 1;
  Pen:= CreatePen(PS_SOLID, 3, RGB(225, 1, 1));   //创建宽度为3的实现画笔
  OldPen:= SelectObject(DC, Pen);   //将新创建的画笔选入窗体的设备上下文
  OldBrush:= SelectObject(DC, GetStockObject(NULL_BRUSH));   //将系统库存的空画刷选入窗体的设备上下文
  Rectangle(DC, 0, 0, MainForm.Width, MainForm.Height);   //绘制镜框
  SelectObject(DC, OldBrush);
  SelectObject(DC, OldPen);
  DeleteObject(Pen);   //删除画笔
  ReleaseDC(Handle, Canvas.Handle);   //释放设备上下文

end;

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

end.

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