Twebbrowser issues help develop and apply VCL Components
Http://www.delphi2007.net/DelphiVCL/html/delphi_20061225015126140.html
Using twebbrowser as a browser, two webpage files on the local machine are called.
The webpage contains a large number of javescrip scripts,
Three errors occur during the round-trip switch. These three errors are not frequent, but there are always,
One is mshtml. DLL exception
The second is to bring up a dialog box titled "real-time debugging"
"Select a debugger" at the top"
The following is a list box titled "Possible Debugger"
The list box contains a new instance Mircosoft Script Editor"
Below is a check box that sets the current debugger as the default debugger, and at the bottom of it is whether you want to debug with the selected debugger and then click
Third, a dialog box appears. In English, it tells me that I am in the debugging status.
The first problem is that it will appear on all machines during testing.
The second and third problems do not appear on some machines,
When the third problem occurs, it will be closed directly. Program
Development Environment D7 XP
The web page commit crip and mp7 are generated by the tool software.
Expert Solution
My Code Yes
I have a unit that defines a class. This class reads parameters from the database, generates instances, and then generates buttons on the interface.
Each button corresponds to an instance of this class
Click a button to open the corresponding webpage. These webpages are all local and are mp7 courseware generated by the software.
Including videos and ppt files, and the JavaScript scripts on the webpage are responsible for playing and synchronizing videos and ppt files,
The scripts on the webpage are generated by the software, and it is no problem to play one independently.
The problem is that when I keep pressing the button, that is, after I open a webpage, I immediately open another webpage.
I think webbrowser has transferred a new webpage, but the script in the original webpage has not been released clean or is still running, causing a conflict, so this problem occurs.
The main code is as follows,
Unit define;
//
Tpowerctl = Class (tobject)
Private
But: Boolean;
Fobj: tcontrol;
Fctlinfo: tctlfieldinfo;
Oldx: integer;
Oldy: integer;
Procedure objclick (Sender: tobject );
Procedure objenter (Sender: tobject );
Procedure tpowerctl. objclick (Sender: tobject );
VaR
I: integer;
DOC: ihtmldocument2;
// Temp: integer;
Begin
// Temp: = 0;
For I: = 0 to tcontrol (sender). Parent. ControlCount-1 do
Begin
If tcontrol (sender). Parent. controls [I]). Tag = 9999 then // tag of the webpage Control
Begin
While twebbrowser (tcontrol (sender). Parent. controls [I]). readystate <> 4 do
Application. processmessages; // execute after completion
Twebbrowser (tcontrol (sender). Parent. controls [I]). Stop;
DOC: Maid (FIG;
Doc. close;
Doc. Clear;
Twebbrowser (tcontrol (sender). Parent. controls [I]). navigate (mainpath + self. fctlinfo. findexpage); // call the corresponding webpage
Doc. _ release;
End;
End;
End;
The unit is called by the main form,
The ole control is initialized in the initialization event of this unit. // I have doubts about the initialization.
// Whether the Web is fixed and should be written in the prj initialization event
// Or the initialization event of the main form Unit
Top
The last one is a helpful brother, and the last one is closed and posted to the score, but if you are free, please continue to help,
Ding ding ~
Top, look...
You have to give two webpages.
It is estimated that the objclick has not been executed, and the new objclick has been executed again.
You need to find a way to avoid this situation.
Solution 1
Procedure tpowerctl. objclick (Sender: tobject );
//..
Begin
Enabled: = false; // do not let the User Switch when the processing is not complete
// Open the webpage
Enabled: = true; // switch is allowed only after processing
End;
Solution 2
Do not use while do
Event webbrowser1.ondocumentcomplete
Brother Shui,
Since the webpage will call the webpage itself after opening a new webpage, I feel that ondocumentcomplete cannot be used ,,
I now use readystate = 4 to control the enabled of the control,
But the problem is the same,
Is there a way to abort the execution of scripts on the webpage while I abort the webpage?
Brother Cutting
The two web pages add up to more than 300 mb. I guess they cannot be sent, including videos and PPT, And the scripts are not written by me,
I have never met you. I want to help you!
Initialization must be added. It is very important. format:
Uses ActiveX;
Initialization
Oleinitialize (NiL );
Finialization
Oleuninitialize;
The two web pages add up to more than 300 mb. I guess they cannot be sent, including videos and PPT, And the scripts are not written by me,
Khan, just give the webpage code! Both ppt and video are called locally.
However, Newbie will not handle webbrowser exceptions.
Which unit should be added for initialization?
Subscribe