We wrote this solution in response to a question posed on the Be Community Forums. MicroStation provides between one and eight view windows that are the primary interface between a user and the CAD tool. Usually, a view window's title is something like View 1: Top View. However, an application may want to append text to the standard caption, or perhaps replace it entirely.
Q How do I append text to a MicroStation view window's title bar?
In the good old days you could call
mdlWindow_titleSet (mdlWindow_viewWindowGet (viewIndex).
But with MicroStation V8i life is more difficult, and we have to use other techniques.
Those other techniques involve the MicroStationAPI.
The reason for the change is that MicroStation has become more sophisticated. A view window, in the V8i era, is dynamic — no longer is it a simple static view of a DGN model. Hence, it no longer has a static caption. Using the above MDL code with V8i changes the caption, but the change is not persistent.
The C++ MicroStationAPI provides the solution we want for MicroStation CONNECT and MicroStation V8i.
There are various public interfaces, including those relevant to this solution:
IViewMonitor lets us override view callback methods with our own implementation;
IViewManager lets us inform MicroStation that a view has changed because we have modified its title.
For this solution, our class
MyViewMonitor inherits from
IViewMonitor is an abstract class with several virtual callback methods.
We're interested in only one of those methods …
virtual void IViewMonitor::_OnGetViewTitle (IViewportP vp, WStringR title);
Our class method provides a custom implementation of that method.
We determine the view number of the
Viewport and append our text to its current title.
The current title is usually the default caption (e.g. View 3 - Front).
It's our decision, in this example, to append text to the current title:
you could replace the title completely if required.
mdl load SetViewTitle in MicroStation's keyin window.
Commands available include …
VIEWTITLE SETview index "suffix text"
VIEWTITLE RESETview index
SetViewTitle stores up to eight suffix strings, one for each MicroStation view. You can set and reset each suffix independently.
We assume that you are using the MicroStation development environment to build this project. Consult the Software Development Kit (SDK) help for more information, or take a look at our guide to setting up Windows to build MicroStation applications.
As with any MicroStation application built for native code, the result is in two parts:
SetViewTitle.ma contains only resource data: in this case, the information MicroStation requires to load the DLL,
and a command table.
SetViewTitle.dll is the implementation file.
When a user types
mdl load SetViewTitle MicroStation first loads
and finds the resource directive (the
SetViewTitle.r) that instructs it to load a DLL,
then it loads
Download the SetViewTitle project.
This ZIP file contains C++ source code header and implementation files, and a bmake (
.mke) file to build the project.
Check the version of Visual Studio you need to build this project. We built this project for MicroStation V8i and have not modified it for MicroStation CONNECT.