PDA

View Full Version : پرینت یک فایل htmlبه وسیله Webbrowser در دلفی



champion
یک شنبه 21 خرداد 1385, 20:20 عصر
دوستان عزیزم سلام
من احتیاج به کمک فوری شما دارم لطفا من رو راهنمایی کنید
من یک فایل html رو به وسیله Webbrowser در دلفی باز میکنم ولی موقع پرینت نصفه چاپ میشه
راه حل خاصی داره ؟
ممنون

babak869
یک شنبه 21 خرداد 1385, 22:11 عصر
از کد زیر استفاده نمایید


procedure TForm1.WebBrowser_V1NavigateComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
HTMLDoc: IHTMLDocument2;
HTMLWnd: IHTMLWindow2;
HTMLWindow3: IHTMLWindow3;
begin
HTMLDoc := (Sender as TWebBrowser).Document as IHTMLDocument2;
if HTMLDoc = nil then
raise Exception.Create('Could not convert the WebBrowser to an IHTMLDocument2');
HTMLWnd := HTMLDoc.parentWindow;
HTMLWindow3 := HTMLWnd as IHTMLWindow3;
// finally, we get to the print method
HTMLWindow3.print;
end;

// ..
begin
WebBrowser1.Navigate('http://www.yahoo.com/');
end;