클립보드에 있는 이미지 찍기
uses clipbrd;
procedure drawFromClip;
begin
with ClipBoard do
begin
if HasFormat(CF_BITMAP) then
begin
Image1.Picture.Bitmap.Assign(ClipBoard)
end
else if HasFormat(CF_PICTURE) then Image1.Picture.Assign(ClipBoard)
else if HasFormat(CF_METAFILEPICT) then Image1.Picture.Metafile.Assign(ClipBoard);
end;
end;
클립보드에 넣기, 꺼내기
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, clipbrd;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure WMDrawClipboard(var Msg: TMessage) ; message WM_DRAWCLIPBOARD;
procedure WMChangeCBChain(var Msg: TMessage) ; message WM_CHANGECBCHAIN;
public
{ Public declarations }
end;
var
Form1: TForm1;
NextInChain : THandle;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
NextInChain := SetClipboardViewer(Handle) ;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ChangeClipboardChain(Handle, NextInChain) ;
end;
// 클립보드 내용이 바뀌면 발생하는 메세지
procedure TForm1.WMDrawClipboard(var Msg:TMessage) ;
begin
if Clipboard.HasFormat(cf_text) then
begin
Memo1.Lines.Clear;
Memo1.PasteFromClipboard;
end
else
begin
//do something with other clipboard formats
end;
//pass the message on to the next window
if NextInChain <> 0 then
SendMessage(NextInChain, WM_DrawClipboard, 0, 0)
end;
// 다른 클립보드 뷰어가 바뀐상황을 체크하고 다음 체인에게도 알려준다
procedure TForm1.WMChangeCBChain(var Msg: TMessage) ;
var
Remove, Next: THandle;
begin
Remove := Msg.WParam;
Next := Msg.LParam;
with Msg do
if NextInChain = Remove then
NextInChain := Next
else if NextInChain <> 0 then
SendMessage(NextInChain, WM_ChangeCBChain, Remove, Next)
end;
end.
클립보드 내용 바뀐거 체크
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, clipbrd;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure WMDrawClipboard(var Msg: TMessage) ; message WM_DRAWCLIPBOARD;
procedure WMChangeCBChain(var Msg: TMessage) ; message WM_CHANGECBCHAIN;
public
{ Public declarations }
end;
var
Form1: TForm1;
NextInChain : THandle;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
NextInChain := SetClipboardViewer(Handle) ;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ChangeClipboardChain(Handle, NextInChain) ;
end;
// 클립보드 내용이 바뀌면 발생하는 메세지
procedure TForm1.WMDrawClipboard(var Msg:TMessage) ;
begin
if Clipboard.HasFormat(cf_text) then
begin
Memo1.Lines.Clear;
Memo1.PasteFromClipboard;
end
else
begin
//do something with other clipboard formats
end;
//pass the message on to the next window
if NextInChain <> 0 then
SendMessage(NextInChain, WM_DrawClipboard, 0, 0)
end;
// 다른 클립보드 뷰어가 바뀐상황을 체크하고 다음 체인에게도 알려준다
procedure TForm1.WMChangeCBChain(var Msg: TMessage) ;
var
Remove, Next: THandle;
begin
Remove := Msg.WParam;
Next := Msg.LParam;
with Msg do
if NextInChain = Remove then
NextInChain := Next
else if NextInChain <> 0 then
SendMessage(NextInChain, WM_ChangeCBChain, Remove, Next)
end;
end.