读书人

delphi怎么按照控件的左右顺序来遍历窗

发布时间: 2012-05-22 18:18:54 作者: rapoo

delphi如何按照控件的左右顺序来遍历窗体中的每个控件
delphi如何按照控件的左右顺序来遍历窗体中的每个控件
delphi默认是按照控件添加进窗体的顺序来遍历的,
有没有哪个属性能控制这个/??


[解决办法]
没有的,

Delphi(Pascal) code
object Form1: TForm1  Left = 226  Top = 153  Width = 696  Height = 480  Caption = 'Form1'  Color = clBtnFace  Font.Charset = DEFAULT_CHARSET  Font.Color = clWindowText  Font.Height = -11  Font.Name = 'MS Sans Serif'  Font.Style = []  Menu = MainMenu1  OldCreateOrder = False  PixelsPerInch = 96  TextHeight = 13    object Edit1: TEdit    Left = 336    Top = 128    Width = 121    Height = 21    TabOrder = 2    Text = 'Edit1'  end  object Button1: TButton    Left = 208    Top = 296    Width = 75    Height = 25    Caption = 'Button1'    TabOrder = 0  end  object Button2: TButton    Left = 408    Top = 272    Width = 75    Height = 25    Caption = 'Button2'    TabOrder = 1    OnClick = Button2Click  end  object Edit2: TEdit    Left = 368    Top = 32    Width = 121    Height = 21    TabOrder = 3    Text = 'Edit2'  end  object Edit3: TEdit    Left = 200    Top = 64    Width = 121    Height = 21    TabOrder = 4    Text = 'Edit3'  end  object RadioButton1: TRadioButton    Left = 128    Top = 40    Width = 113    Height = 17    Caption = 'RadioButton1'    TabOrder = 5  end  object MainMenu1: TMainMenu    Left = 232    Top = 96  endend
[解决办法]
如果窗体上的控件都是 TWinControl继承下来的 下面的代码对你可能有帮助
var

P:TPoint;
wnd:Thandle;
vWinControl: TWinControl;
begin



P := self.ClientToScreen(Point(x,y));

wnd := WindowFromPoint(p);//
if wnd<>0 then
begin
vWinControl := FindControl(wnd);


end;

end;

读书人网 >.NET

热点推荐