Problem using ActiveX controls with VS2010

11. May 2012 11:56 by Mrojas in ActiveX, COM Interop, VB6 Migration, Visual Studio, WinForms  //  Tags: , , , , , , , ,   //   Comments (0)

 

Sometimes during migrations from VB6 to VS2010 we have found issues when you tried to add an ActiveX control with the VS2010 winforms designer. The issue is only present in VS2010 not on previous versions.

You usually will see an error in the added Interop references, and messages like a missing VBA or StdLib library.

The error has been reported several times so please vote on Connect to make sure MS will consider fixing it.

 

https://connect.microsoft.com/VisualStudio/feedback/details/557722/errors-utilizing-activex-controls-in-vs-2010

http://connect.microsoft.com/VisualStudio/feedback/details/568769/aximp-error-with-vb6-activex-control

 

And possible workarounds are running the Aximp manually from the command line and the add the references. You will then need to add the control by hand in your forms. Do not use the designer to add the component, this will try to regenerate the references and reproduice the issue.

The obscure way to open an Access 97 database with MDW Security in Access2010

10. May 2012 12:38 by Mrojas in Access  //  Tags: , , , , ,   //   Comments (0)

I was in an AccessMigration to SQL Server and i needed to open an Access97 database with security (using a system.mdw file).

It took me a while to do, but it is possible to open an Access97 Database in Access2010.

I really thing that it is a little obscure. But these are the steps:

1. First open Access2010

2. After Opening Access2010, press Ctrl + G. That will open the Microsoft Visual Basic for Applications window.

3. On the Immediate Window run this command (to run it just time the command and press Enter): DoCmd.RunCommand acCmdWorkgroupAdministrator

4. Once you run this command you will see a dialog with a title of Workgroup Administrator, press the Join Button

  

5. When you press the join Button a Dialog with Title Workgroup Information File will prompt Click Browse and find your System.mdw file and press OK. And press Ok on the Workgroup Administrator Dialog

6. Now close Access 2010

7. Open Windows explorer. Find your .mdb file and double click it. Access2010 will prompt for user/password and then will upgrade your database.

Getting ready for your certification tests

3. May 2012 10:58 by Mrojas in   //  Tags:   //   Comments (0)

Technology changes every day, and I consider that is part of my obligations as an Engineer to stay aware of the latest trends.

Some companies even demand that you should have certifications to backup your experience. Is not the same to say that you know WCF, as showing that have a certification my MS indicating that you at least know all the basics of WCF.

I have done some certifications in the past for MS and Sun (well now Oracle Java), and I want I have done is usually to research for documentation online or buy some books on the subjects of the certification exam. I have even bought guide books that prepare you for a certification test.

Recently the people from uCertify approached me and they let me evaluate one of their Certification PrepKits (at least that’s the way they call them).

Well this are my observations on the product.

The uCertifiy PrepKit is small application that you have to download to your computer. Once there is provides a personalized browser to an information portal.

You have to provide your email and license to be able to access your PrepKit. Once you do you will be presented with a page showing your current progress.

 

I think that must annoying thing about certification test is not knowing if you are ready or not (you do not want to pay for the test and do not pass it)

And the PrepKit is great for that. It provides a set of tests you can apply to yourself to verify your knowledge.

For example if you already know about the subject and what to know if you can pass a the test, give it a try to the diagnostic test:

 

 

All test in the prepkit provide some level of customization. So you can decide to take a quick 20 minute test of a longer 45 minute test.
Test mode is nice because sometimes you can feel very confident about a subject but during the test you miss some questions, so the test mode will leave you see which were the right answers.

I think is nice to start with the Diagnostic Test and then review a little about the subject. The prepkit provides study material. Just go to Notes\Study Notes and you will have access with several pages with information about the certification. This is very nice, because usually I have to look for a good page that provides information that I can use for a test. Certification test questions are very tricky they will ask about attribute combinations and configurations that you might not use very much so this notes can be a great help.

There are 4 predefined tests A, B, C and D and you can create your own test.

The best feature for me, is the ability to track your current progress.

 

Using the tests differs from buying a book or just using a web site, because they are more interactive.

 

You can write down your notes, you can make links to your info, and easily review your errors.

Conclusions

I had never used one of this PrepKits before, but they are a great experience. They are not cheap but I think they worth their price. Some years before I would have thought that I could just take my time and look for my own material on the web for my certifications, but now I’m a very busy professional, father and dog owner, so time is important for me, and keeping ahead in my career too. Thinks I would improve: better navigation, and little overhaul of the interface.

Customizing the Look and Feel or your Windows Forms Applications

27. April 2012 17:05 by Mrojas in Controls, VB6 Migration, WinForms  //  Tags: , , , , , ,   //   Comments (0)

Windows forms is still a great technology, but by default is not as flexible as XAML or HTML where you can very easily modify the style of your controls.

But that is not entirely true.

Let's review which options do we have for customizing the look and feel of Windows Forms Applications.

 

Custom Look And Feel

Well the idea is simple. Centralize all the settings for your components and make sure to invoke that logic just after the initializeComponent() method call on the Windows Form constructor.

I will implement a very simple example:

First the class the implements the "theming logic":

using System.Windows.Forms;
using System.Drawing;
public class ApplicationLookAndFeel
{
	static void ApplyTheme(TextBox c)
	{
		c.Font = new Font("Arial",12.0f); c.BackColor=Color.Blue; c.ForeColor = Color.White;
	}
	static void ApplyTheme(Label c)
	{
		c.Font = new Font("Arial", 12.0f); c.BackColor = Color.Black; c.ForeColor = Color.White;
	}
	static void ApplyTheme(Form c)
	{
		c.Font = new Font("Arial", 12.0f); c.BackColor = Color.Black; c.ForeColor = Color.White; 
	}
	
	public static void UseTheme(Form form)
	{
		ApplyTheme(form);
		foreach (var c in form.Controls)
		{
			switch(c.GetType().ToString())
			{
				case "System.Windows.Forms.TextBox":
					ApplyTheme((TextBox)c);
					break;
				case "System.Windows.Forms.Label":
					ApplyTheme((Label)c);
					break;


			}
		}
	}
}
As you see is just very simple code that will just update the settings for all controls, and a simple call in all form constructors and your done:
public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
			ApplicationLookAndFeel.UseTheme(this);
		}
	}
A form like:
 

 

This approach is simple, but could require a lot of work if you have a lot of components, and switching to another look and feel will require a lot of changes, and it does not allow you to customize all of the form.

Customization of non client are (title bar, borders, requires a little more work). You can take a look at Szymon Kobalczyk work in codeplex. There is a lot of information about a setting custom borders for your forms and even a start of a form styling library. 

 

Styling Controls

There are some third-parties that provide some level of Theming/Styling. The main difference is the impact they have on existing applications. I categorize them a Little Changes/Big Changes

 

Little Changes

Visual Styler.NET from http://www.skin-soft.co.uk/

This is an interesting solution, because it allows you to style your Standard Windows Form controls, with very little changes. You just add a control on you main form and that all.  They provide some custom styles and you can built your own. They support styling of ThirdParty Controls but I am not sure how that will work.

 

 

For screen shots and details see: http://www.skin-soft.co.uk/Products/VisualStyler/Overview.aspx

 

More Changes

Telerik Visual Style Builder http://www.telerik.com/products/winforms/visual-style-builder.aspx

 

 

 

DevExpress WinForms Skins http://www.devexpress.com/Products/NET/Controls/WinForms/Skins/

 

 

Infragistics Application Styling http://www.infragistics.com/resources/application-styling.aspx#ApplicationStyling

 

 

I call this "more changes" because all of them are great styling components but in order to style your application you have to use THEIR components. That is change all your TextBox for RadTextBox in the case of Telerik, Button for RadButton, or change your Label for WinLabel and your Button for WinButton for Infragistics and TextEdit for DevExpress...

So it can be a lot of changes. The end result can be stunning, because all of these companies have very very good components, but it is a lot of changes and can affect your application.

 

 But as you can see, Windows Forms still has a lot to offer

Share Code between Silverlight, Winforms and even Metro: Portable Library Tools

Maybe you faced the situation where you had code that was to be used on your server side services and also on your silverlight clients. 
Having this situation required some tricks because Silverlight Class libraries could not be used on .NET projects and viceversa.
Common workarounds were to share files and use precompilation directive iack!!

Well VS 2011 has a concept called Portable Class Libraries which allow you to create class libraries that can be use in Windows Phone, Silverlight, .NET framework, etc.

And if you have VS 2010 you don't have to suffer. Just use the Portable Library Tools from from the VS Extensions and start sharing code (see this image form the VS Extensions site)

  

 

For more details about Portable Libraries check the MSDN documentation page: http://msdn.microsoft.com/en-us/library/gg597391.aspx

 

Change Apache Default Port

25. April 2012 15:12 by Mrojas in Apache  //  Tags: , , ,   //   Comments (0)

I was playing around with XAMPP trying out the OrangeHR open source application.

I installed XAMPP on a machine with an IIS 7 pointing to HTTP port 80. So when I tried to start apache, I encounter a conflict.

Modifying the Apache included with XAMPP to use another port is very easy. Go to the installation directory.

It usually is c:\xampp\

In c:\xampp\apache\conf look for file httpd.conf

Look for a line that says: Listen 80  and change it for the port you need. In my case Listen 78

Save the file. And restart apache and TA DA!!!

Customizing ToolStrip Items

2. April 2012 13:53 by Mrojas in WinForms  //  Tags: , , , , ,   //   Comments (0)

There are many types of ToolStrip<Control> classes.

But how can you create your own customized version. Let’s say you want a control that prefixes a label before your combo box?
Ok that is very simple, you just extend the ToolStripControlHost class

 

First we create our UserControl:
using System.Windows.Forms;

	public partial class ComboBoxWithLabel : UserControl
	{
		public ComboBoxWithLabel()
		{
			InitializeComponent();
		}

		public string LabelText
		{
			get {return label1.Text;}
			set {label1.Text = value;}
		}

		public ComboBox.ObjectCollection Items
		{
			get
			{
				return comboBox1.Items;
			}
		}
	}

	partial class ComboBoxWithLabel
	{
		/// <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 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.label1 = new System.Windows.Forms.Label();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Dock = System.Windows.Forms.DockStyle.Left;
			this.label1.Location = new System.Drawing.Point(0, 0);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(35, 13);
			this.label1.TabIndex = 0;
			this.label1.Text = "label1";
			// 
			// comboBox1
			// 
			this.comboBox1.Dock = System.Windows.Forms.DockStyle.Right;
			this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.comboBox1.FormattingEnabled = true;
			this.comboBox1.Location = new System.Drawing.Point(35, 0);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(134, 21);
			this.comboBox1.TabIndex = 1;
			// 
			// ComboBoxWithLabel
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.label1);
			this.Name = "ComboBoxWithLabel";
			this.Size = new System.Drawing.Size(169, 22);
			this.ResumeLayout(false);
			this.PerformLayout();

		}

		#endregion

		public System.Windows.Forms.Label label1;
		public System.Windows.Forms.ComboBox comboBox1;
	}
Next we just create an extension of the ToolStripControlHost
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms.Design;
using System.Windows.Forms;
using System.Drawing.Design;

[DefaultProperty("Items")]
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All)]
public class MyCustomComboBoxWithLabel : ToolStripControlHost
{
	public MyCustomComboBoxWithLabel()
		: base(new ComboBoxWithLabel())
	{
	}
	[Browsable(false)]
	public ComboBoxWithLabel ComboBoxWithLabel
	{
		get { return base.Control as ComboBoxWithLabel; }
	}
	

	[Browsable(true)]
	[DefaultValue(false)]
	public string LabelText
	{
		get { return ComboBoxWithLabel.LabelText; }
		set { ComboBoxWithLabel.LabelText = value; }
	}

	[Localizable(true)]
	[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
	[Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
	public System.Windows.Forms.ComboBox.ObjectCollection Items
	{
		get { return ComboBoxWithLabel.comboBox1.Items; }
		set {
			foreach (var item in value)
			{
				ComboBoxWithLabel.comboBox1.Items.Add(item);
			}
		}
	}
}
 
And Next ...
Well there is not next. You just used it :) And this is how it looks:

Migrating .NET applications to Windows CE

22. March 2012 12:05 by Mrojas in VB6 Migration, Windows CE, Windows Mobile  //  Tags: , , , ,   //   Comments (0)

If you have a .NET application and then find that you need to move your application or
part of it to a Handheld or mobile device based in Windows CE don't worry.

The .NET has what is called the .NET Compact Framework which is in general
.NET for mobile devices. However review some info before you start your development
because it is not necessary the same. 

 

Differences between .NET Framework and Compact Framework

The CF is great but... it is not the .NET Framework. There

are differences take a look at: http://msdn.microsoft.com/en-us/library/2weec7k5.aspx

 

Controls

For a list of .NET Compact Framework Controls

See: http://en.wikipedia.org/wiki/.NET_Compact_Framework_controls

 

Some nice Third Party .NET Framework Controls are:

  • http://beemobile4.net/products/ipack/controls
  • http://www.resco.net/developer/mobileformstoolkit/overview.aspx

Some useful links:

Need remoting in .NET well you should know that CF does not provide Remoting but there

is company that implements it:

http://gotcf.net/

 

You can also use DCOM

http://www.codeproject.com/Articles/13819/Bringing-DCOM-remoting-functionality-to-Windows-CE

 

And for BlueTooth

There are several aproaches for developing BlueTooth with .NET.

1)  Bluetooth programming with Windows Sockers. 

See: http://msdn2.microsoft.com/en-us/library/aa362928(VS.85).aspx

2)   Windows Embedded Source Tools for Bluetooth.  

See: http://www.microsoft.com/windowsembedded/en-us/develop/windows-embedded-ce-6-bluetooth-technology-source-tools.aspx

3)    3rd party solution, A nice library is:

See: http://inthehand.com/content/32feet.aspx

Windows Services in CE

See this post: http://bansky.net/blog/2008/04/services-for-windows-mobile-in-managed-code/ 

and the library is available here:

http://managedserviceswm.codeplex.com/



 

Sending Messages between EXE files

13. March 2012 10:37 by Mrojas in COM Interop, General, IPC, VB6 Migration  //  Tags: , , , ,   //   Comments (0)

Today someone asked what is a way to send messages between two .NET exes.

mmm Well. Interesting question. There are several approaches.

 

1. .NET Remoting

.NET remoting is not a new technology but is a core part of the

.NET framework and it's always available:

 

For an example see this code from: http://www.codeproject.com/Articles/62813/NET-Remoting-Events-Explained

 

2. Named Pipes

This is vb.net example: http://support.microsoft.com/kb/871044

 

3. WCF

WCF is a great option even if you have legacy VB6 code you can use the SOAP Client to communicate

with the service:

This link http://www.aspfree.com/c/a/VB.NET/Calling-a-Web-Service-using-VB6-with-SOAP-30/

shows an example calling a Coldfusion Service but use it as a base for calling 

a WCF service

You can also integrate WCF with COM+ http://msdn.microsoft.com/en-us/library/bb735856.aspx

 

4. Windows Messages

There is a nice project that wrap it all up for you so you can use this solution:

http://www.codeproject.com/Articles/17606/NET-Interprocess-Communication

 

 

Cannot uninstall Silverlight 4 and you want to install Silverlight 5

5. March 2012 14:50 by Mrojas in Silverlight  //  Tags: , , , , , ,   //   Comments (0)

I faced this problem recently. I tried and tried but I got different error messages for uninstall Silverlight 4 SDK and I needed to upgrade to Silverlight 5.

So after a lot of tears and suffering I came across the Microsoft Fix it.

http://support.microsoft.com/mats/Program_Install_and_Uninstall

 

I runned this program and indicated that I wanted to uninstall Microsoft Silverlight 4 SDK and it was like magic!

It checked the registry, and fixed it, and then uninstalled the MS Silvelight 4 SDK.

After that I just download the new installer run it and everything work! Isn’t it something J