< summary of bugs that occur in the use of >delphi WebBrowser controls

Source: Internet
Author: User

Delphi WebBrowser controls enable thethe bug that appears in use:
1, Webbrowser.visible=false;visible property can not make the WebBrowser control is not visible, temporarily replaced with Webbrowser.hide method, webbrowser.hide Hidden Browser, Webbrowser.show Display browser;
Added: WebBrowser's onvisible Event Control window is visible or hidden and used as above (does not fire if the visual property is tested for changes)
The above supplementary Reference original website: http://www.tuicool.com/articles/2ai6fi
    2, using webbrowser1.quit; method to exit the browser, the system error "unspecified target", the solution is not available;
     3, the Delphi WebBrowser cannot copy paste
The Web page that the WebBrowser control opens in Delphi cannot be copied or pasted, including the right-click menu and shortcut keys.
The solution is as follows:

citation: Uses Activex;

Place the following code in front of the last end of the window with the WebBrowser control:

Initialization
OleInitialize (nil);
Finalization
OleUninitialize;
reprinted in: http://blog.sina.com.cn/s/blog_62dcdf1a0100qu7d.html &NBSP;
< Span style= "margin:0px; font-size:16px; padding:0px; " >     4,      discussion URL:  http://bbs.csdn.net/topics/390229795

     workaround URL: http://www.cnblogs.com/dlwang2002/archive/2007/04/14/713499.html
Code:

The WebBrowser control shows that the Web page encounters a close window script problem within the page. Prompt to execute window close after running

Var

Vdefinetexplorerserverproc:pointer;

function Inetexplorerserverwndproc (

Hwnd:hwnd; Msg:uint; Wparam:wparam; Lparam:lparam): LRESULT; stdcall;

Begin

Result: = CallWindowProc (Vdefinetexplorerserverproc,

hwnd, MSG, WParam, LParam);

Case MSG of

Wm_destroy:

Begin

SetWindowLong (hwnd, GWL_WNDPROC, Integer (Vdefinetexplorerserverproc));

ShowMessage (' Window Close '); EXECUTE statement

End

End

End

Procedure Tform1.webbrowser1documentcomplete (Sender:tobject;

Const Pdisp:idispatch; var url:olevariant);

Var

Vshelldocobjviewhandle:thandle;

Vinetexplorerserverhandle:thandle;

Begin

Vshelldocobjviewhandle: = GetWindow (Twebbrowser (Sender). Handle, Gw_child);

Vinetexplorerserverhandle: = GetWindow (Vshelldocobjviewhandle, gw_child);

If Integer (@InetExplorerServerWndProc) <>

GetWindowLong (Vinetexplorerserverhandle, GWL_WNDPROC) Then

Begin

Integer (vdefinetexplorerserverproc): =

GetWindowLong (Vinetexplorerserverhandle, GWL_WNDPROC);

SetWindowLong (Vinetexplorerserverhandle, GWL_WNDPROC,

Integer (@InetExplorerServerWndProc));

End

End

Split Line


The following is a reference to Web control bugs and workarounds that are reproduced from web pages


URL:http://bbs.51cto.com/thread-656975-1.html

The bug and solution of WebBrowser control in Delphi
Introduction: Delphi language, whether from the development speed, or speed, or compile speed, or after the compilation of the execution file volume, are one of the most. Therefore, it is the first choice for sharing software, developing products and making "green software". However, for many reasons, Delphi, there are some controls, there are some bu ...
Keyword: Delphi WebBrowser control Bug Copy memory leak JavaScript close
Delphi language, whether from the development speed, or run speed, or compile speed, or compiled after the execution of file volume, are one of the most. Therefore, it is the first choice for sharing software, developing products and making "green software". However, for many reasons, there are some controls in Delphi, some bugs. No matter how the vast number of technical personnel response, Delphi official is "blind eye." There are problems, although people do not give a solution, but, can not use this language, after all, the advantages are greater than the shortcomings. or "hands-on, clothed" bar.
Recently, the author in the development of the Pan-East collaborative management system client, using the Delphi WebBrowser control, believe that the control is one of the most widely used controls, almost all Internet-related products are inseparable from this control. But this Delphi WebBrowser control, in the course of use, found three bugs.
1, if the open page, there through JavaScript close the page, will only close the control, the window containing the control still exists, and manually close the window, there is a problem;
2, open the page, through the mouse selected content, can not be copied, either through the right-click menu Copy, or through the CTRL + C shortcut key copy, can not;
3. Open the window with WebBrowser control, and after closing the window, the memory is not released (this bug also exists in other languages).

The above three questions must be solved. By finding the data and your own experiments, we finally found a solution to summarize the solution as follows:

Problem 1 Solution:
Declare the message handler function first:
Procedure Applicationmessage (Var msg:tmsg; var handled:boolean);

When you create a form
Application.onmessage: = Applicationmessage;

The function contents are as follows:
Procedure Tfrmhtmlbrowser.   Applicationmessage (var msg:tmsg; var handled:boolean);
Var
WB:TEMBEDDEDWB;
Begin
WB: = Getvisiblewebbrowser; Take the current WebBrowser control
if (Msg.message = Wm_close) and (Msg.hwnd = Wb.handle) Then
Begin
Self.close ();//Turn off the WebBrowser after closing the corresponding window
End
Else
inherited;
End

Problem 2 Solution:
Citation: Uses Activex;

Place the following code in front of the last end of the window with the WebBrowser control:
Initialization
OleInitialize (nil);
Finalization
OleUninitialize;

Problem 3 Solution:
Modify the Delphi Control Source: Olectrls.pas

Modify the functions in this file: Getidispatchprop, Getiunknownprop
Modify the following:

function Tolecontrol.getidispatchprop (Index:integer): IDispatch;
Var
Temp:tvardata;
Begin
GetProperty (Index, Temp);
Result: = IDispatch (Temp.vdispatch);
Pointer (Result): = Temp.vdispatch;
End

function Tolecontrol.getiunknownprop (Index:integer): IUnknown;
Var
Temp:tvardata;
Begin
GetProperty (Index, Temp);
Result: = IUnknown (Temp.vunknown);
Pointer (Result): = Temp.vunknown;
End

After modification, recompile.

The above is the Delphi WebBrowser control bug Solution, we hope to help!

< summary of bugs that occur in the use of >delphi WebBrowser controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.