How can I start programming this program ?

Discussion in 'Win32' started by domain, May 9, 2007.

  1. domain

    domain New Member

    Joined:
    May 1, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone,
    I was asked to write a program with MFC. It's about Linked List .
    This is how I would start :


    [​IMG]

    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 ? ).
     
  2. domain

    domain New Member

    Joined:
    May 1, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    To be more clear, What Should I Write In This Function :

    PHP:
    void CTetDlg::OnButton1() 
    {
        
    // TODO: Add your control notification handler code here
        
    }
    While the Button1 points to EXIT button ?
     
  3. domain

    domain New Member

    Joined:
    May 1, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    OK, I figure it out :

    PHP:
     void CTetDlg::OnButton1()
    {
        exit(
    1);
        
     
  4. domain

    domain New Member

    Joined:
    May 1, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    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:
    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:
    #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 ? :confused:
     
  5. domain

    domain New Member

    Joined:
    May 1, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    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 ):

    [​IMG]

    [​IMG]

    [​IMG]

    [​IMG]

    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.
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     
  7. domain

    domain New Member

    Joined:
    May 1, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    Thank you Mr.Shabbir for the reply :)

    I do not know how to do this :
    could you please help me by using the previous information in reply #5 ?
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     
  9. domain

    domain New Member

    Joined:
    May 1, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    PHP:
    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:
    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 !
     
  10. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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 ....
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice