In the previous MFC Article, we examined how the Mapping Modes works while performing the drawing operation. In this example, we will see how we set the custom mapping modes. Our goal is below:
1) Set mapping mode so that the horizontal logical unit is 1 Centimeter (cm). Simply, 1 Unit = 1 cm in X axis.
2) Also, 1 Unit = 1 cm in Y Axis.
3) Positive X is towards left.
4) Positive Y is going Upwards.
5) The Drawing origin should be in screen center.
We can achieve the above goal by using the Custom Mapping mode MM_ISOTROPIC.
MFC supports two kinds of coordinate systems. One is Device Coordinate and the other one is Logical Coordinate. In device coordinate, we point out all in terms of pixels. In logical coordinate, we measure each unit in terms of Metric Standard or British Standard. How each unit maps to the logical measure is called the mapping. We can mention the mapping using the Mapping Modes. In MFC, having the knowledge of Drawing Origin is the key to draw in the Client Area the way you want.
In this Example, we will walk through the examples and demo videos, which will help us in learning the Mapping Modes and doing the MFC drawing using the device contexts. We will also try the ViewPort Origin and Window Origin and how to use them while drawing using MFC GDI APIs.
In this article, we will see how we play an AVI video file in MFC Application. To play the AVI file, we will use the Media Control Interface (MCI) function and its API function MCIWndCreate. The Animate control that ships with MFC can play the AVI files, but you will not get any sound when the video is playing. OK. Let us start with this simple and quick example that plays the video file comp.avi. The AVI file that I am packing with this example has no sound information, so replace that with any video file, which has sound information in it. Note, we call the MCIWndCreate API from the MCI interface embedded into the MFC dialog.
In this example, we will see how to create and use MFC DialogBar Control. The DialogBar acts like a toolbar. Unlike toolbar, a dialog bar can have controls which we can place in it treating it as dialog. One can dock the DialogBar like a toolbar. To better visualize it, we can think of a tool bar with a radio button, a checkbox and a combo box in it. What we just now imagined can be easily achieved through a DialogBar control.
In this example we will design an MFC DialogBar, then we will place that in a Rebar Control so that we can dock it on the Main Frame window of the SDI application.
Our example is a Single Document Interface (SDI) application, which shows six toolbar buttons in two ToolBars. These two ToolBars are hosted by the Rebar Control. Placing the ToolBar on the Rebar allows the user to move the toolbar over the Rebar Control using the Gripper. Using the grippers, we can also place a toolbar in separate rows. Let us start building this example.