Click here to Skip to main content
15,897,891 members
Articles / Desktop Programming / ATL

Native & Managed Interop Made Simple

Rate me:
Please Sign up or sign in to vote.
4.43/5 (3 votes)
14 Nov 2007CPOL14 min read 37.4K   350   26  
This article presents a simple calculator component example by using COM Interoperability basics.
namespace SimpleCalcTesterNET
{
	partial class SimpleCalcTesterForm
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		#region Windows Form Designer generated code

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.txOper1 = new System.Windows.Forms.TextBox();
			this.txOper2 = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.txResult = new System.Windows.Forms.TextBox();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.btDivideEB = new System.Windows.Forms.Button();
			this.btMultiplyEB = new System.Windows.Forms.Button();
			this.btSubtractEB = new System.Windows.Forms.Button();
			this.btAddEB = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.btDivideLB = new System.Windows.Forms.Button();
			this.btMultiplyLB = new System.Windows.Forms.Button();
			this.btSubtractLB = new System.Windows.Forms.Button();
			this.btAddLB = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(12, 9);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(132, 23);
			this.label1.TabIndex = 0;
			this.label1.Text = "1st Value";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(150, 9);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(130, 23);
			this.label2.TabIndex = 0;
			this.label2.Text = "2nd Value";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// txOper1
			// 
			this.txOper1.Location = new System.Drawing.Point(15, 35);
			this.txOper1.Name = "txOper1";
			this.txOper1.Size = new System.Drawing.Size(129, 20);
			this.txOper1.TabIndex = 1;
			this.txOper1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// txOper2
			// 
			this.txOper2.Location = new System.Drawing.Point(150, 35);
			this.txOper2.Name = "txOper2";
			this.txOper2.Size = new System.Drawing.Size(130, 20);
			this.txOper2.TabIndex = 1;
			this.txOper2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(15, 208);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(265, 23);
			this.label3.TabIndex = 0;
			this.label3.Text = "Result";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// txResult
			// 
			this.txResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txResult.Location = new System.Drawing.Point(15, 234);
			this.txResult.Name = "txResult";
			this.txResult.ReadOnly = true;
			this.txResult.Size = new System.Drawing.Size(265, 20);
			this.txResult.TabIndex = 2;
			this.txResult.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.btDivideEB);
			this.groupBox1.Controls.Add(this.btMultiplyEB);
			this.groupBox1.Controls.Add(this.btSubtractEB);
			this.groupBox1.Controls.Add(this.btAddEB);
			this.groupBox1.Location = new System.Drawing.Point(15, 61);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(97, 132);
			this.groupBox1.TabIndex = 3;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Early Bound";
			// 
			// btDivideEB
			// 
			this.btDivideEB.Location = new System.Drawing.Point(6, 106);
			this.btDivideEB.Name = "btDivideEB";
			this.btDivideEB.Size = new System.Drawing.Size(85, 23);
			this.btDivideEB.TabIndex = 0;
			this.btDivideEB.Text = "Divide (/)";
			this.btDivideEB.UseVisualStyleBackColor = true;
			this.btDivideEB.Click += new System.EventHandler(this.btDivideEB_Click);
			// 
			// btMultiplyEB
			// 
			this.btMultiplyEB.Location = new System.Drawing.Point(6, 77);
			this.btMultiplyEB.Name = "btMultiplyEB";
			this.btMultiplyEB.Size = new System.Drawing.Size(85, 23);
			this.btMultiplyEB.TabIndex = 0;
			this.btMultiplyEB.Text = "Multiply (*)";
			this.btMultiplyEB.UseVisualStyleBackColor = true;
			this.btMultiplyEB.Click += new System.EventHandler(this.btMultiplyEB_Click);
			// 
			// btSubtractEB
			// 
			this.btSubtractEB.Location = new System.Drawing.Point(6, 48);
			this.btSubtractEB.Name = "btSubtractEB";
			this.btSubtractEB.Size = new System.Drawing.Size(85, 23);
			this.btSubtractEB.TabIndex = 0;
			this.btSubtractEB.Text = "Subtract (-)";
			this.btSubtractEB.UseVisualStyleBackColor = true;
			this.btSubtractEB.Click += new System.EventHandler(this.btSubtractEB_Click);
			// 
			// btAddEB
			// 
			this.btAddEB.Location = new System.Drawing.Point(6, 19);
			this.btAddEB.Name = "btAddEB";
			this.btAddEB.Size = new System.Drawing.Size(85, 23);
			this.btAddEB.TabIndex = 0;
			this.btAddEB.Text = "Add (+)";
			this.btAddEB.UseVisualStyleBackColor = true;
			this.btAddEB.Click += new System.EventHandler(this.btAddEB_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.btDivideLB);
			this.groupBox2.Controls.Add(this.btMultiplyLB);
			this.groupBox2.Controls.Add(this.btSubtractLB);
			this.groupBox2.Controls.Add(this.btAddLB);
			this.groupBox2.Location = new System.Drawing.Point(183, 61);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(97, 132);
			this.groupBox2.TabIndex = 3;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "Late Bound";
			// 
			// btDivideLB
			// 
			this.btDivideLB.Location = new System.Drawing.Point(6, 106);
			this.btDivideLB.Name = "btDivideLB";
			this.btDivideLB.Size = new System.Drawing.Size(85, 23);
			this.btDivideLB.TabIndex = 0;
			this.btDivideLB.Text = "Divide (/)";
			this.btDivideLB.UseVisualStyleBackColor = true;
			this.btDivideLB.Click += new System.EventHandler(this.btDivideLB_Click);
			// 
			// btMultiplyLB
			// 
			this.btMultiplyLB.Location = new System.Drawing.Point(6, 77);
			this.btMultiplyLB.Name = "btMultiplyLB";
			this.btMultiplyLB.Size = new System.Drawing.Size(85, 23);
			this.btMultiplyLB.TabIndex = 0;
			this.btMultiplyLB.Text = "Multiply (*)";
			this.btMultiplyLB.UseVisualStyleBackColor = true;
			this.btMultiplyLB.Click += new System.EventHandler(this.btMultiplyLB_Click);
			// 
			// btSubtractLB
			// 
			this.btSubtractLB.Location = new System.Drawing.Point(6, 48);
			this.btSubtractLB.Name = "btSubtractLB";
			this.btSubtractLB.Size = new System.Drawing.Size(85, 23);
			this.btSubtractLB.TabIndex = 0;
			this.btSubtractLB.Text = "Subtract (-)";
			this.btSubtractLB.UseVisualStyleBackColor = true;
			this.btSubtractLB.Click += new System.EventHandler(this.btSubtractLB_Click);
			// 
			// btAddLB
			// 
			this.btAddLB.Location = new System.Drawing.Point(6, 19);
			this.btAddLB.Name = "btAddLB";
			this.btAddLB.Size = new System.Drawing.Size(85, 23);
			this.btAddLB.TabIndex = 0;
			this.btAddLB.Text = "Add (+)";
			this.btAddLB.UseVisualStyleBackColor = true;
			this.btAddLB.Click += new System.EventHandler(this.btAddLB_Click);
			// 
			// SimpleCalcTesterForm
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.ClientSize = new System.Drawing.Size(292, 266);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.txResult);
			this.Controls.Add(this.txOper2);
			this.Controls.Add(this.txOper1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label1);
			this.Name = "SimpleCalcTesterForm";
			this.Text = "SimpleCalc Tester";
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);
			this.PerformLayout();

		}

		#endregion

		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox txOper1;
		private System.Windows.Forms.TextBox txOper2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox txResult;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button btDivideEB;
		private System.Windows.Forms.Button btMultiplyEB;
		private System.Windows.Forms.Button btSubtractEB;
		private System.Windows.Forms.Button btAddEB;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.Button btDivideLB;
		private System.Windows.Forms.Button btMultiplyLB;
		private System.Windows.Forms.Button btSubtractLB;
		private System.Windows.Forms.Button btAddLB;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Safira
Portugal Portugal
Graduated the course Lincenciatura em Engenharia Informatica e Computadores at Instituto Superior Tecnico de Lisboa.
Worked as IT Technician and Manager of a small team while giving support to very small business offices.
Worked sa a Senior Developer at Markdata, a software house in Portugal.
Currently as Senior Software Engineer at Safira Consultoria S.A. in Portugal.

Comments and Discussions