Presenting the ClarionMetroWizard!

Topics Covered

Setting up

Some background

Classes

If a child class has the IMPLEMENTS attribute for an interface implemented above in it in the hierarchy, not all of the interface’s methods have to be overridden.

  • ce_TabList Class – Originally inspired I think by the office 2007 options window this class that I already had was a nice starting point for the metro wizard.
  • ce_MetroWizardForm Class – Finally the class that does the rest of the work!

Live Demo

  • Compile the project APP and look at some of the features
  • Implement in School.app (if there is time)
    • Delete the SCHOOL004.clw from the solution
    • Compile and make sure it all looks normal.
    • Use the Students form as an example
    • Copy the required files into the school.app directory
      • _classes
      • resources
      • Clarion80.red
    • Global embeds, After Global Includes
      • Include(‘ce_MetroWizardForm.inc’),ONCE
    • UpdateStudents procedure
      • re-arrange the form to work with the metro class
      • Enlarge the window and sheet
      • Shift all controls to the right and down a bit
      • Set Sheet tab location to left with a width of 100 or so.
      • Add Tab display prompts: ?PromptTabHeader, ?PromptTabDetail (make sure to set their tab order!)
      • Set some PROP:Tip text on the tabs
      • Set form background to COLOR:White
      • Add MetroForm class and Init http://fushnisoft.github.com/ClarionMetroWizard/ce_MetroWizardForm.html#init
  • Demo of Trips2012 application that is using these wizard (and more!)

Bonus Features

 

Hopefully there is time to go through everything. The classes are pretty hacked together but they do what I need for now 🙂

 

-brahn

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!

I had been using the C# Project Template for Unmanaged Exports quite a lot and while upgrading a project to VS 2012 I noticed that it is now available as a nuget package. There is only one catch… make sure your project has a specific CPU target set. It took me a little while to work that one out, otherwise the nuget package works perfectly. Go get it and start integrating .NET with your Clarion projects now!! Smile

This is a topic that comes up on the newsgroups from time to time. A while back, more than 6 years back IIRC, I spent some time researching and testing the different scenarios for a project I was involved in. I will attempt to summarise the finding here with a few additional comments picked up in NG threads along the way.

Update 21 Sept 2012: I have just tested with Clarion 8.0.9304 and it looks like it uses the new Native Client just fine. This is what is shown in the trace log:

Some terms:

Clarion MSSQL Accelerator driver – C60MSS.DLL or more recently, ClaMSS.dll  \

ODBC SQL Server Driver – This is what Trace.exe reports when you have no SQL Native Client installed. There is likely a more technical explanation for the name but it doesn’t really matter. This is what Clarion will do when there is not other choice. The default…

SQL Native Client – “…contains the SQL Server ODBC driver and the SQL Server OLE DB provider in one native dynamic link library (DLL) supporting applications using native-code APIs (ODBC, OLE DB and ADO) to Microsoft SQL Server.” – source

I have not personally taken any serious benchmarks of using the ODBC driver or the Native client. My general impression is that it seems you get a faster experience with the Native Client and others have reported significant differences, especially when connecting to a remote server. Also, if you want your application to use MARS support introduced in Clarion6 (6.3 I think) then you must have the Native Client installed or you will likely see BUSYHANDLING errors very soon.

Getting it right

For an application compiled with Clarion6 you must