Modeless dialog problem
-
HI all; I am building an SDI application which has a dockable CDialogBar containing tabs and listControls etc... However,this CDialogBar is modeless. I need to access the list control and dynamically remove or add items to them. The problem is that i just don't know how to access the variable of listcontrol in a modeless dialog. I have tried many methods but it keeps giving me assertion errors since the pointer to the modeless dialog is lost. Could anybody please help me, i badly need this and i need to present this application for my final year project next week. Thank you; Krugger
-
HI all; I am building an SDI application which has a dockable CDialogBar containing tabs and listControls etc... However,this CDialogBar is modeless. I need to access the list control and dynamically remove or add items to them. The problem is that i just don't know how to access the variable of listcontrol in a modeless dialog. I have tried many methods but it keeps giving me assertion errors since the pointer to the modeless dialog is lost. Could anybody please help me, i badly need this and i need to present this application for my final year project next week. Thank you; Krugger
im not much into MFC, but i think this can solve the problem: i assume you are loosing the pointer to the dialog cause you are creating the object inside some function, therefore when the function exits, the pointer is no longer valid (a code sample would have helped). make the pointer a member variable of the class where you want to manipulate the dialog (like CMainFrame), and then you can safely call its members. EG: class CMainFrame { CMyDialogBar* m_pBar; int OnCreate() { m_pBar=new CMyDialogBar; m_pBar->Create(); } void Whatever() { if(m_pBar!=NULL) { // you can access its public member here } } }; this is of course only "sample" code, but should give you an idea of how to do it. HTH