Virtual Developer Workshop: Containerized Development with Docker
This small example is for the beginner who wants to create an ActiveX control by superclassing the windows common control using ATL 3.0. If you don't have VC6, you need to install OLE DB1.1 from VC5 for this project to work properly.
On this site, a lot of excellent examples about tree controls are already there so why this example? Because:
- My tree control create by using ATL instead of MFC
- Using OLD DB to save tree structure and load it back
- Right click to open popup menu and more...
Open Access database and create a table, and name it any name as you like. Create four fields in the table with the names as follow:
- ITEM_NODE ( int )
- ITEM_NAME ( text )
- INDENT_LEVEL ( int )
- ITEM_DATA ( long ) [ primary key ]
if you want to create some bogus data, go head and do it, otherwise the example will create default data for you. If you don't want to use any database at all, two things you need to do:
- Open your project, click on FileView tab, remove the file name: Tree.h
- Open MyTreeControl.h, go to the method name " OnDestroy() " and comment out the line: " this->SaveTree(); ", after all select Build on the menu and select Rebuild All.
When the project is running, the first thing you need to do is select " Microsoft Jet 3.51 OLE DB Provider ( if you have another OLE DB Provider on your system, go head and select it. ", second is select your data source. If you don't have any data in your table yet, just click cancel when the dialog asking you to select a driver and you will have the default data which I created for you.
To test this control, You can select the ActiveX Control test container to test it or you can create a new MFC project with Dialog base. When the project is completely constructed, click on Resource View, open Dialog resource, right click on dialog and select insert ActiveX control..., that is all you need to do. If you have any question about this project or you do not understand some line of codes, please post your comment and I will try to answer as soon as possible but within my knowledge, because I just have 2 year experience on Visual C. I hope you can understand my example and can apply part of it in your project in the future.