Does CDialogBar support DDX?
Luca ENEA-SPILIMBERGO -- luca_esl@pointest.com Sunday, October 20, 1996 Environment: VC++ 4.0, NT3.51 The question is: does CDialogBar class support Dynamic Data Exchange??? -------------------------------------------------------------------------- Here's the fact: I've designed a dialog with dialog editor, created a class with Class Wizard and manually changed the base class from CDialog to CDialogBar (I had to change some other stuff in order to make it work). For reference there was a message on this list titled "Re: CDialogBar & ClassWizard" - Jim Lawsonw. (write me if you need it...) With class wizard, in Member Variable tab I saw no control IDs so I tried to add DDX manually: In my dialog I have a CTreeCtrl named IDC_TREE In MYDIALOGBAR.H I declared a variable CTreeCtrl m_tree; void CMyDialogBar::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMyDialogBar) DDX_Control(pDX, IDC_TREE, m_tree); //}}AFX_DATA_MAP } the problem is that whatever I do with my variable (set tree style, add items, ...) I can see no changes in my Tree Control. ------------------------------------------------------------------------------- My solution: Every time I need a reference to my tree control I use this code: ... m_pTree=(CTreeCtrl*)GetDlgItem(IDC_TREE); ... and then I use this pointer to do my work: for example: ... HTREEITEM hTempObj=m_pTree->InsertItem(&TreeItem); ... Is the only right solution??? Thanks. \\\|/// \\ - - // ( @ @ ) O-----------------------oOOo-(_)-oOOo--------------------O | Luca ENEA-SPILIMBERGO Via P.Neruda 4/A | | 20060 BUSSERO MI | | luca_esl@pointest.com Oooo ITALY | O------------------------oooO---( )--------------------O ( ) ) / \ ( (_/ \_)
Lars Martinsson -- lmn@kvaser.ada.agema.se Tuesday, October 22, 1996 I've manually added DDX support to a dialogbar and it worked just fine. In the DoDataExchange function I skipped the CDialog::DoDataExchange call since CDialogbar isn't based on CDialog. Before I could use a control member variable I had to call UpdateData(FALSE). Hope this helps. Lars Martinsson lmn@agema.se ---------- From: Luca ENEA-SPILIMBERGO[SMTP:luca_esl@pointest.com] Sent: den 20 oktober 1996 22:55 To: mfc-l@netcom.com Subject: Does CDialogBar support DDX? Environment: VC++ 4.0, NT3.51 The question is: does CDialogBar class support Dynamic Data Exchange??? -------------------------------------------------------------------------- Here's the fact: I've designed a dialog with dialog editor, created a class with Class Wizard and manually changed the base class from CDialog to CDialogBar (I had to change some other stuff in order to make it work). For reference there was a message on this list titled "Re: CDialogBar & ClassWizard" - Jim Lawsonw. (write me if you need it...) With class wizard, in Member Variable tab I saw no control IDs so I tried to add DDX manually: In my dialog I have a CTreeCtrl named IDC_TREE In MYDIALOGBAR.H I declared a variable CTreeCtrl m_tree; void CMyDialogBar::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMyDialogBar) DDX_Control(pDX, IDC_TREE, m_tree); //}}AFX_DATA_MAP } the problem is that whatever I do with my variable (set tree style, add items, ...) I can see no changes in my Tree Control. ------------------------------------------------------------------------------- My solution: Every time I need a reference to my tree control I use this code: ... m_pTree=(CTreeCtrl*)GetDlgItem(IDC_TREE); ... and then I use this pointer to do my work: for example: ... HTREEITEM hTempObj=m_pTree->InsertItem(&TreeItem); ... Is the only right solution??? Thanks. \\\|/// \\ - - // ( @ @ ) O-----------------------oOOo-(_)-oOOo--------------------O | Luca ENEA-SPILIMBERGO Via P.Neruda 4/A | | 20060 BUSSERO MI | | luca_esl@pointest.com Oooo ITALY | O------------------------oooO---( )--------------------O ( ) ) / \ ( (_/ \_)
Niels Ull Jacobsen -- nuj@kruger.dk Tuesday, October 22, 1996 [Mini-digest: 2 responses] >>> Luca ENEA-SPILIMBERGO20-10-96 22.55 >>> >Environment: VC++ 4.0, NT3.51 >The question is: does CDialogBar class support Dynamic Data >Exchange??? Yes. Every window supports it - there's no magic involved. You just call UpdateData() to perform the DDX. This is done by the default implementation of CDialog::OnInitDialog - unfortunately, it *isn't* called by CDialogBar. But just add a WM_INITDIALOG handler and call it yourself - it should work. Actually, you can call at any time, after the controls have been created. Actually, DDX_Control doesn't do much. The main advatnage of DDX is that it can be handled by ClassWizard. In your case, it might be simpler to forget about DDX and just do HWND hTree = ::GetDlgItem(GetSafeHWnd(),IDC_TREE); VERIFY(m_tree.SubclassWindow(hTree)); unless you're planning on using other DDX facilities. By the way, don't put your own code inside the ClassWizard delimiter comments - ClassWizard may mangle them later. And they are just comments - they don't do anyhting magic other than tell ClassWizard that it can modify the code between them. -------------------------------------------------------------------------- Here's the fact: I've designed a dialog with dialog editor, created a class with Class Wizard and manually changed the base class from CDialog to CDialogBar (I had to change some other stuff in order to make it work). For reference there was a message on this list titled "Re: CDialogBar & ClassWizard" - Jim Lawsonw. (write me if you need it...) With class wizard, in Member Variable tab I saw no control IDs so I tried to add DDX manually: In my dialog I have a CTreeCtrl named IDC_TREE In MYDIALOGBAR.H I declared a variable CTreeCtrl m_tree; void CMyDialogBar::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMyDialogBar) DDX_Control(pDX, IDC_TREE, m_tree); //}}AFX_DATA_MAP } the problem is that whatever I do with my variable (set tree style, add items, ...) I can see no changes in my Tree Control. ------------------------------------------------------------------------------- My solution: Every time I need a reference to my tree control I use this code: ... m_pTree=(CTreeCtrl*)GetDlgItem(IDC_TREE); ... and then I use this pointer to do my work: for example: ... HTREEITEM hTempObj=m_pTree->InsertItem(&TreeItem); ... Is the only right solution??? Thanks. \\\|/// \\ - - // ( @ @ ) O-----------------------oOOo-(_)-oOOo--------------------O | Luca ENEA-SPILIMBERGO Via P.Neruda 4/A | | 20060 BUSSERO MI | | luca_esl@pointest.com Oooo ITALY | O------------------------oooO---( )--------------------O ( ) ) / \ ( (_/ \_) -----From: Kyle Herbert Luca, "Is it the only right solution?" This I cannot say :) However, in my own application (in which I also manually changed a CDialog into a CDialogBar containing a tree control) I am using the very same methodology and it works fine. During my research I found no simpler solution. I'll be anxiously watching for replies to your posting to see if there is indeed a more elegant solution. Kyle Herbert CK Engineering kyleh@ckeng.com http://www.ckeng.com
| Вернуться в корень Архива |