473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Composite UI Application Block issues

I'm trying to figure out how to make a SmartPart visible on my screen through
a SmartPartPlaceHolder. I have the following code (I don't have so much
understanding of CAB yet so there might be a few things wrong here and there
- I hope you can help and correct me):

//------ CABTest2 project -------------

//Program.cs
using System;

namespace CABTest2
{
static class Program
{
[STAThread]
static void Main()
{
new MainShell().Run();
}
}
}
//ProfileCatalog.xml
<?xml version="1.0" encoding="utf-8" ?>
<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile" >
<Modules>
<ModuleInfo AssemblyFile="Module1.dll"/>
</Modules>
</SolutionProfile>
//MainShell.cs
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.CompositeUI.WinForms;

namespace CABTest2
{
class MainShell : FormShellApplication<WorkItem, MainForm>
{
protected override void AfterShellCreated()
{
base.AfterShellCreated();

RootWorkItem.UIExtensionSites.RegisterSite(
"MainMenu",
Shell.MainMenuStrip);

ToolStripMenuItem l_mi = new ToolStripMenuItem("File");
RootWorkItem.UIExtensionSites["MainMenu"].Add(l_mi);
}
}
}
//MainForm.cs
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI;

namespace CABTest2
{
public partial class MainForm : Form
{
WorkItem m_root;

[ServiceDependency]
public WorkItem RootWorkItem
{
set
{
m_root = value;
}
}

public MainForm()
{
InitializeComponent();
}
}
}

//MainForm.Designer.cs
namespace CABTest2
{
partial class MainForm
{
/// <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.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.smartPartPlaceHolder1 = new
Microsoft.Practices.CompositeUI.WinForms.SmartPart Placeholder();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(292, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// smartPartPlaceHolder1
//
this.smartPartPlaceHolder1.BackColor =
System.Drawing.Color.Transparent;
this.smartPartPlaceHolder1.Location = new
System.Drawing.Point(12, 126);
this.smartPartPlaceHolder1.Name = "smartPartPlaceHolder1";
this.smartPartPlaceHolder1.Size = new System.Drawing.Size(219,
66);
this.smartPartPlaceHolder1.SmartPartName = "TestSmartPart";
this.smartPartPlaceHolder1.TabIndex = 1;
this.smartPartPlaceHolder1.Text = "TestSmartPart";
//
// MainForm
//
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.smartPartPlaceHolder1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "MainForm";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.MenuStrip menuStrip1;
private
Microsoft.Practices.CompositeUI.WinForms.SmartPart Placeholder
smartPartPlaceHolder1;
}
}

//-------------- Module1 project -----------------

//Module1Init.cs
using Microsoft.Practices.CompositeUI;

namespace Module1
{
public class Module1Init : ModuleInit
{
WorkItem m_root;

[ServiceDependency]
public WorkItem RootWorkItem
{
set
{
m_root = value;
}
}

public override void AddServices()
{
base.AddServices();

//Add services programmatically here...
}

public override void Load()
{
base.Load();

//Display the user-interface here or perform startup custom
logic...

Module1WorkItem l_wi = m_root.WorkItems.AddNew<Module1WorkItem>();
l_wi.Run();
}
}
}
//Module1WorkItem.cs
using Microsoft.Practices.CompositeUI;
using Module1;

namespace Module1
{
public class Module1WorkItem : WorkItem
{
protected override void OnRunStarted()
{
base.OnRunStarted();

MainUserControl csp =
SmartParts.AddNew<MainUserControl>("TestSmartPart" );

//MainUserControl l_uc = SmartParts.AddNew<MainUserControl>();
//Workspaces["MyMainWorkspace"].Show(l_uc);
}
}
}
//MainUserControl.cs
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI.SmartParts;

namespace Module1
{
[SmartPart]
public partial class MainUserControl : UserControl
{
public MainUserControl()
{
InitializeComponent();
}
}
}

NOTE that I also have set the SmartPartName
Nov 22 '06 #1
3 4109
It works perfectly fine if I use the workspace approach, but I'm really
having problems getting the SmartPartPlaceHolder to show anything.
Nov 22 '06 #2

U¿ytkownik "Joachim" <Jo*****@discussions.microsoft.comnapisa³ w
wiadomo¶ci news:E6**********************************@microsof t.com...
I'm trying to figure out how to make a SmartPart visible on my screen
through
a SmartPartPlaceHolder. I have the following code (I don't have so much
understanding of CAB yet so there might be a few things wrong here and
there
- I hope you can help and correct me):

//------ CABTest2 project -------------

//Program.cs
using System;

namespace CABTest2
{
static class Program
....
....
....

Please try this link

http://msdn.microsoft.com//msdnmag/i...s/default.aspx

Sorry, but your code is terible.

Regards
Forrest
Nov 23 '06 #3


"Forrest" wrote:
>
U¿ytkownik "Joachim" <Jo*****@discussions.microsoft.comnapisa³ w
wiadomo¶ci news:E6**********************************@microsof t.com...
I'm trying to figure out how to make a SmartPart visible on my screen
through
a SmartPartPlaceHolder. I have the following code (I don't have so much
understanding of CAB yet so there might be a few things wrong here and
there
- I hope you can help and correct me):

//------ CABTest2 project -------------

//Program.cs
using System;

namespace CABTest2
{
static class Program
....
....
....

Please try this link

http://msdn.microsoft.com//msdnmag/i...s/default.aspx
Not much that helped me there, except for

"Views can be displayed by using SmartPartPlaceHolder classes or through
what CAB calls a workspace. These are simply layout containers used to
display your views in a given arrangement. If you have ever worked with the
Java abstract windows toolkit (AWT), you should be familiar with this
concept."

Sorry, but your code is terible.
Thanks, that was encouraging and informative.
Regards
Forrest

Joachim
Nov 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1210
by: Ken | last post by:
Our tool control applicatioin is currently comprised of a .NET part written in C#, components written in C++ and a Lab View component. They are at different version levels. Not all composite...
1
2059
by: Paul Kia | last post by:
I have an ATL composite control which I drop into a tab control dialog page of an MFC application. When I click on the composite control and then click anywhere outside the MFC application, the...
5
2000
by: KJ | last post by:
This is kind of hard to explain but I have a The controls are created with CreateChildControls(). Now let say I click a button and an error occurs in the control. If I throw it up it goes back...
1
3136
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
8
6455
by: TrtnJohn | last post by:
I have an application where I would like to block waiting on an asynchronous event and still process messages. I can implement a hard loop to block such as: Do While StillWaiting...
3
1412
by: cashdeskmac | last post by:
I have created a composite control in C# which shows a DropDownList with 4 items and when one is selected a relevant message appears in a TextBox. This works fine. I then tried to recreate the...
2
2146
by: lwhitb1 | last post by:
Does anyone have any input on setting up my CAB application so that the application is thread safe, and cached appropiately? I read that this can be managed through Services, and dynamic injection....
0
1147
by: lwhitb1 | last post by:
Does anyone have any input on setting up my CAB application so that the application is thread safe, and cached appropiately? I read that this can be managed through Services, and dynamic injection....
0
1377
by: Paul | last post by:
I've installed the Composite UI Application block. However, I'm unable to open the Solution (using VS.NET 2005 - Standard Edition). Is this becuase I need VSTS to open the Composite UI...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.