<pre>
没有亲自试试,瞎说一气,请见谅,我参照其它程序做个键盘钩子程序,
试一下,可以满足你的要求,
Create New Form:Richedit1 Button1 Save as To unit1.dfm
例子如下:Save as To Unit1.pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls;
type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
BitBtn1: TBitBtn;
procedure FormShow(Sender: TObject);
procedure FormHide(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
hNextHookProc: HHook;
function
KeyboardHookHandler(iCode:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
implementation
{$R *.DFM}
function KeyboardHookHandler(iCode: Integer;
wParam: WPARAM;
lParam: LPARAM): LRESULT;
stdcall;
const
_KeyPressMask = $80000000;
var i:integer;
begin
Result := 0;
If iCode &lt;
0 then
begin
Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);
Exit;
end;
if ((lParam and _KeyPressMask) = 0)and(wParam = vk_tab) then
begin
with form1do
if RichEdit1.Focused then
begin
i:=RichEdit1.SelStart;
RichEdit1.text:=copy(RichEdit1.text,1,i)+chr(VK_TAB)+copy(RichEdit1.text,i+1,le
ngth(RichEdit1.text)-i+1);
RichEdit1.SelStart:=i+1;
end;
Result := 1;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
hNextHookProc := SetWindowsHookEx(WH_KEYBOARD,KeyboardHookHandler,HInstance,0);
end;
procedure TForm1.FormHide(Sender: TObject);
begin
UnhookWindowshookEx(hNextHookProc);
end;
end.
第二个问题照jams的做可以
</pre>