如何才能访问到 controls.ControlAtomString变量,在不修改contorls.pas的前提下uses
  Windows,
  SysUtils,
  Classes,
  Controls;{$R *.res}function MyFindControl(Handle: HWnd): TWinControl;
begin
  ControlAtomString:=WindowAtomString;
  ControlAtom:=WindowAtom;
  Result:=FindControl(Handle);
end;编译器提示ControlAtomString未定义
[DCC Error] Project1.dpr(24): E2003 Undeclared identifier: 'ControlAtom'
[DCC Error] Project1.dpr(24): E2003 Undeclared identifier: 'WindowAtom'

解决方案 »

  1.   

    打开Controls.pas单元,找到InitControls过程:procedure InitControls;
    begin
      ...
      WindowAtomString := Format('Delphi%.8X',[GetCurrentProcessID]);
      WindowAtom := GlobalAddAtom(PChar(WindowAtomString));
      ControlAtomString := Format('ControlOfs%.8X%.8X', [HInstance, GetCurrentThreadID]);
      ControlAtom := GlobalAddAtom(PChar(ControlAtomString));
      ....
    end;
      

  2.   


    打开Controls.pas单元,找到InitControls过程: procedure   InitControls; 
    begin 
        ... 
        WindowAtomString   :=   Format('Delphi%.8X',[GetCurrentProcessID]); 
        WindowAtom   :=   GlobalAddAtom(PChar(WindowAtomString)); 
        ControlAtomString   :=   Format('ControlOfs%.8X%.8X',   [HInstance,   GetCurrentThreadID]); 
        ControlAtom   :=   GlobalAddAtom(PChar(ControlAtomString)); 
        .... 
    end; 
    我知道是在这里定义的,
    我的意思是在Contorls.pas单元外使用ControlAtomString...这几个变量
    (delphi编译器对rtl里的单元和外部单元处理方式是不一样的,有些定义不能以常规的方式访问,
    比如上边的例子就提示未定义)
      

  3.   

    晕,你不会自己照样生成啊!
    function   MyFindControl(Handle:   HWnd):   TWinControl; 
    begin 
        ControlAtomString:=Format('ControlOfs%.8X%.8X',       [HInstance,       GetCurrentThreadID]);
        ControlAtom:=GlobalAddAtom(PChar(ControlAtomString));    
        Result:=FindControl(Handle); 
    end;