So far, we have created project files individually, and have not linked these files to a VisualStudio project. In this way, we cannot take advantage of the powerful syntax intelligence of VS. The following will create an empty VS project manually, and then add these files to the project in categories.
1. Select File > New > Project in VS to create a new VC ++ empty project. As shown below:
Note: Observe the selections in the red boxes in the figure above. The Location column is the location of the HelloWorld folder. Do not select the Create directory for solution because our folder already exists.
2. Add the existing files HelloWorld.cpp, HelloWorld.r, and HelloWorldCmd.r, HelloWorld.mke to the source file, resource file, and the entire project, respectively. The adding method is of course achieved by right-clicking the corresponding folder in the VS project and selecting Add > Existing Item.
The file you want to edit in the future, double-click the file directly in VS to edit it. Of course, before returning to the command prompt to generate the project, please remember to press Ctrl + S to save the entire project. After creating the VS project, there will be a few more files in the HelloWorld folder, which are roughly described as follows:
|
3. Right-click the HelloWorld project and select Properties from the pop-up menu to open the project properties dialog box. Add the VC ++ include file path to the project as shown below.
Note: This step is to add a new path instead of replacing the original $(IncludePath).The final setting result should be: C:\Program Files\Bentley\MicroStationCONNECTSDK\include; $(IncludePath).After this addition, the HelloWorld project will support VS's IntelliSense.This will greatly increase our programming efficiency.
4. To debug the project, return to the command prompt and type bmake -a -ddebug
to perform a rebuild with debugging information. -a means all, which is similar to executing Rebuild in VS, and -d means define, followed by debug without spaces. The generated pdb(program database) file will contain debugging information.
5. Open the cpp file in VS, find the MdlMain function, then set a breakpoint at the line g_1mu = pInfo-> GetUorPerStorage ();
6. In VS, select the menu Debug > Attach to Process to open the Attach to process dialog box, and then find the microstation.exe process in the Attachable Process as shown in the figure below and click the Attach button to connect. Note that if MSCE has not been started, the microstation.exe process will not be found. At this time, MSCE can be started first. Another point is that Attach to must be set to Native code, which is the way to debug C++.
7. Switch to MSCE, type MDL LOAD HelloWorld and press Enter. At this point, you should be able to automatically activate VS and stay at the breakpoint.
8. Move the cursor to pInfo and you should see its value. The detailed VS debugging technology is beyond the scope of this book. Readers who are not familiar with VS debugging technology can check Microsoft's MSDN documentation or related books to learn.
Prev:[[Adding commands to MDL applications]] | Next:[[Implementing Interactive tools using DgnTools Class]] |