2009-05-28 6 views
3

두 가지 간단한 질문에델파이 - TWebBrowser은

  1. 어떻게이 TWebBrowser에 포커스를 설정하는 발행? 이렇게하면 마우스 휠이 TWebBrwoser 디스플레이 영역 내에서 먼저 클릭하지 않고도 디스플레이를 스크롤 할 수 있습니다. 그것은 아무것도하지 않는 (또는 아무것도하지 않는 것 같다) setfocus 메소드를 가지고있다.

  2. TWebBrowser 내에서 표시된 링크를 마우스 오른쪽 단추로 클릭하고 속성을 선택하십시오. 확인 및 취소 버튼이 비활성화되어 대화 상자를 닫을 수 없습니다. 앱을 종료하려면 앱을 종료해야합니다.

아이디어가 있으십니까?

감사합니다. Jason. 많은 웹 사냥 후 질문 1에 대한

+0

그래서 별도로 질문하는 것이 가장 좋습니다. 그래서 요점은 고품질 응답을 가진 질문 저장소를 만드는 것입니다. 당신이 당신의 질문에 대해 두 가지 대답을 얻으면, 당신은 동의 할 것인가? – Argalatyr

+0

의미가 있습니다. 앞으로 별도의 질문을 드리겠습니다. Jason. –

답변

6

대답 ....

with WebBrowser1 do 
if Document <> nil then 
with Application as IOleobject do 
DoVerb(OLEIVERB_UIACTIVATE, nil, WebBrowser1, 0, Handle, GetClientRect); 
0

이 피터 존슨, How to make a TWebBrowser become the active control when clicked에 의해 다음 문서에서 설명합니다.

기사에서 더 많은 세부 사항이
procedure TWebBrowserFrame.CommandStateChange(Sender: TObject; 
    Command: Integer; Enable: WordBool); 
var 
    Doc: IHTMLDocument2;  // document object 
    Sel: IHTMLSelectionObject; // current selection 
begin 
    // Check we have a valid web browser triggering this event 
    if not Assigned(Sender) or not (Sender is TWebBrowser) then 
    Exit; 
    // Check we have required command 
    if TOleEnum(Command) <> CSC_UPDATECOMMANDS then 
    Exit; 
    // Get ref to document object and check not nil 
    Doc := Browser.Document as IHTMLDocument2; 
    if not Assigned(Doc) then 
    Exit; 
    // Get ref to current selection 
    Sel := Doc.selection as IHTMLSelectionObject; 
    // If selection is of correct type then we have a mouse click 
    if Assigned(Sel) and (Sel.type_ = 'Text') then 
    begin 
    // Make the web browser the form's active control 
    (Sender as TWebBrowser).SetFocus; 
    Doc.parentWindow.focus; 
    end; 
end; 

, 당신이 모든 것을 읽을 수 있는지 확인 바랍니다 :

OnCommandStateChange 이벤트를 추가, 크게 요약합니다.

+0

이 코드를 얻은 기사의 참조에서 편집했습니다. 귀속하지 않고 코드를 게시하십시오. –