Hello all,
I am writing a native, dialog based, c++ app (MFC) for a Windows Mobile 2003 device (PPC) using vs2005. I have the following things:
- a variable
- that variable DDX'd to an edit control
- the variable set to some initial value
- an "OnEnChange" handler for my edit control that calls UpdateData(TRUE)
- another method that changes the variable and calls UpdateData(FALSE) to update the control
This seems to work fine...the user changes the edit control and the variable is updated, and vice versa. However, the problem is at application startup. I get an error "An unsupported operation was attempted". The dialog box is then displayed and the program executes fine. (I really have about 8 of these suckers, so I get a bunch of errors).
This error comes from the call to UpdateData(TRUE) in my OnEnChange handler - presumably because something doesn't exist yet when it's called during startup.
Is there a better way to do this , or a workaround to avoid those errors (maybe suppressing the 'change' messages until the dialog is displayed)
It seems that this would be a common thing to do, and I'm just not aware of the right way to do it.
variable <--> control (where both can change and must update the other)
Thanks,
CyleS

UpdateData before app starts
nkroy
May I know the type of m_myPt.m_temp
Do you mean that you didn't get the same error when you tried the same thing in a newly created app Was the error, that you got in ::CreateDialogIndirect, same as the previous one
Thanks
Chris763324
DDX_Text(pDX, IDC_TEMP, m_myPt.m_temp);
I tried to re-create this error from scratch, and was also unable to do so. While single stepping my app, I get the error in:
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProcEx);
of dlgcore.dll.
Does this help
Cyle
TedHoward
Hi,
I agree with you that this might be value exchange related issue. But I find myself unable to get a repro without knowing the eaxct code used above( related to the context). Which DDX_Function was used in DoDataExchnage and which type of variable are you using in exchnage.
Thanks
dfmartin
Yes, when I created my small test app from scratch, I'm not getting this error. The original app was created in VS2005B2, and I'm now using vs2005 AE.
I'll try to single-step deeper later, however, when I comment out the UpdateData(TRUE) line from my OnEnChange handler, the error does not happen, and returns when I put the line back. For now, that's the only line in that or similar handlers (for other controls).
Thanks for your patience
Manny M
Hi CyleS,
Like Avinash, I can't reproduce the exact problem you're facing without access to your project. However I have another suggestion. Try replacing the UpdateData(TRUE) with GetDlgItemInt. You may want to re-consider calling UpdateData() in OnEnChange. Realize that UpdateData not only updates the control that has focus, but ALL the other ddx variables in your dialog. So there may be an unnecessary performance hit there everytime the user types something in the edit control. Do you really want this I recommend looking into using Get/SetDlgItemInt and Get/SetDlgItemText as alternatives to UpdateData(). I prefer to use UpdateData() only when all controls need to be refreshed (like in OnInitDialog or OnOK). Hope this helps.
--
Mel Sampat
Program Manager, Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.
Ivo Klerkx
Hi,
I am unable to repro the issue with the infromation provided.
Thanks