MFC GUI
This sample shows how to bind the Microsoft Foundation Class (MFC) graphical user interface (GUI) with KINGSTAR Win32 API functions, which are almost the same as KINGSTAR RT APIs. Because this sample centers on the link between the MFC GUI and the KINGSTAR functions, it demonstrates only the basic features.
Compile the sample
The sample file is located at C:\Users\Public\Public Documents\IntervalZero\KINGSTAR SDK\<Version Number>\Samples\GUI\MFC_GUI
. Open MFC_GUI.sln and compile it.
NOTE: File Explorer has two paths: the hierarchy path and full path. The hierarchy path is shown in the address bar. The full path is shown in <File Name> Properties—if you right-click MFC_GUI.sln
and click Properties, you'll see the Location is C:\Users\Public\Documents\IntervalZero\KINGSTAR SDK\<Version Number>\Samples\GUI\MFC_GUI
, which is the full path. Notice that in the hierarchy path it is Public Documents
. If you are using a non-English Windows system, and you want to copy and paste the path to the address bar to find the sample quickly, you must use the full path. If you want to browse to the sample folder through clicks, use the hierarchy path. For English Windows, folder redirection is done automatically. Even if you paste the hierarchy path, File Explorer can lead you to the sample.
![]() |
![]() |
The figure below shows the output of the sample:
Source code
The sample is a MFC application developed using C++ in Visual Studio 2019, and MFC 64-bit. When developing your own applications, you can choose your own development environment, as long as the application is 64-bit. The use of 64-bit is required to control the real-time Subsystem.
The main source code is contained in the following files:
- MFC_GUIDlg.h: contains the declarations of the MFC controls in the layout.
- MFC_GUIDlg.cpp: determines how the MFC controls works. The KINGSTAR functions are written in this file.
Link the KINGSTAR functions to the MFC GUI
Before you start writing code, you should have built an MFC GUI. The layout of the GUI can be customized to meet your needs. In this sample, we use only the basic components to demonstrate how to link the KINGSTAR functions to the GUI.
- The Connect button
- The link status and progress bar
- The initialization settings
- The List Box: the device list
- The Edit Controls: the actual position, actual velocity, and command velocity
- The Enable button: enable the axis
- The Reset button: reset the alarm
- The Jog buttons: jog motion
- Closing the sample