⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clpbrd.htm

📁 对于学习很有帮助
💻 HTM
字号:
<!-- This document was created with HomeSite v2.5 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

<HTML>
<HEAD>
	<TITLE>UDDF - ClipBoard</TITLE>
	<META NAME="Description" CONTENT="Clipboard section of the Delphi Developers FAQ" >

</HEAD>

<BODY>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff">

<CENTER>
<IMG SRC="../images/uddf.jpg"> </CENTER>

<HR SIZE="6" COLOR="LIME">
<FONT FACE="Arial Black" SIZE=7 COLOR="#ff0000"><P ALIGN="CENTER">ClipBoard</FONT> </P>
<H1><A NAME="clpbrd0">ClipBoard Viewer</A></H1>
<I>Erik Sperling Johansen &lt;erik@info-pro.no&gt;</I><P>

Example source to implement a clipboard viewer follows.

<HR><PRE>
unit ClipboardViewer;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    FNextViewerHandle : THandle;
    procedure WMDrawClipboard (var message : TMessage); 
   message WM_DRAWCLIPBOARD;
    procedure WMChangeCBCHain (var message : TMessage); 
  message WM_CHANGECBCHAIN;
  public
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Hook the clipboard viewer chain
  // Should also check for a possible null return value, which indicates
  // that the function failed.
  FNextViewerHandle := SetClipboardViewer(Handle);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  // Remove ourselves from the clipboard viewer chain.
  ChangeClipboardChain(Handle, FNextViewerHandle);
end;

procedure TForm1.WMDrawClipboard (var message : TMessage);
begin
// Called whenever contents of the clipboard changes
  message.Result := SendMessage(WM_DRAWCLIPBOARD, FNextViewerHandle, 0, 0);
end;

procedure TForm1.WMChangeCBCHain (var message : TMessage);
begin
  // Called when there is a change in the Clipboard viewer chain.
  if message.wParam = FNextViewerHandle then begin
    // the next viewer in the chain is being removed. Update our internal var.
    FNextViewerHandle := message.lParam;
    // Return 0 to indicate message was processed
    message.Result := 0;
  end else begin
    // Pass message on to next window in chain.
    message.Result := SendMessage(FNextViewerHandle, WM_CHANGECBCHAIN,
message.wParam, message.lParam);
  end;
end;


end.
</PRE><HR>

<P><H1><A NAME="clpbrd1">Copy to Clipboard</P></A></H1>
<P><I>From: Bas ten Den &lt;btenden@dds.nl&gt;</I></P>

<P>Also these procedures can Help:</P>
<HR><PRE>procedure CopyButtonClick(Sender: TObject);
begin
   If ActiveControl is TMemo then TMemo(ActiveControl).CopyToClipboard;
   If ActiveControl is TDBMemo then TDBMemo(ActiveControl).CopyToClipboard;
   If ActiveControl is TEdit then TEdit(ActiveControl).CopyToClipboard;
   If ActiveControl is TDBedit then TDBedit(ActiveControl).CopyToClipboard;
end;

procedure PasteButtonClick(Sender: TObject);
begin
   If ActiveControl is TMemo then TMemo(ActiveControl).PasteFromClipboard;
   If ActiveControl is TDBMemo then TDBMemo(ActiveControl).PasteFromClipboard;
   If ActiveControl is TEdit then TEdit(ActiveControl).PasteFromClipboard;
   If ActiveControl is TDBedit then TDBedit(ActiveControl).PasteFromClipboard;
end;
</PRE><HR>

<HR SIZE="6" COLOR="LIME">
<FONT SIZE="2">
<a href="mailto:rdb@ktibv">Please email me</a> and tell me if you liked this page.<BR>
<SCRIPT LANGUAGE="JavaScript">
<!--
	document.write("Last modified " + document.lastModified);
// -->
</SCRIPT><P>
<TABLE BORDER=0 ALIGN="CENTER">
<TR>
	<TD>This page has been created with </TD>
	<TD> <A HREF="http://www.dexnet.com./homesite.html"><IMG SRC="../images/hs25ani.gif" WIDTH=88 HEIGHT=31 BORDER=0 ALT="HomeSite 2.5b">
</A></TD>
</TR>
</TABLE>

</FONT>


</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -