삽질하는플머

라자루스의 LCL 폼에 ActiveX 객체 올리기.

Lazarus

간만에 라자루스 관련 포스팅. 

저녁 먹고 라자루스 포럼을 뒤져보다 재미난 주제를 발견. 
http://www.lazarus.freepascal.org/index.php/topic,9311.0.html 

윈도에서 라자루스 LCL폼 위에 ActiveX 컨트롤을 올릴 수 있느냐는 질문. 오~!!
라자루스의 포터블한 특성이 사라지네 어쩌네 이런 저런 갑론을박이 있었지만,
어쨌건 글타래 말미에 ATL.DLL 을 사용한 멋진 해법이 올라와있다. 
빈 LCL폼 위에 TPanel을 올리고 다음과 같이 코딩. 


......

implementation


......

uses
  Windows, ComObj;

type
  PIUnknown=^IUnknown;
  TAtlAxAttachControl = function(Control:IUnknown; hwind:hwnd;ppUnkContainer:PIUnknown): HRESULT; stdcall;

........

constructor TForm1.Create(aOwner: TComponent);
var
  atl: hModule;
  AtlAxAttachControl:TAtlAxAttachControl;
  WebBrower:variant;
begin
  inherited Create(aOwner);
  atl := LoadLibrary('atl.dll');
  AtlAxAttachControl := TAtlAxAttachControl(GetProcAddress(atl, 'AtlAxAttachControl'));

  WebBrower:= CreateOleObject('Shell.Explorer');
  AtlAxAttachControl(WebBrower, Panel1.Handle, nil);
  WebBrower.Navigate('http://oranke.tistory.com');
end;




실행시켜본 결과는 짜잔~~


그 밑에 딸려있는 idl2pas 에 대한 링크도 재미나 보인다. 
http://www.nohl.eu/tech-resources/using-typelibs-with-freepascal/ 

다음에 시간날 때 뒤져봐야지...