How can I start programming this program ?

domain's Avatar, Join Date: May 2007
Go4Expert Member
Hi everyone,
I was asked to write a program with MFC. It's about Linked List .
This is how I would start :




When the user press button EXIT, the program should terminate ( How can I do that ? ).

When the user press button Singly linked list, the program should open another Dialog ( #2 ) and the others the same ( How can I do that ? ).
0
domain's Avatar, Join Date: May 2007
Go4Expert Member
To be more clear, What Should I Write In This Function :

PHP Code:
void CTetDlg::OnButton1() 
{
    
// TODO: Add your control notification handler code here
    

While the Button1 points to EXIT button ?
0
domain's Avatar, Join Date: May 2007
Go4Expert Member
OK, I figure it out :

PHP Code:
 void CTetDlg::OnButton1()
{
    exit(
1);
    

0
domain's Avatar, Join Date: May 2007
Go4Expert Member
Note: the program I'm creating is based on Dialogs only.

Now, I want to fox in creating a SLL Dialog , which should appears when I press the Singly linked list button on the First Dialog.

This is the function for button 3 :

PHP Code:
void CTetDlg::OnButton3() 
{
    
// TODO: Add your control notification handler code here
    
SLL newSll;
    

That does not work, even when I created a SLL class, this the header file for SLL class:

PHP Code:
#if !defined(AFX_SLL_H__4C827A8A_AB05_4879_8765_3161DEFA7142__INCLUDED_)
#define AFX_SLL_H__4C827A8A_AB05_4879_8765_3161DEFA7142__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SLL.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// SLL dialog

class SLL : public CDialog
{
// Construction
public:
    
SLL(CWndpParent NULL);   // standard constructor

// Dialog Data
    //{{AFX_DATA(SLL)
    
enum IDD IDD_PROPPAGE_MEDIUM };
        
// NOTE: the ClassWizard will add data members here
    //}}AFX_DATA


// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(SLL)
    
protected:
    
virtual void DoDataExchange(CDataExchangepDX);    // DDX/DDV support
    //}}AFX_VIRTUAL

// Implementation
protected:

    
// Generated message map functions
    //{{AFX_MSG(SLL)
    
afx_msg void OnButton7();
    
afx_msg void OnButton1();
    
afx_msg void OnButton2();
    
afx_msg void OnButton3();
    
afx_msg void OnButton4();
    
//}}AFX_MSG
    
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SLL_H__4C827A8A_AB05_4879_8765_3161DEFA7142__INCLUDED_) 
So, what should I do ?
0
domain's Avatar, Join Date: May 2007
Go4Expert Member
Where are you people ? I need help really ..

Here you are what I have done by now ( Just designing, I don not know how to write commands to open or close or to call ...etc ):









Now, I want the IDD_SLL_DIALOG opens when I press SLL button & create a new SLL object ( I have the code for it but I don not know where should I put it ).

And, when I press EXIT button ( on IDD_SLL_DIALOG ) I want the program return to IDD_TET_DIALOG not ending the whole program.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Now it Looks you already have everything ready and done. Just double click on the button and it will add the necessary handler to the button by the studio wizard.
0
domain's Avatar, Join Date: May 2007
Go4Expert Member
Thank you Mr.Shabbir for the reply

I do not know how to do this :
Quote:
Now, I want the IDD_SLL_DIALOG opens when I press SLL button & create a new SLL object ( I have the code for it but I don not know where should I put it ).
could you please help me by using the previous information in reply #5 ?
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You need to add the code in the button handler which is generated with the IDE as I mentioned above.

For quiting the application you can do lots of things

1. Use API DestroyWindow
2. Use API PostQuitMessage
3. Send the WM_CLOSE message to the window
4. Use EndDialog API.
0
domain's Avatar, Join Date: May 2007
Go4Expert Member
PHP Code:
You need to add the code in the button handler which is generated with the IDE as I mentioned above
Could you please tell me what code should I add ?
I tried this :

PHP Code:
SLL dlg;
dlg.DoModal();
if ( 
dlg.DoModal() == IDCOK )
        
AfxMessageBox(_T("Its OK!")); 
and the compiler didn't show me any error, although, the program crashed when I pressed SLL button !
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
If you wrote the following
Code:
SLL dlg;
dlg.DoModal();
and the compiler crashed means something somewhere is terribly wrong because the DoModal on the object should not be crashing unless you have some code in the dialog to be doing the crashing. Check the code you have edited in the InitDialog or OnCreate / PreCreate dialog handler ....