Class Structure
I have encapsulated a framework program with a fixed and reliable data flow. developers can easily complete the design of subdialog tabs by writing several simple framework attributes, you do not need to manually manage changes to the object list or switch tabs. You can add various controls as you would in the normal dialog box. Data exchange can also be achieved through the frame, Doc, and three view pointers in the base class without manual assignment.
Two base classes:
Class meshpropertybase {cpiframe * m_ppiframe; cmodelview * m_pmodelview; cpatview * m_ppatview; clayoutview * m_playoutview; cpidoc * m_ppidoc; // These pointers can be used to call data in the program, however, the constructor is uncertain. In oninitdialog (), the first step is to determine these values int meshid; // The idstring m_strname of the selected mesh; // The title virtual void getdata () on the tab; // virtual void initdata (INT m_meshnum) is called each time an object is replaced; // This is called each time an object list is updated, prepare the internal data structure size virtual void updateviews (); // call render () uint m_nidtemplate of various views; // remember your own window ID template} class meshpropertysecondbase: Public meshpropertybase, public cdialog
Attribute Panel Type
Class meshpropertydlg: Public cdialogbar, public meshpropertybase {...... public: vector <meshpropertysecondbase *> m_meshdlgs; // set of mesh object tab pointers vector <strong *> m_scenedlgs; // you need to add the code about your own dialog box m_meshpm; m_meshpt; meshpropertylightset m_scenel; meshpropertyshaderset m_scenes; // This is an instance of the four subdialog classes ......}
Example of a subdialog box:
class MeshPropertyTextureSet : public MeshPropertySecondBase
2. How to compile a subdialog box
Add the MFC class and select cdialog as the base class to add a dialog box. 122x266 in width. In the attribute, border is set to none, style is set to child, and must be set to child.
Add in. h file
#include "MeshPropertyBase.h"
Add
#include "ModelView.h"#include "PatView.h"#include "PIDoc.h"
Change the base class cdialog to meshpropertysecondbase.
Change: cdialog (meshpropertytextureset: IDD, pparent) in the constructor to meshpropertysecondbase (meshpropertytextureset: IDD, pparent)
Add the title of the tab in the constructor
M_strname = "texture ";
Implement two virtual functions. If you do not need them
Virtual void getdata (); // virtual void initdata (INT m_meshnum) is added each time an object is replaced; // the size of the internal data structure is prepared each time an object list is updated, m_meshnum is the total number of Mesh
The work in properties panel meshpropertydlg is as follows:
. H file class declaration add subdialog box instance
MeshPropertyTextureSet m_MeshPT;
In the. cpp file, add the Sub-Dialog Box pointer to the pointer set in the constructor to automatically call the background program.
M_meshdlgs.push_back (& m_meshpt); // if it is a mesh object tab m_scenedlgs.push_back (& m_scenes); // if it is a scene object Tab