cpclip.pas

来自「生物信息学中的遗传数据分析的delphi源码。」· PAS 代码 · 共 54 行

PAS
54
字号
{*******************************************************************
*                                                                  *
*  COMPONENT for MS DOS and Windows source code.                   *
*                                                                  *
*  (c) 1992, Roderic D. M. Page                                    *
*                                                                  *
*  Language: Turbo Pascal (Pascal with object-oriented extensions) *
*  Compiler: Turbo Pascal 6.0 (MS DOS)                             *
*            Turbo Pascal for Windows 1.0 (WINDOWS)                *
*                                                                  *
*  Notes:    Program interface is currently Windows specific.      *
*                                                                  *
*******************************************************************}

{* Basic clipboard operations *}

{* Written 16 Oct 1992 *}

unit cpclip;

interface

uses
	WinTypes,
	WinProcs,
	Strings;

function CopyTextToClipboard (TextString: PChar):Boolean;

implementation

{ Copy TextString to Windows Clipboard }
function CopyTextToClipboard (TextString: PChar):Boolean;
var
	StringGlobalHandle : TGlobalHandle;
	StringGlobalPtr	 : PChar;
begin
	CopyTextToClipboard := False;
	StringGlobalHandle  := GlobalAlloc (gHnd, Strlen (TextString) + 1);
	if (StringGlobalHandle <> 0) then begin
		StringGlobalPtr := GlobalLock (StringGlobalHandle);
		if (StringGlobalPtr <> NIL) then begin
			StrCopy (StringGlobalPtr, TextString);
			GlobalUnlock (StringGlobalHandle);
			SetClipboardData (cf_Text, StringGlobalHandle);
			CopyTextToClipboard := True;
			end
		else GlobalFree (StringGlobalHandle);
		end
	else GlobalFree (StringGlobalHandle);
end;

begin
end.

⌨️ 快捷键说明

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