2009-10-28 2 views
2

내 응용 프로그램의 한 형태에서 양식에 프레임을 추가하여 데이터 집합을 추가합니다. 각 프레임마다 Enter 키를 눌러 한 편집 (Dev Express 편집자) 제어에서 다음 편집으로 이동할 수 있기를 원합니다. 지금까지 컨트롤의 KeyPress 및 KeyUp 이벤트에서 네 가지 메서드를 시도했습니다.프레임 안의 다음 컨트롤로 이동하는 방법?

  1. SelectNext(TcxCurrencyEdit(Sender), True, True); // also base types attempted

  2. SelectNext(Sender as TWinControl, True, True);

  3. Perform(WM_NEXTDLGCTL, 0, 0);

  4. 이러한 방법

중에

  • f := TForm(self.Parent); // f is TForm or my form c := f.FindNextControl(f.ActiveControl, true, true, false); // c is TWinControl or TcxCurrencyEdit if assigned(c) then c.SetFocus;

  • 작동되지 델파이 5에서이 작업을 수행하는 데 도움이 될 수 있습니까? 감사.

    답변

    3

    님의

    설정 양식의 KeyPreview 속성 참된.

    procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char); 
    begin 
        If (Key = #13) then 
        Begin 
        SelectNext(ActiveControl as TWinControl, True, True); 
        Key := #0; 
        End; 
    end; 
    
    +0

    수준을 형성하도록 해주 때 작동하지만, 나는 그것이 프레임의 제한된 상호 작용 기능과 관련이 추측에는 요 이유는 확실하지. 고마워. 고마워. –

    3

    사용자가 Enter 키를 누른 다음 VK_TAB 키를 누르면 이전 프로젝트 하나가 CM_DIALOGKEY이라는 메시지를 발견했습니다. 그것은 다양한 컨트롤의 숫자와 함께 작동합니다.

    interface 
    ... 
        procedure CMDialogKey(var Message: TCMDialogKey);message CM_DIALOGKEY; 
    
    implementation 
    ... 
    
    procedure TSomeForm.CMDialogKey(var Message : TCMDialogKey); 
    begin 
        case Message.CharCode of 
        VK_RETURN : Perform(CM_DialogKey, VK_TAB, 0); 
        ... 
        else 
        inherited; 
        end; 
    end; 
    
    +0

    은 낮은 수준 이상의 구성 요소에 정말 좋은 작품이 너무 – user2092868

    1

    양식에 TButton을 놓고 작게 만들고 다른 컨트롤 아래에 숨길 수 있습니다. (즉,이 키 입력 받고 있습니다) true로 기본 속성을 설정하고 OnClick 이벤트에 다음과 같은 장소 :

    이 델파이 3, 5, 6에서 작동
    SelectNext(ActiveControl, true, true); 
    
    1

    이벤트 onKeyPress는 다른 형식과 마찬가지로 삼중 형식으로 처리됩니다.

    문제는 프로 시저 수행 (wm_nextdlgctl, 0,0)이 프레임 내부에서 작동하지 않는다는 것입니다.

    적절한 이벤트를 발생 시키려면 활성 컨트롤을 알아야합니다.

    procedure TFrmDadosCliente.EditKeyPress(Sender: TObject; var Key: Char); 
    var 
        AParent:TComponent; 
    begin 
        if key = #13 then 
        begin 
        key := #0; 
    
        AParent:= TComponent(Sender).GetParentComponent; 
    
        while not (AParent is TCustomForm) do 
         AParent:= AParent.GetParentComponent; 
    
        SelectNext(TCustomForm(AParent).ActiveControl, true, true); 
        end; 
    end;