Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 팁&트릭
Delphi Programming Tip&Tricks
[96] 다른 Application의 단추를 Click하자
박정모 [] 5103 읽음    2001-12-10 16:56


EnumWindows, EnumChildWindows를 이용해서 단추를 찾고 Click하는 방법을 사용하고
있네요... ^^

function EnumChildProc( phWnd : hWnd; poCaptions : TStrings ) : Boolean; stdcall;
var
  szFull : array[ 0..MAX_PATH ] of Char;
begin
  Result := phWnd <> 0;

  if Result = TRUE then
  begin
     GetWindowText( phWnd, szFull, SizeOf( szFull ) );

     if ( Pos( poCaptions[ 0 ], String( szFull ) ) > 0 ) AND
        ( poCaptions.IndexOfObject( TOBject( phWnd ) ) <  0 ) then
        poCaptions.AddObject( String( szFull ), TObject( phWnd ) );

     EnumChildWindows( phWnd, @EnumChildProc, LongInt( poCaptions ) );
  end;
end;

function ClickButton( ParentWindow : Hwnd; ButtonCaption : String ) : Boolean;
var
  lhWnd : hWnd;
  loCaptions : TStringList;
begin
  loCaptions := TStringList.Create;

  try
     loCaptions.AddObject( ButtonCaption, nil );

     EnumChildWindows( ParentWindow, @EnumChildProc, LongInt( loCaptions ) );

     lhWnd := 0;
     case loCaptions.Count of
        1 : ShowMessage( 'Window text not found.' );
        2 : lhWnd := hWnd( loCaptions.Objects[ 1 ] );
        else
           ShowMessage( 'Ambiguous text detected.' );
     end;
  finally
     loCaptions.Free;
  end;

  Result := lhWnd <> 0;
  if Result then
     PostMessage( lhWnd, BM_CLICK, 0, 0 );
end;



+ -

관련 글 리스트
96 다른 Application의 단추를 Click하자 박정모 5103 2001/12/10
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.