TEdit = class(StdCtrls.TEdit)
protected
procedure WndProc(var Message: TMessage); override;
end;
procedure TEdit.WndProc(var Message: TMessage);
var
hClip: THandle;
pBuf, lBuf, gBuf: PChar;
C: Char;
begin
if Message.Msg = WM_PASTE then
begin
OpenClipboard(Handle);
if IsClipboardFormatAvailable(CF_TEXT) then
begin
hClip := GetClipboardData(CF_TEXT);
pBuf := GlobalLock(hClip);
GetMem(lBuf, Length(pBuf));
StrCopy(lBuf, pBuf);
GlobalUnlock(hClip);
EmptyClipboard; //ShowMessage(lBuf);
//改变某些字符
pBuf := lBuf;
C := pBuf^;
while C <> #0 do
begin
if C = #51 then
pBuf^ := Char(#65);
Inc(pBuf);
C := pBuf^;
end;
//end 改变某些字符
hClip := GlobalAlloc(GMEM_MOVEABLE, StrLen(lBuf) + 1);
gBuf := GlobalLock(hClip);
StrCopy(gBuf, lBuf);
FreeMem(lBuf);
GlobalUnlock(hClip);
SetClipboardData(CF_TEXT,hClip);
end;
CloseClipboard;
end;
inherited;
end;
浙公网安备 33010602011771号