在整个程序需输入内容的地方中如何根据 Insert 键的不同状态来决定输入的内容是插入还是覆盖。
delphi好像居然没有些属性设置!???

解决方案 »

  1.   

    用个全局变量来记录按下Insert键后的值。
    car flag_insert:boolean;// true 为插入,false为覆盖
    在Form的OnKeyDown事件中写
    if key=VK_Insert then
      flag_insert:= not flag_insert;
    应该不是很难吧
      

  2.   

    我的最终目的不是要记下insert键的状态,而是想在输入的时候根据当前是插入还是改写来对输入的内容进行相应的插入或改写。但delphi的标准输入框控件不支持,只有richedit才行,除非不用标准控件改用第三方控件,可是我不想重新替换这些控件,工作理太大了,所以想用代码实现就行。
      

  3.   

    难道没人懂了吗?看来Delphi还是有缺陷啊!这么简单、常用的操作都没有!唉,看来只能用别的控件了。
      

  4.   

    '程序需输入内容的地方':什么意思?????EDIT或MEMO中????
      

  5.   

    在memo中的实现
    procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
    var col,lin:integer;old,new:string;
    begin
      col:=form1.Memo1.CaretPos.X;
      lin:=form1.Memo1.CaretPos.Y;
      old:=memo1.Lines[lin];
      new:=copy(old,1,col)+key+copy(old,(col+2),(length(old)-col-1));
      memo1.Lines[lin]:=new;
      key:=#0;
      form1.Memo1.SelStart:=col;
    end;
      

  6.   

    应该是这样的  han:boolean;  全局变量var col,lin:integer;old,new:string;i,j:integer;
    begin
      if ((key in ['0'..'9']) or (ord(key)>128) or (key in ['a'..'z']) or (key in ['A'..'Z'])) then
      begin
        if ord(key)>128 then
        begin
          if not han then
            exit;
        end;
        han:=false;
        col:=form1.Memo1.CaretPos.X;
        lin:=form1.Memo1.CaretPos.Y;
        old:=memo1.Lines[lin];
        if old='' then
          exit;
        if ord(old[col+1])>128 then
          new:=copy(old,1,col)+key+copy(old,(col+3),(length(old)-col-1))
        else
          new:=copy(old,1,col)+key+copy(old,(col+2),(length(old)-col-1));
        memo1.Lines[lin]:=new;
        key:=#0;
        j:=0;
        for i:=1 to lin do
        begin
          j:=j+length(memo1.Lines[i-1]);
        end;
        form1.Memo1.SelStart:=j+col+1;
      end;
    end;
      

  7.   

    老大,如此复杂?用Api不就得了?GetKbStatus;
      

  8.   

    你在你的keypress里判断一下全局变量就行了。
    if flag=inserted then
    begin
      ……
    end
    else 
      ……
      

  9.   

    to crossbow(La Vida Es Amor) GetKbStatus  是干什么用的?我怎么找不到