Re: Unhandled exception on clicking dialog box OK button,Its URGENT



See below....
On Tue, 19 Jun 2007 01:01:21 -0700, rindam2002@xxxxxxxxx wrote:

Hi
I have a dialog class in my ATL COM application which is using WTL
and not using MFC.this dialog class is derived from CAxDialogImpl.I
have two edit boxes in this dialog and I want that on clicking the ok
button,I can save the string values entered in those edit boxes into
two variables.So my code in OnOK function is as bellow:

LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
bHandled)
{
GetDlgItemText(IDC_EDIT_RSSNAME,bstrRssName);
GetDlgItemText(IDC_EDIT_RSSPATH,bstrRssPath);
m_strRssName=CString(bstrRssName);
m_strRssPath=CString(bstrRssPath);
*****
Where are bstrRssName and bstrRssPath declared? Why is it you are showing an example so
incomplete as to make it impossible to diagnose the problem? Why are you under the
impression that the text is a bstr, and how large are those buffers, and why do you
believe they are large enough?
*****

// gToolbarCtrl.strRssName=m_strRssName;
// gToolbarCtrl.strRssPath=m_strRssPath;
// MessageBox(m_strRssName);
// MessageBox(m_strRssPath);
*****
What is gToolbarCtrl, what are the types of the member variables, and why do you think you
need a global variable to hold this?

This code looks incredibly complicated. In addition, when you have access faults, the
ONLY valid presentations MUST involve showing EVERY declaration of EVERY variable
manipulated by the code in question. Otherwise, the answer is "you have a bug somewhere
here, fix it"
*****
EndDialog(wID);
return 0;
}

Now on clicking the ok button I am getting unhandled exception.But If
I remove these lines from OnOK


GetDlgItemText(IDC_EDIT_RSSNAME,bstrRssName);
GetDlgItemText(IDC_EDIT_RSSPATH,bstrRssPath);
m_strRssName=CString(bstrRssName);
m_strRssPath=CString(bstrRssPath);

then the exception goes.But I am not being able to save the string
values.I need to save them.As this dialog class is derived from
CAxDialogImpl,I am not being able to call UpdateData() also.Plz help
me to solve this problem By giving me the sample code.Plz help me ,Its
urgent.
*****
I suspect that bstRssName is bogus, But since you didn't bother to actually tell us what
it is, we can only guess that it is a character array. If it is a
pointer-to-a-character-array, then the first suspicion is that it is an uninitialized
pointer; and the second suspicition is that it is a pointer to a buffer that is too small.
Also, it is meaningless to say "when I remove these lines" because only ONE of them causes
the error, and it would be nice to know which one. That's why debuggers have call stack
traces! What was the call stack trace, and what were the values of the variables
involved at the time of the error?

You have to do SOMETHING besides say "my program has a bug, what's wrong?"
joe
*****
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.