如下代码:    indexfocus := self.ActiveControl.ComponentIndex + 1;    if indexfocus = self.ActiveControl.ComponentCount then
          indexfocus := 0;
        twincontrol(form.Controls[indexfocus]).SetFocus;
    end;
如果是delphi中带的自身控件判断起来没有问题,可是使用第三方控件后,就不好使了?代码中的 self.ActiveControl.ComponentIndex 无法获取,甚至连控件的name都获取不了!请问这是为什么啊?
朋友们帮帮忙!

解决方案 »

  1.   

    如果你只是想:将焦点放到下一个控件的话,建议用:
    SendMessage(Handle, WM_NEXTDLGCTL, 0, 0);
      

  2.   

    sendmessage(Handle,WM_NEXTDLGCTL,0,0)中的0,0是代表什么意思啊?
    大虾可以说说吗?
      

  3.   

    自己查帮助WM_NEXTDLGCTL  
    wCtlFocus = wParam;              // identifies control for focus 
    fHandle = (BOOL) LOWORD(lParam); // wParam handle flag 
     ParameterswCtlFocusValue of wParam. If the fHandle parameter is TRUE, the wCtlFocus parameter identifies the control that receives the focus. If fHandle is FALSE, wCtlFocus is a flag that indicates whether the next or previous control with the WS_TABSTOP style receives the focus. If wCtlFocus is zero, the next control receives the focus; otherwise, the previous control with the WS_TABSTOP style receives the focus. fHandleValue of lParam. Contains a flag that indicates how Windows uses the wCtlFocus parameter. If the fHandle parameter is TRUE, wCtlFocus is a handle associated with the control that receives the focus; otherwise, wCtlFocus is a flag that indicates whether the next or previous control with the WS_TABSTOP style receives the focus. 焦点移出的时候拉回来
    procedure TForm1.Edit1Exit(Sender: TObject);
    begin
      if Edit1.Text <> 'Zswang' then Edit1.SetFocus;
    end;