Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can I make a modeless topmost for the desktop ? Pin
S Douglas18-Oct-05 22:50
professionalS Douglas18-Oct-05 22:50 
AnswerRe: How can I make a modeless topmost for the desktop ? Pin
yarp20-Oct-05 6:19
yarp20-Oct-05 6:19 
QuestionAccess Violation Error Pin
nripun18-Oct-05 3:50
nripun18-Oct-05 3:50 
AnswerRe: Access Violation Error Pin
David Crow18-Oct-05 3:57
David Crow18-Oct-05 3:57 
GeneralRe: Access Violation Error Pin
Chris Losinger18-Oct-05 4:03
professionalChris Losinger18-Oct-05 4:03 
GeneralRe: Access Violation Error Pin
David Crow18-Oct-05 4:43
David Crow18-Oct-05 4:43 
GeneralRe: Access Violation Error Pin
Chris Losinger18-Oct-05 4:50
professionalChris Losinger18-Oct-05 4:50 
GeneralRe: Access Violation Error Pin
nripun18-Oct-05 5:21
nripun18-Oct-05 5:21 
DavidCrow wrote:
What error?


Debug Assertion Error
File:afxwin2.inl
Line 590



DavidCrow wrote:
Are you trying to do this before CDialog::OnInitDialog() is called?


I have tried both, b4 and after


I am restating my problem and i will try to be as clear as possible.

Aim is to have the dialog box pop up with a few checkboxes and radiobuttons checked and the listbox be filled.
Using class wizard i assigned the following member variables to the radiobuttons and the list box.

The first radiobutton is IDC_RADIOBUTTON1
The second radiobutton is IDC_RADIOBUTTON2
The listbox is IDC_LISTBOX1
When i open the MemberVariables tab in the ClassWizard i get the following..

ControlIDs Type Member
IDC_RADIOBUTTON1 CButton m_radio1
IDC_RADIOBUTTON1 CButton m_radio2
IDC_LISTBOX1 CListBox m_listbox1

Now when the dialog opens i want hte first radiobutton to be checked, the second radiobutton be disabled and the listbox be filled with certain text.

To achieve the above result i wrote the following code inside the OnInitDialog function.
<br />
m_radio1.SetCheck(BST_CHECKED);<br />
m_radio2.EnableWindow(FALSE);<br />
m_listbox1.AddString(BUFF);<br />


The above code gave the Debug Assertion Error i mentioned in the beginning of the post.

Now i change the above piece of code to

<br />
CButton *pButton;<br />
pButton=(CButton*)this->GetDlgItem(IDC_RADIOBUTTON1);<br />
pButton->SetCheck(BST_CHECKED);<br />
pButton=(CButton*)this->GetDlgItem(IDC_RADIOBUTTON2);<br />
pButton->EnableWindow(FALSE);<br />


..... it actually worked

Then i added the GetDlgItem for te list box
<br />
BOOL CSchDlg::OnInitDialog(){<br />
CDialog::OnInitDialog();<br />
CButton *pButton;<br />
CListBox *pListBox;<br />
pButton=(CButton*)this->GetDlgItem(IDC_RADIOBUTTON1);<br />
pButton->SetCheck(BST_CHECKED);<br />
pButton=(CButton*)this->GetDlgItem(IDC_RADIOBUTTON2);<br />
pButton->EnableWindow(FALSE);<br />
pListBox = (CListBox *)this->GetDlgItem(IDC_TIMETABLELIST);<br />
pListBox->AddString("Hope this works");<br />
<br />


The DoModal() of the Dialog box is done from another class CMySch.
The above piece of code works fine when i DoModal() for the first time.
But after i close the dialog and then again call DoModal from CMySch the following error:
Access violation

comes at pListBox = (CListBox *)this->GetDlgItem(IDC_TIMETABLELIST);

Inside the debug window the following was displayed

Name Value
---- ------
this {SchDlg 0x20383738 hWnd=???}

Hope things are clear

-- modified at 11:22 Tuesday 18th October, 2005
GeneralRe: Access Violation Error Pin
Rage18-Oct-05 5:43
professionalRage18-Oct-05 5:43 
GeneralRe: Access Violation Error Pin
nripun19-Oct-05 0:45
nripun19-Oct-05 0:45 
GeneralRe: Access Violation Error Pin
Rage18-Oct-05 5:47
professionalRage18-Oct-05 5:47 
QuestionRe: Access Violation Error Pin
David Crow18-Oct-05 5:50
David Crow18-Oct-05 5:50 
Questiontime help pleas Pin
Gapilazo18-Oct-05 3:18
Gapilazo18-Oct-05 3:18 
AnswerRe: time help pleas Pin
Calc2018-Oct-05 3:44
Calc2018-Oct-05 3:44 
AnswerRe: time help pleas Pin
vikas amin18-Oct-05 3:45
vikas amin18-Oct-05 3:45 
QuestionRe: time help pleas Pin
David Crow18-Oct-05 3:50
David Crow18-Oct-05 3:50 
QuestionCString memory leak Pin
mails_aphale18-Oct-05 2:50
mails_aphale18-Oct-05 2:50 
AnswerRe: CString memory leak Pin
prasad_som18-Oct-05 3:02
prasad_som18-Oct-05 3:02 
GeneralRe: CString memory leak Pin
mails_aphale18-Oct-05 3:48
mails_aphale18-Oct-05 3:48 
AnswerRe: CString memory leak Pin
vikas amin18-Oct-05 3:51
vikas amin18-Oct-05 3:51 
GeneralRe: CString memory leak Pin
mails_aphale18-Oct-05 18:52
mails_aphale18-Oct-05 18:52 
QuestionRe: CString memory leak Pin
David Crow18-Oct-05 3:52
David Crow18-Oct-05 3:52 
AnswerRe: CString memory leak Pin
Rage18-Oct-05 5:35
professionalRage18-Oct-05 5:35 
GeneralRe: CString memory leak Pin
David Crow18-Oct-05 5:54
David Crow18-Oct-05 5:54 
AnswerRe: CString memory leak Pin
mails_aphale18-Oct-05 18:51
mails_aphale18-Oct-05 18:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.