Adding MFC to ATL
-
Hi! I created an ATL project and checked "Support MFC" in the ATL COM AppWizard. Then, I added some code to create a CTreeCtrl object. I had to #include afxcmn.h to compile the project(because of the CTreeCtrl). The problem is, I'm getting debug assertion failures inside CTreeCtrl::Create because the AfxGetInstanceHandle() returns NULL. Should I be able to use CTreeCtrl(and other common controls) inside an ATL project?
-
Hi! I created an ATL project and checked "Support MFC" in the ATL COM AppWizard. Then, I added some code to create a CTreeCtrl object. I had to #include afxcmn.h to compile the project(because of the CTreeCtrl). The problem is, I'm getting debug assertion failures inside CTreeCtrl::Create because the AfxGetInstanceHandle() returns NULL. Should I be able to use CTreeCtrl(and other common controls) inside an ATL project?
You don't have to use "Support MFC" in an ATL-project when you want to use the TreeCtrl. Check my website www.braem17.yucom.be (ATL - SAWEditListCtrl). It gives you an example of how you can use common controls in ATL.
-
Hi! I created an ATL project and checked "Support MFC" in the ATL COM AppWizard. Then, I added some code to create a CTreeCtrl object. I had to #include afxcmn.h to compile the project(because of the CTreeCtrl). The problem is, I'm getting debug assertion failures inside CTreeCtrl::Create because the AfxGetInstanceHandle() returns NULL. Should I be able to use CTreeCtrl(and other common controls) inside an ATL project?
-
Hi! I created an ATL project and checked "Support MFC" in the ATL COM AppWizard. Then, I added some code to create a CTreeCtrl object. I had to #include afxcmn.h to compile the project(because of the CTreeCtrl). The problem is, I'm getting debug assertion failures inside CTreeCtrl::Create because the AfxGetInstanceHandle() returns NULL. Should I be able to use CTreeCtrl(and other common controls) inside an ATL project?
I bet you're doing your CTreeCtrl stuff in an exported function or COM method, right? You need to add this line at the very beginning of the function/method: AFX_MANAGE_STATE(AfxGetStaticModuleState()); This sets up some internal data structures so all the MFC code knows where to find resources and other stuff.