CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    May 2009
    Posts
    88

    Exclamation regarding application class variable??

    can i declare a variable of application class of my project??

  2. #2
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: regarding application class variable??

    Please give more details, what you want to do?
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  3. #3
    Join Date
    May 2009
    Posts
    88

    Re: regarding application class variable??

    I have designed a project ,so what i read o=in various documention's is that InitInstance of the Application class of project is the entry point for the project, so by declaring a variable of application class in one of my normal cpp files (having a main()) and including the header files of this Application class, i guess i may display the GUI whenever i declare the variable??

  4. #4
    Join Date
    May 2009
    Posts
    88

    Re: regarding application class variable??

    Please ignore o= in above post

  5. #5
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: regarding application class variable??

    Well, well. You need to grab a copy of MFC programming to understand all that.
    If you need Visual Studio to help, just create a Dialog based MFC application with MFC's New-Project wizard.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  6. #6
    Join Date
    May 2009
    Posts
    88

    Re: regarding application class variable??

    So m wrong??

  7. #7
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: regarding application class variable??

    It's not the question of being wrong or right. You need to understand basics of how MFC programs run (not too though!).

    What you've read in documentation is correct, thus you are right. But you know how and why?
    Yes, you can declare application-class variable, you are right. But what does it imply?
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  8. #8
    Join Date
    May 2009
    Posts
    88

    Re: regarding application class variable??

    Well on declaring an object as in file
    Code:
    #include "stdafx.h"
    #include<iostream.h>
    #include "Pflow.h"
    
    
    
    int main(int argc, char* argv[])
    {
    	printf("Hello World!\n");
    	CPflowApp app;
    	return 0;
    }
    and have included all the required project required files am getting Following Errors:
    main.obj : error LNK2001: unresolved external symbol "public: __thiscall CPflowApp::CPflowApp(void)" (??0CPflowApp@@QAE@XZ)
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/main.exe : fatal error LNK1120: 3 unresolved externals
    Error executing link.exe.

    and the file Pflow.h the header file of my application class is given as:
    Code:
    // Pflow.h : main header file for the PFLOW application
    //
    
    #if !defined(AFX_PFLOW_H__BB6F1EE1_33AA_4DF5_AF29_7A8DC123B309__INCLUDED_)
    #define AFX_PFLOW_H__BB6F1EE1_33AA_4DF5_AF29_7A8DC123B309__INCLUDED_
    
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    
    #ifndef __AFXWIN_H__
    	#error include 'stdafx.h' before including this file for PCH
    #endif
    
    #include "resource1.h"       // main symbols
    
    /////////////////////////////////////////////////////////////////////////////
    // CPflowApp:
    // See Pflow.cpp for the implementation of this class
    //
    
    class CPflowApp : public CWinApp
    {
    public:
    	CPflowApp();
    	int m_CurrentTool;
    
    // Overrides
    	// ClassWizard generated virtual function overrides
    	//{{AFX_VIRTUAL(CPflowApp)
    	public:
    	virtual BOOL InitInstance();
    	//}}AFX_VIRTUAL
    
    // Implementation
    	//{{AFX_MSG(CPflowApp)
    	afx_msg void OnAppAbout();
    	afx_msg void OnBus();
    	afx_msg void OnCapacitor();
    	afx_msg void OnGenerator();
    	afx_msg void OnLine();
    	afx_msg void OnLoad();
    	afx_msg void OnTransformer();
    	afx_msg void OnUpdateBus(CCmdUI* pCmdUI);
    	afx_msg void OnUpdateTransformer(CCmdUI* pCmdUI);
    	afx_msg void OnUpdateLoad(CCmdUI* pCmdUI);
    	afx_msg void OnUpdateLine(CCmdUI* pCmdUI);
    	afx_msg void OnUpdateGenerator(CCmdUI* pCmdUI);
    	afx_msg void OnUpdateCapacitor(CCmdUI* pCmdUI);
    	afx_msg void OnText();
    	afx_msg void OnUpdateText(CCmdUI* pCmdUI);
    	afx_msg void OnDeleteBus();
    	afx_msg void OnUpdateDeleteBus(CCmdUI* pCmdUI);
    	afx_msg void OnDeleteCapacitor();
    	afx_msg void OnUpdateDeleteCapacitor(CCmdUI* pCmdUI);
    	afx_msg void OnDeleteGenerator();
    	afx_msg void OnUpdateDeleteGenerator(CCmdUI* pCmdUI);
    	afx_msg void OnDeleteLine();
    	afx_msg void OnUpdateDeleteLine(CCmdUI* pCmdUI);
    	afx_msg void OnDeleteLoad();
    	afx_msg void OnUpdateDeleteLoad(CCmdUI* pCmdUI);
    	afx_msg void OnDeleteTransformer();
    	afx_msg void OnUpdateDeleteTransformer(CCmdUI* pCmdUI);
    	//}}AFX_MSG
    	DECLARE_MESSAGE_MAP()
    };
    
    
    /////////////////////////////////////////////////////////////////////////////
    
    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
    
    #endif // !defined(AFX_PFLOW_H__BB6F1EE1_33AA_4DF5_AF29_7A8DC123B309__INCLUDED_)

  9. #9
    Join Date
    May 2009
    Posts
    88

    Re: regarding application class variable??

    Well After changing my Settings->General to Use MFC using shared Dll i removed all the errors and could build the exe.....but know getting a runtime error as as soon as i execute my cpp file as written above:
    it Prints the Output:
    Hello World (at Console)
    and displays error as:
    Debug Assertion Failed!
    File :appcore.cpp
    Line :85
    and the line 85 is:
    ASSERT(AfxGetThread() == NULL);
    i have earlier also recieved this error but could not help myself....

  10. #10
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: regarding application class variable??

    Why do you need CWinApp object?
    Do you want to use MFC features?

    You can create Console Application and add support to MFC.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  11. #11
    Join Date
    May 2009
    Posts
    88

    Re: regarding application class variable??

    how can i add that support to MFC

  12. #12
    Join Date
    May 2009
    Posts
    88

    Re: regarding application class variable??

    and i have already told you the need of CWinApp object.....

  13. #13
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: regarding application class variable??

    i guess i may display the GUI whenever i declare the variable??
    No you cannot! You application should be GUI, which, generally has WinMain, instead of main.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  14. #14
    Join Date
    May 2009
    Posts
    88

    Re: regarding application class variable??

    So can you please give me any suggestion to accomplish this??

  15. #15
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: regarding application class variable??

    It would be hard for you to digest that you cannot do it that simply.
    Grab a book of GUI/MFC/VC++ programming. Learn from some tutorials on the net. Create Dialog-based MFC application using wizard, and step-in each line of code, starting from InitInstance.

    Understanding GUI/MFC programming will need few days, at least.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured