傻问题送分喽!(20分)

  • 主题发起人 主题发起人 nuke
  • 开始时间 开始时间
N

nuke

Unregistered / Unconfirmed
GUEST, unregistred user!
1。如何在richedit里使用tab键,而不是跳到下一个控件。
2。如何在record中使用长于255的字符串
我只能type rec=record
name:string[255]
大于255就会抱错的说!
 
先回答第二个问题:
type rec =record
name :array[0..1023] of char;
//!
 
你可以在richedit wanttabs = True
即可
 
Turbo Pascal对串的要求是<=255,而Delphi使用String类型则没有该限制,
你应写成:
Name: String;
 
用KEYPRESS截住table,再加入当前光标处,不知行不行
 
<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 &amp;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>
 
请查看柳五公子, DanceAgain, Jams的答案;
如果使用String 类型, Record 的数据长度无法固定,
btw , 你的问题好多哟! 结束一些吧!
 
多人接受答案了。
 
后退
顶部