HELP! DoDataExchange is injured? 
Author Message
 HELP! DoDataExchange is injured?

I can't seem to communicate with the form view when changing control
status in anything, be it edit views, checkboxes or whatnot.
DoDataExchange is read once, at view creation, but once created there
is no communication.  I can capture the controls with ON_COMMAND().
I've been trying to fix this problem for a week, but apart from
forgetting CFormView::OnInitialUpdate(), I've had no progress.

The view is set in a splitter window, not unlike the collect example.
I added the mainframe code at the bottom, just in case the view
isn't created properly.

/*
 *  CItemView Class, a Form class for selecting items
 */

#include "itemview.h"

IMPLEMENT_DYNCREATE(CItemView, CFormView)

CItemView::CItemView()
   : CFormView(CItemView::IDD)
{

Quote:
}

CItemView::~CItemView()
{

Quote:
}

BEGIN_MESSAGE_MAP(CItemView, CFormView)
END_MESSAGE_MAP()

void CItemView::OnInitialUpdate()
{
   CFormView::OnInitialUpdate();

Quote:
}

void CItemView::DoDataExchange(CDataExchange* pDX)
{
   CFormView::DoDataExchange(pDX);
   DDX_Text(pDX, IDC_ITEMNAME, itemName);

Quote:
}

/*
 * Header for CItemView class
 */

#ifndef __AFXEXT_H__
#include <afxext.h>
#endif
#include "resource.h"

class CItemView : public CFormView
{
   DECLARE_DYNCREATE(CItemView)

protected:
   CItemView();                
   ~CItemView();

public:
   CString itemName;

public:
   void OnInitialUpdate();
protected:
   virtual void DoDataExchange(CDataExchange* pDX);

public:
   enum { IDD = IDD_ITEMVIEW };

   DECLARE_MESSAGE_MAP()

Quote:
};

/*
 *  Part of the mainframe code
 */
void CMainFrame::OnNewItem(UINT nCmdID)
{
   if(windowstatus == ITEMWINDOW)
      return;
   windowstatus = ITEMWINDOW;
   CRuntimeClass* pNewViewClass;
   pNewViewClass = RUNTIME_CLASS(CItemView);

   // create the new view
   CCreateContext context;
   context.m_pNewViewClass = pNewViewClass;
   context.m_pCurrentDoc = GetActiveDocument();

   m_wndSplitter.DeleteView(0,1);
   m_wndSplitter.CreateView(0,1,pNewViewClass,CSize(0,0), &context);

   CView* pNewView = STATIC_DOWNCAST(CView, m_wndSplitter.GetPane(0,1));
   if (pNewView != NULL)
   {
      pNewView->ShowWindow(SW_SHOW);
      pNewView->OnInitialUpdate();
      SetActiveView(pNewView);
      RecalcLayout();
   }
   m_wndSplitter.RecalcLayout();

Quote:
}

Any suggestions at all are welcome, I'm stumped.
Could it be because I'm Compiling with Borland 5.02?
Can't see why though.  I've coded dialog boxes before without any problems.

Please, help
Morten



Fri, 24 Oct 2003 19:08:09 GMT  
 HELP! DoDataExchange is injured?
Morten,

That behavior is by design. You wouldn't want default processing to update the
whole dialog every time one control changed. You need to capture the change
notifications from the controls you want to cause automatic changes and either
call DoDataExchange yourself, or just update whatever other control is
supposed to change manually (SetText, SetCheck, SetSel, etc.)

Jim

Quote:

> I can't seem to communicate with the form view when changing control
> status in anything, be it edit views, checkboxes or whatnot.
> DoDataExchange is read once, at view creation, but once created there
> is no communication.  I can capture the controls with ON_COMMAND().
> I've been trying to fix this problem for a week, but apart from
> forgetting CFormView::OnInitialUpdate(), I've had no progress.

Jim [VC/MFC MVP]
To send mail, change spam-me-not to msn


Fri, 24 Oct 2003 21:50:32 GMT  
 HELP! DoDataExchange is injured?
: Morten,

: That behavior is by design. You wouldn't want default processing to update the
: whole dialog every time one control changed. You need to capture the change
: notifications from the controls you want to cause automatic changes and either
: call DoDataExchange yourself, or just update whatever other control is
: supposed to change manually (SetText, SetCheck, SetSel, etc.)

: Jim

:> I can't seem to communicate with the form view when changing control
:> status in anything, be it edit views, checkboxes or whatnot.
:> DoDataExchange is read once, at view creation, but once created there
:> is no communication.  I can capture the controls with ON_COMMAND().
:> I've been trying to fix this problem for a week, but apart from
:> forgetting CFormView::OnInitialUpdate(), I've had no progress.

Well, I suppose it makes some sense, but it still doesn't explain why
DoDataExchange isn't read at all apart from at creation.  The examples I've
been looking at triggers DoDataExchange at every control.  For instance
when checking a checkbox or hitting enter in an edit field.

Oh well, I guess I will have to find out which control was triggered when
using ON_COMMAND_RANGE.



Fri, 24 Oct 2003 22:13:03 GMT  
 HELP! DoDataExchange is injured?
Heh, nevermind ;)
I just found out what UpdateData() did.
One never stops learning.  Btw I'm rather new to this GUI.


Fri, 24 Oct 2003 22:54:35 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. I am new to programming and am lost

2. I have it kinda but I am really confused.PLease HElp

3. I am a beginner, Need help on variables

4. I am perplexed - help!

5. please help, where am i wrong??

6. PLEASE HELP: I AM NEW TO DEBUGGER (Turbo Debugger 3.0)

7. I'am LOOKING 4 help w/ C++ PROGRAMING

8. Help I cant C what I am doing wrong

9. Urgently help as i am stuck!

10. Help I am stuck!!!!!!!!!!!!

11. HELP with C, I am losing it fast....

12. Help, I am new to cprograming ...

 

 
Powered by phpBB® Forum Software