Thread: what is wrong with this code?

  1. #1
    Jennifer
    Guest

    Angry what is wrong with this code?

    hi,
    what is wrong with the sample code that i paste it in here? i should run the whole program without errror but dont know it gets wrong.here i pasted the code in there,hope anyone can solved the problem in there.Would someone there generate the script file for me? i wanna to see how is the script file for this program works? thax. jenny.

    #include<afxwin.h>
    #include"resource.h"

    #include <afxext.h>
    #include <afxdlgs.h>




    class MyWindow:public CFrameWnd
    {
    protected:
    CMenu *m_MyMenu;
    CProgressCtrl *pro;


    public:
    MyWindow();

    ~MyWindow()
    {
    MessageBox("Sample Window","CFrame Destructor");
    }




    void ExitHandle()
    {
    PostQuitMessage(0);
    }

    void OnEditRace()
    {
    CProgress a;
    a.DoModal();
    }


    DECLARE_MESSAGE_MAP()
    };
    BEGIN_MESSAGE_MAP(MyWindow,CFrameWnd)

    ON_COMMAND(ID_EDIT_RACE,OnEditRace)

    ON_COMMAND(ID_MY_EXIT,ExitHandle)


    END_MESSAGE_MAP()

    class CProgressDlg:public CDialog
    {
    protected:
    CProgressCtrl *pro;
    public:
    CProgressDlg():CDialog(IDD_DIALOG1)
    {
    }
    BOOL OnInitDialog()
    {
    pro=(CProgressCtrl*)GetDlgItem(IDC_PROGRESS1);
    pro->SetRange(1,30);
    return TRUE;
    }
    void OnOneUp()
    {
    pro->SetStep(1);
    pro->StrpIt();
    }

    void OnOneDown()
    {
    pro->SetStep(-1);
    pro->StrpIt();
    }
    void OnRaceToFinish()
    {
    int j;

    pro->SetStep(1);
    for(j=0;j>30;j++)
    pro->StepIt();
    }
    void OnOk()
    {
    EndDialog(TRUE);
    }
    DECLARE_MESSAGE_MAP()
    };
    BEGIN_MESSAGE_MAP(CProgressDlg,CDialog)

    ON_COMMAND(IDOK,OnOk)
    ON_COMMAND(ID_ONEUP,OnOneUp)
    ON_COMMAND(ID_ONEDOWN,OnOneDown)
    ON_COMMAND(ID_RACE,OnRaceToFinish)

    END_MESSAGE_MAP()

    MyWindow::MyWindow()
    {

    m_MyMenu=new CMenu;
    Create(0,"Example Window");
    m_MyMenu->LoadMenu(MAKEINTRESOURCE(IDR_MENU1));
    SetMenu(m_MyMenu);
    // ::DeleteObject(hYellowBrush);
    }


    class MyApp : public CWinApp
    {
    public:
    //Overloading the virtual member function InitInstance
    BOOL InitInstance();
    //Overriding virtual member function ExitInstance
    BOOL ExitInstance();
    }; //End of class declaration
    //InitInstance Overrriden definition
    BOOL MyApp::InitInstance()
    {
    ::MessageBox(0,"Sample Window","InitInstance",MB_OK|MB_ICONASTERISK);
    MyWindow *MyWindowObject;
    MyWindowObject=new MyWindow;
    m_pMainWnd=MyWindowObject;
    MyWindowObject->ShowWindow(SW_SHOWMAXIMIZED);
    //hicon=::LoadIcon(hinst,MAKEINTRESOURCE(IDI_ICON1)) ;
    return TRUE;

    }
    //Exit instance Overriden Definition
    BOOL MyApp::ExitInstance()
    {
    ::MessageBox(0,"Sample Window","ExitInstance",MB_OK|MB_ICONHAND);
    return TRUE;
    };
    //Creation of an Object of application type
    MyApp ApplicationObject;

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    >what is wrong with the sample code that i paste it in here?

    I don't know. Who said it was wrong ? Probably your compiler. It gave you information what is wrong. It gave you an error message. Please post this message, too, so we can help you. You already did some work, like pasting this into a file and compiling it, and got a negative result. We are lazy people here, and don't like to do all this over again Would you post your negative results ( i.e. Error messages ) here please ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong in this simple code
    By vikingcarioca in forum C Programming
    Replies: 4
    Last Post: 04-23-2009, 07:10 AM
  2. what is wrong with this code please
    By korbitz in forum Windows Programming
    Replies: 3
    Last Post: 03-05-2004, 10:11 AM
  3. I cant find what is wrong with this code
    By senegene in forum C Programming
    Replies: 1
    Last Post: 11-12-2002, 06:32 PM
  4. Anyone see what is wrong with this code?
    By Wise1 in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 02:01 PM
  5. very simple code, please check to see whats wrong
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-10-2001, 12:51 AM