A while back I posted a short video of the Booking Wizard I was working on for a client (follow the link for some of the original screenshots, twitter announcements, etc).

Finally there has been the time and the need to make this into a class. The code is up on GitHub and as soon as I post this article I have to start actually implementing the class into the real project so you probably wont see me for a few days 🙂

I would love to hear what you think and what you end up doing with the code. Feel free to fork the project and contribute back any changes you make too…

Design Time View Run time view!

Built in themesOther features

 

Go take a look at the ClarionMetroWizard GitHub Repo !

Oh, and for the impatient.. try the pre-compiled demo!

Something about LibMaker I forgot to mention.
The libmaker source that ships with Clarion has a couple of problems with “Unmanaged Exports” DLLs. It only works with short filenames and it prefixes the labels with a “\”. These can be easily fixed in the source of LibMaker but I have created a compiled fixed version that should do the job.
Alternatively use the LoadLibrary API to dynamically load the DLL http://www.clarionmag.com/search/find?searchTerm=author%3Asand+loadlib  (sub required).

What?

ClarionMag article –Mixing Clarion with .NET, Part 1

“To call any .NET procedure from Clarion, you have a few choices. You can expose any .NET class to COM, which makes it visible to any COM client. Once you’ve done that, you can either use Clarion’s OLE control or write some Clarion wrapper classes.” “You can also make a Managed C++ wrapper, which is stored inside your .NET assembly. You then call this wrapper the same way you would call an API function.”

Robert Giesecke – C# Project Template for Unmanaged ExportsVisual Studio C# Project Template to “export managed code to native applications without the need of COM registrations”

And finally, a similar technique using Clarion# – http://clarionsharp.com/blog/2011/05/clarion-net-update-2/

Why?

Using .net allows you to tap into the vast amount of examples and libraries available in the .net world to help you create solutions. There is significantly less need to try and take a C++ or C# example and translate it to clarion code and API calls when you can just wrap up the functionality you need in .net and call it from clarion.

Unless you need to embed .net user controls in a clarion window I cannot see any reason not to use the DLLExport technique. It has the advantage that you don’t need to register the .net assembly using regasm.exe and is likely much faster to execute.

Color picker example

This example uses the Zeta Color Editor from an article on The Code Project website. The same editor is used in my InsertClarionColor addin.

ColorPicker.zip – Clarion 8 and Visual studio C# solutions. (one day I will move it to GitHub!)

  1. Create a C# project using the Unmanaged Exports template in visual studio
  2. Export a method that can be called by clarion which handles the calling of the editor dialog
  3. Create a clarion friendly lib file from the .net dll
  4. Create a clarion project to use the dll!

How to Enable Code Snippets

Add .appclw and .APPCLW (no “*” in front of it) to the list in the Code Snippets setup. This tells the IDE to show snippets in the code completion list for the embed editor and the embeditor.

In my IDE I have this set of extensions for Clarion snippets:

How to Enable Code Snippets

Using Code Snippets

I was playing with this technique a lot over the past few weeks. There is a lot of work coming up to integrate clarion with .Net components and if there was a way to do so without having to register them using regasm before they could be used that would be really, really awesome.

See the thread “COM Gurus – Need some help & advice” on comp.lang.clarion newsgroup for some further discussion.

Long story short, I was able to get it partly working. With the right manifest you can use a COM object from clarion just fine without registration. Unfortunately this does not extend to placing user controls in a Clarion OLE control which is pretty much all I was after.

Clarion calling .Net COM reg-free!

 

All is not lost, I think there are still a few ways this could be achieved but for now I have had to shelve the project in deference to more financially immediate concerns… such as you know, paid work Smile

See the repo I created on GitHub for an example project, more information and some links to where I think it could go next – https://github.com/fushnisoft/ClarionRegFreeCOM

-brahn

 

Ok, so before you ask why on earth would you bother let me explain 🙂

As part of my work over at ClarionAddins I am always looking for way to improve the user experience as well as stretching my knowledge of .Net programming. I thought it might be nice to use WPF but since the Clarion IDE is targeting v2.0 of the .Net framework this is not so easy. Hence this example!

Of course there are many resources out there related to this topic, see below, but nothing I could discover specific to v2.0 so for me it took a little work to get there. I learnt a lot about reflection along the way!

This code assumes that the v3.5 Framework is installed on the target machine. For production it would of course be necessary to test for this and react accordingly.

Here is a screenshot of this technique being used in an addin I am working on:

WPF UserControl in an Addin Pad!

-brahn