Building the Right Environment to Support AI, Machine Learning and Deep Learning
CFloatingDialog is a CDialog-derived class that I used to create the sliding effect of the dialog. There are already some classes available for this purpose, but most of the classes are for modal dialogs and not exactly what I was looking for.
Dialogs with different controls are used to capture the data, but when the volume of data is very great, different dialogs that contain the logical related set of data/controls are used. What I tried to do is: When the user completes one dialog, he is given a button for next or back, and rather then showing the next dialog at once, the current dialog will slide towards any direction (Left, Right, Top, Down) and can also slide back toward the center.
How To Use CFloatingDialog
- Create a dialog-based MFC project.
- Add CFloatingDialog.h and CFloatingDialog.cpp to your project.
- Create a dialog template; select "Child" for the style and "None" for borders from Style tab.
- Place whatever controls you want on your dialog resource.
- Simply by double-clicking the dialog template, the new class window will appear. Put any name for your class and derive it from CDialog. Yes, from CDialog at the moment.
- Now, go to your new dialog class and replace CDialog with CFloatingDialog. You'll have to replace it at the start of the class where it will derive publically from CDialog. Beside that, at the body of the ctor, you'll have to replace CDialog() with CFloatingDialog() and finally in the message map. Don't forget to put
#include "FloatingDialog.h"at the top of your dialog class.
- The file wi_header.h contains some enums and a define. If you don't want to use that file, you can place the entries at the beginning of the class.
- Place a CStatic at the main dialog and name it IDC_PLACE_HOLDER. This will be used as parent of the dialog and also the reference of the displacement will be measured from the Rect of this place holder.
- Now, create a member variable of dialog (that you derived from CFloatingDialog) for the main dialog. Let's call it "CFirstDialog m_oDlg1;"
- Place the following lines in OnInitDialog():
m_oDlg1.Create(IDD_DIALOG1 , GetDlgItem(IDC_PLACE_HOLDER)); m_oDlg1.ShowWindow(SW_SHOW);
- Now, use the DisplaceDialog(...) function with different enum values to slide in different directions.
Similarly, you can put more then one dialog as the member of the main dialog and create them similarly and at different occasions. You can call them in different sequences, giving the user the feel that certain parts of the dialog (mainly concerned with data I/O) are sliding.
The usage of CFloatingDialog is pretty easy. All you need to do is just inherit your class from it, rather then CDialog. You can work without any hassle of doing changes, except when changing the dialog style and border style, and putting in the placeholder where you want your dialog to be displayed.