设置frmBKHKML窗口的Keypreview:=True

解决方案 »

  1.   

    在OnKeyDown事件里用你的代码实现!
      

  2.   

    SpinEdit的keyPress不会响应Enter键;
      

  3.   

    看看spinedit控件的代码吧!
    function TSpinEdit.IsValidChar(Key: Char): Boolean;
    begin
      Result := (Key in [DecimalSeparator, '+', '-', '0'..'9']) or
        ((Key < #32) and (Key <> Chr(VK_RETURN)));
      if not FEditorEnabled and Result and ((Key >= #32) or
          (Key = Char(VK_BACK)) or (Key = Char(VK_DELETE))) then
        Result := False;
    end;
      

  4.   

    设置form1.keypreview ;= True; 好象不行
    在OnKeyDown事件中key的类型为word,该如何将char转换为word! 
      

  5.   

    先谢谢大家了。在keydown中我实现了TAB功能,但是系统会beep,如何将声音去掉,能不能重载TSpinEdit.IsValidChar函数。
    procedure TfrmBKHKML.spinYearKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
       if (key=13) then
      begin
       key:=0;
       perform(CM_Dialogkey,VK_TAB,0);
      end;
    end;
      

  6.   

    其实,你把
    function TSpinEdit.IsValidChar(Key: Char): Boolean;
    begin
      Result := (Key in [DecimalSeparator, '+', '-', '0'..'9']) or
        ((Key < #32) and (Key <> Chr(VK_RETURN)));//改为 key = Chr(VK_RETURN) 即可响应onkeypress,系统也不会beep
      if not FEditorEnabled and Result and ((Key >= #32) or
          (Key = Char(VK_BACK)) or (Key = Char(VK_DELETE))) then
        Result := False;
    end; 
      

  7.   

    ChocoboY(陆行鸟)大侠,我应该在哪改,我不知从哪找到你上面的那段代码,再帮个忙。
      

  8.   

    ChocoboY(陆行鸟)大侠,function TSpinEdit.IsValidChar(Key: Char): Boolean;
    请问应在什么地方声明。
      

  9.   

    在Source\Samples\spin.pas, Line: 444;