Click here to Skip to main content
15,901,368 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: COM is not working in Windows98se Pin
Dave Kreskowiak18-Sep-05 1:38
mveDave Kreskowiak18-Sep-05 1:38 
QuestionMinimum security level to... Pin
Ray Cassick17-Sep-05 14:28
Ray Cassick17-Sep-05 14:28 
QuestionMSMQ Pin
chinnasrihari16-Sep-05 19:23
chinnasrihari16-Sep-05 19:23 
QuestionSubType = "Form" or "UserControl" --> SubType = "Code" Pin
Rafferty Uy15-Sep-05 22:25
Rafferty Uy15-Sep-05 22:25 
Questionauto detect new device in windows application Pin
SongDog15-Sep-05 7:28
SongDog15-Sep-05 7:28 
QuestionSystemMonitor ActiveX control and custom performance counters Pin
ivanrachev15-Sep-05 4:38
ivanrachev15-Sep-05 4:38 
QuestionActive document server in .NET Pin
Bruce Pataki15-Sep-05 3:15
Bruce Pataki15-Sep-05 3:15 
QuestionBug in framework? Pin
AlexR12315-Sep-05 2:16
AlexR12315-Sep-05 2:16 
Hello,

I'm trying to use Microsoft Web Browser Control coding on c# (framework 1.1), what is the purpose of the wrapper used tlbimp utility.

1) I've load web page using Navigate method

2) then when i got the document, I’m running thru all the elements and make a "hooks" or register delegates on the events I’ve needed.

When I’m using OnClick event - all is OK,

but in others case ( e.g. OnActivate ) - the error occurred

When I’ve implemented such code using winAPI - the code done the right result.

On my opinion there is an error in .NET Framework, i.e. during implementing COM object wrapper.



Answer please what has happened;

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using AxSHDocVw;

using mshtml;



namespace WindowsApplication1

{

///

/// Summary description for Form1.

///


public class Form1 : System.Windows.Forms.Form

{

private AxSHDocVw.AxWebBrowser myWebBrowser;

private System.Windows.Forms.Button button1;

private System.Windows.Forms.Button button2;

///

/// Required designer variable.

///


private System.ComponentModel.Container components = null;



public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();



//

// TODO: Add any constructor code after InitializeComponent call

//

}



///

/// Clean up any resources being used.

///


protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}



#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///


private void InitializeComponent()

{

System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));

this.myWebBrowser = new AxSHDocVw.AxWebBrowser();

this.button1 = new System.Windows.Forms.Button();

this.button2 = new System.Windows.Forms.Button();

((System.ComponentModel.ISupportInitialize)(this.myWebBrowser)).BeginInit();

this.SuspendLayout();

//

// myWebBrowser

//

this.myWebBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)

| System.Windows.Forms.AnchorStyles.Right)));

this.myWebBrowser.Enabled = true;

this.myWebBrowser.Location = new System.Drawing.Point(0, 48);

this.myWebBrowser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("myWebBrowser.OcxState")));

this.myWebBrowser.Size = new System.Drawing.Size(664, 288);

this.myWebBrowser.TabIndex = 0;

//

// button1

//

this.button1.Location = new System.Drawing.Point(16, 8);

this.button1.Name = "button1";

this.button1.TabIndex = 1;

this.button1.Text = "Navigate";

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// button2

//

this.button2.Location = new System.Drawing.Point(104, 8);

this.button2.Name = "button2";

this.button2.Size = new System.Drawing.Size(104, 23);

this.button2.TabIndex = 2;

this.button2.Text = "ProcessElements";

this.button2.Click += new System.EventHandler(this.button2_Click);

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(664, 342);

this.Controls.Add(this.button2);

this.Controls.Add(this.button1);

this.Controls.Add(this.myWebBrowser);

this.Name = "Form1";

this.Text = "Form1";

((System.ComponentModel.ISupportInitialize)(this.myWebBrowser)).EndInit();

this.ResumeLayout(false);



}

#endregion



///

/// The main entry point for the application.

///


[STAThread]

static void Main()

{

Application.Run(new Form1());

}





private void button1_Click(object sender, System.EventArgs e)

{

object o = 0;

object o1 = "";

object o3 = new byte[]{};

object o4 = "";

myWebBrowser.Navigate("http://127.0.0.1/test/index3.html", ref o, ref o1, ref o3, ref o4 );



}





private bool procesTextElementClick()

{

MessageBox.Show ("Click");

return false;

}



private void procesTextElementActivate()

{

MessageBox.Show ("Activate");

}







private void button2_Click(object sender, System.EventArgs e)

{



HTMLDocumentClass myDocument = (HTMLDocumentClass) myWebBrowser.Document ;

IHTMLElementCollection myHtmlElementCollection = myDocument.IHTMLDocument2_all;



MessageBox.Show(myHtmlElementCollection.length.ToString() ) ;

IEnumerator enumeratorOfMyCollection = myHtmlElementCollection.GetEnumerator();

do

{

// String href;

Object o = enumeratorOfMyCollection.Current;



if (o is HTMLInputElementClass)

{

HTMLInputElementClass inputElement = o as HTMLInputElementClass;



switch (inputElement.type)

{

case "submit":

// inputElement.HTMLButtonElementEvents_Event_onclick +=new HTMLButtonElementEvents_onclickEventHandler(clickOnButton);

break;

case "text":







inputElement.HTMLInputTextElementEvents_Event_onclick +=new HTMLInputTextElementEvents_onclickEventHandler(procesTextElementClick);



inputElement.HTMLButtonElementEvents_Event_onactivate +=new HTMLButtonElementEvents_onactivateEventHandler(procesTextElementActivate);



break;

case "checkbox":

// inputElement.HTMLButtonElementEvents_Event_onclick +=new HTMLButtonElementEvents_onclickEventHandler(clickOnButton);

break;

case "radio":

// inputElement.HTMLButtonElementEvents_Event_onclick +=new HTMLButtonElementEvents_onclickEventHandler(clickOnButton);

break;

}



}









} while (enumeratorOfMyCollection.MoveNext());



}

}

}
QuestionRegarding the linking of a dll created in .NET Pin
MoQuisha14-Sep-05 20:20
MoQuisha14-Sep-05 20:20 
Questioncompact framework - registering events Pin
David Menéndez Cisterna14-Sep-05 8:48
David Menéndez Cisterna14-Sep-05 8:48 
QuestionNETCF Windows Forms Control in Pocket IE?? Pin
rainersimon14-Sep-05 5:41
rainersimon14-Sep-05 5:41 
Questiongprs classes Pin
_tasleem14-Sep-05 3:25
_tasleem14-Sep-05 3:25 
AnswerRe: gprs classes Pin
Dave Kreskowiak14-Sep-05 6:49
mveDave Kreskowiak14-Sep-05 6:49 
QuestionHow do set another folder than \bin for my assemblies when "Local Copy"... Pin
MaWeRic14-Sep-05 1:36
MaWeRic14-Sep-05 1:36 
GeneralRe: How do set another folder than \bin for my assemblies when "Local Copy"... Pin
seee sharp19-Sep-05 0:37
seee sharp19-Sep-05 0:37 
GeneralRe: How do set another folder than \bin for my assemblies when "Local Copy"... Pin
MaWeRic19-Sep-05 19:52
MaWeRic19-Sep-05 19:52 
Question[SOS] about API(SendMessage or PostMessage) Pin
cnet200813-Sep-05 20:01
cnet200813-Sep-05 20:01 
AnswerRe: [SOS] about API(SendMessage or PostMessage) Pin
cnet200813-Sep-05 20:53
cnet200813-Sep-05 20:53 
GeneralRe: [SOS] about API(SendMessage or PostMessage) Pin
Saksida Bojan13-Sep-05 22:37
Saksida Bojan13-Sep-05 22:37 
GeneralRe: [SOS] about API(SendMessage or PostMessage) Pin
cnet200814-Sep-05 20:18
cnet200814-Sep-05 20:18 
QuestionFundamental Question Pin
Anonymous13-Sep-05 13:45
Anonymous13-Sep-05 13:45 
AnswerRe: Fundamental Question Pin
Christian Graus13-Sep-05 14:28
protectorChristian Graus13-Sep-05 14:28 
GeneralRe: Fundamental Question Pin
Anonymous13-Sep-05 14:41
Anonymous13-Sep-05 14:41 
GeneralRe: Fundamental Question Pin
Christian Graus13-Sep-05 14:43
protectorChristian Graus13-Sep-05 14:43 
AnswerRe: Fundamental Question Pin
rwestgraham13-Sep-05 14:40
rwestgraham13-Sep-05 14:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.