MicroStationAPI
  • Programming Tips
  • Programming Examples
C++, MicroStationAPI

Common Questions about MicroStation Development
Q This system seems way over complicated A C++ development in general is a complex affair, but it delivers substantial benefits
Q How does Visual Studio help create a MicroStation application? A Visual Studio is a powerful and flexible programmer's development environment your DLL.
Q What version of Visual Studio should I use to create a MicroStation application? A The version of Visual Studio you should use depends on the version of MicroStation
Q How do I add Visual Studio switches in my bmake file? A The Bentley include files (*.mki files) provide the right default switches for the Microsoft C++ compiler and resource compiler
Q How does BMake help create a MicroStation application? A BMake is a powerful build tool. It is a particularly good implementation of a make tool
Q What is MFC? A The Microsoft Foundation Classes come with Visual Studio. They make it easier to build applications that work well with Microsoft Windows. MFC is an optional component of Visual Studio 2015 and later
Q What is a pre-compiled header? A pre-compiled headers come with most C++ compilers. They accelerate application development time
Q What is a DllMdlApp? A A DllMdlAp connects MicroStation with your DLL. It contains data that tell MicroStation what DLL to load when you key-in MDL LOAD MYAPP

Building a C++ Project with Visual Studio

When using Visual Studio, the environment implicitly adapts itself to your development platform. That is, various macros are defined that tell the compiler and linker that you are using, for example, a 32-bit processor with Windows 7 Pro. It's typical of C/C++ that many header files are introduced.

Visual Studio Versions

Use the right version of Visual Studio!

Visual Studio Switches

Your bmake file is a list of rule invocations. Each invocation of a make rule instructs a development tool to do something to one of your source files. Your Viz Studio project no doubt includes C++ source (*.cpp) files and resource (*.rc) files that must be compiled be the appropriate Microsoft compiler. The default switches for those compilers are specified in one or more of the make include (*.mki) files supplied with the MicroStation SDK.

Often, the defaults are fine. Occasionally, you may want to give an additional instruction to the compiler.

Microsoft Foundation Classes (MFC)

MFC is delivered with Visual Studio. From Visual Studio 2015 and later it is an optional component. MFC provides a huge number of classes that extend standard C++ on a Windows platform. When developing for MicroStation, one benefit is the provision of Windows forms and dialogs you can use in your application user interface.

Using MFC for some user interface components does not preclude the use of MicroStation dialogs. That is, your application can use both MFC dialogs and MicroStation dialogs.

MicroStation Dialogs versus MFC Dialogs

The two dialog idioms present different ways of designing a user interface (UI).

You design an MFC dialog using the design tools in Visual Studio. MicroStation dialogs lack an interactive designer and you must write the resource specification manually.

MicroStation dialogs are well-integrated with MicroStation. The MicroStation Dialog Manager makes it easy to use your program variables in a modal or modeless dialog. In fact, it's just as easy to make a modeless dialog as a modal dialog.

MFC dialogs provide a rich Microsoft user interface toolkit. However, they lack the elegant MicroStation Dialog Manager. Consequently, you have to write code that exchanges program variable data with dialog item data.

Pre-Compiled Headers

Pre-compiled headers help with projects big & small. They reduce compile time because the bulk of header files don't change and need to be compiled only once each in debug and release mode. Standard C++, MDL and the MicroStationAPI typically #include many header files. Each header file is crammed with #defines and further #include.

You would not introduce your own headers into a precompiled header because they will be changing frequently as your project progresses. If you abandon pre-compiled headers then you nonetheless need to #include somewhere the header files that StdAfx.h includes, and you need to define the macros that StdAfx.h #defines. Otherwise, the compiler won't know what platform you want to build. For example, if you see a message about Int64 being an undefined type, that means you haven't #included one of the standard header files.

By default, Visual Studio assumes you want to use a pre-compiled header. As you have found, you can turn off that capability. However, pre-compiled headers are generally a good thing (they are not a Microsoft invention but a widely used C++ idiom).

You can use pre-compiled headers with BMake.

Building an MDL Project with BMake

MicroStation DLL Resource

An MDL DLL needs DllMdlApp defined in a resource file. The DllMdlApp is data, not code. It is compiled using the MDL resource compiler and merged with other MDL resources (usually a command table) to create yourApp.ma. In other words, yourApp.ma is nothing more than a data file: when you MDL LOAD YourApp, MicroStation examines the resources in the .ma, finds the DllMdlApp and loads YourApp.DLL.

Whether you use BMake or Visual Studio, you need a resource file merged into YourApp.ma. When you build using BMake your make file (YourApp.mke) contains all the rules to build your executable code and the MDL resources. If you use Visual Studio to build your implementation DLL you still need to use BMake to compile your resources into YourApp.ma.