|
|
Using it and needing it are two different things.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
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
|
|
|
|
|
nripun wrote: the Debug Assertion Error i mentioned
Which line of code is actually asserting ? Can you post the code (meaning the block containing the ASSERT(), not your line of code) ?
nripun wrote: ..... it actually worked
Here I have to second DAvid : It seems to have worked, most surely this will not survive the release version.
You need to do all this at least inside OnInitDialog, or after it has been called, otherwise the controls do not exist as such (which explains the hWnd = ??) you mentioned.
~RaGE();
|
|
|
|
|
Sorry guys, My Mistake.
Before the line ,
pListBox = (CListBox*) this->GetDlgItem(IDC_LISTBOX1);
there was a sprintf() function which was not successful .
I corrected the sprintf() and now the code works fine. The mistake in the sprintf() caused the hWnd=???
Thank you all..
|
|
|
|
|
OK, afxwin2.inl, line 590
_AFXWIN_INLINE void CButton::SetCheck(int nCheck)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, BM_SETCHECK, nCheck, 0); }
meaning your control has not been initialized yet. You are calling this function too early (the handle m_hWnd has not been assigned yet).
~RaGE();
|
|
|
|
|
nripun wrote: Debug Assertion Error
File:afxwin2.inl
Line 590
Which indicates that the (control) window does not yet exist.
What does the dialog's DoDataExchange() and BEGIN_MESSAGE_MAP() methods look like?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
How can i change time on my computer with c++ ofcorse
|
|
|
|
|
There is function in Windows API called SetSystemTime(). You can find an example in MSDN.
|
|
|
|
|
Use the function
---SetSystemTime()----
Just search the MSDN u get the details
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
How about SetLocalTime() ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I have used many CString variables in functions.
code works fine but at the end, in CString destructor it gives null pointer exception.
in destructor, in FreeData() call, delete operator gives exception.
is there something that I left out
can somebody help me out ?
thanx in advance.
|
|
|
|
|
|
code is big & it contains lot of my function calls (user defined). it seems difficult.
|
|
|
|
|
might be your string pointer is deleted before the call to destructor
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
i don't understand.
can u just elaborate
|
|
|
|
|
How are you using these CString variables?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hey David, dropped the underlines ? Where is David ?
~RaGE();
|
|
|
|
|
It was simply time for a change. I was trying not to get too eccentric.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
CString strVarName;
CString strLine = <sometext>;
strVarName = strLine.Mid();
thats how it is.
|
|
|
|
|
mails_aphale wrote: CString strLine = ;
Aside from this, I see nothing strange. Have you compiled the project in Debug mode and started it via F5? If you have memory-related issues, they will show up in the debug output window.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hello!
I have a dialog based MFC application with "Style: Popup" and "Border: None". So the system menu, title bar, minimize box, maximize box are not displayed. Also the "Caption" edit is disabled. I want to set a title for the application to be displayed in the taskbar since with the above mentioned settings it only displays the icon.
How can I set the title?
Thanks,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
SetWindowText()
SkyWalker
|
|
|
|
|
I wasn't expecting it to be so simple, but hey, I don't mind.
thanks a lot.
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|