Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Create a Universal Document Template which supports Dynamic Frame Window Layout

, 14 Dec 2002
Introduce a programming technology to design a very complex, rich document type.
visualframework_src.zip
sample
ObjManager
res
ObjManager.manifest
VisualFrameWork
application.rgs
AtlForm.rgs
Board.rgs
DocumentCtrl.rgs
Documents.rgs
menuimg.bmp
Prairie Wind.bmp
res
Toolbar.bmp
VisualFrameWork.ico
VisualFrameWork.manifest
VisualFrameWorkDoc.ico
VisualFrameWork.rgs
VisualFrameWork.tlb
VisualFrameWork1
VisualFrameWork12
VisualFrameWork13
Demo1
Demo2
MfcViewLib
MfcViewLib.rgs
cnn.rgs
MfcViewLib.def
MfcViewLibps.def
AtlView2.rgs
AtlView3.rgs
vc70.tlb
VbComLib
VbComLib.vbproj.user
VCSharpComLib
VCSharpComLib.csproj.user
DemoDoc
Demo1
Demo2
Demo3
DocumentPropertyPage.rgs
New Document 2
New Document333
New Document 2dd
VBDoc
UD.dob
prjVBDoc.vbp
MSSCCPRJ.SCC
prjVBDoc.vbw
CNN
MSSCCPRJ.SCC
PrjCnn.vbw
PrjCnn.dll
PrjCnn.lib
PrjCnn.exp
cls.cls
PrjCnn.vbp
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace VCSharpComLib
{
	//Declare a new delegate
	[ComVisible(false)]
	public delegate void CSharpObjEventHandler();

	//Events interface
	[Guid("6FB2615E-9C46-4B29-9357-14BA74A0A15E")]
	[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
	public interface ICSharpObjEvent
	{
		//declare a event source
		void NewEvent();
	}

	/// <summary>
	/// summary of CSharpObj 
	/// </summary>
	[Guid("7B00FED4-BD02-42E9-92B4-C18912A9F6DE")]
	[ClassInterface(ClassInterfaceType.AutoDual)]
	[ComSourceInterfaces(typeof(ICSharpObjEvent))]
	public class CSharpObj : System.Windows.Forms.UserControl
	{
		private System.Windows.Forms.Button button1;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		
		//declare a event
		public event CSharpObjEventHandler NewEvent;

		//declare a method
		public void NewMethod()
		{
			//raise event
			NewEvent();
		}

		//dynamic load .Net component
		public void LoadDotNetControl(string sLibraryName, string sControlName, string sName)
		{
			System.Reflection.Assembly mAssembly;
			Type mType;
			object mDynObj;
			System.Reflection.PropertyInfo mPropertyInfo;

			//load program assembly
			mAssembly = System.Reflection.Assembly.Load(sLibraryName);
			//get component type
			mType = mAssembly.GetType(sLibraryName + "." + sControlName, true, true);
			//create component instance
			mDynObj = System.Activator.CreateInstance(mType);
			//set component "Dock" property
			mPropertyInfo= mType.GetProperty("Dock");
			mPropertyInfo.SetValue(mDynObj, System.Windows.Forms.DockStyle.Fill,null);
			//set component "Name" property
			mPropertyInfo= mType.GetProperty("Name");
			mPropertyInfo.SetValue(mDynObj, sName ,null);
			//show component in current container
			Controls.AddRange(new System.Windows.Forms.Control[]{( System.Windows.Forms.Control)mDynObj});

		}

		public CSharpObj()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitForm call

		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component 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.button1 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.BackColor = System.Drawing.Color.Blue;
			this.button1.Location = new System.Drawing.Point(32, 48);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(88, 40);
			this.button1.TabIndex = 0;
			this.button1.Text = "CSharpCtrl";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// CSharpObj
			// 
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(255)), ((System.Byte)(128)));
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.button1});
			this.Name = "CSharpObj";
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			Form1 pForm = new Form1();
			pForm.Show();
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

dean170
Web Developer
China China
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411019.1 | Last Updated 15 Dec 2002
Article Copyright 2002 by dean170
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid