Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 13th, 2004, 03:27 PM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Running main() from a dialog-based control

Hi,
I'm a C++ newbie and have a liitle problem I hope someone can help me with here.

I have a Visual C++ project consisting of about 20 source files, one of which contains main(). I originally built a dialog-based application, and have no menus in the application. I am trying to run main(), by clicking on a Control button, "Analyze", inside the OnAnalyze() function.

From my understanding, main() is supposed to harness all my other source files and implement it. Now, I need to run main() from a control button, in my MFC application. The project compiles with no errors at present but I don't know how to run main() with the control button.

Or would it may be necessary to implement an instance of the control in main()?

Thaanks a lot in advance!
Reply With Quote
  #2 (permalink)  
Old December 4th, 2004, 12:48 PM
Authorized User
 
Join Date: Dec 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do not see why you would want to call main().

To explain.
Main is the common name for the entry point of a program. The entry point is the place where execution starts. It is used by the OS and the Runtime to start and run your program. Calling it your self is at best very risky and worst a disaster. Do Not Try. Further since your application is written with the MFC you should not even have a main in your source. It is implemented within the MFC and needs to be inorder for the MFC to do its thing.

Another thing to note is that the name main is not a must. It is defined in the build settings of your compiler and when using the MFC is acctually called something like WinMainCRTStartup.

You should move the functionaly of your main function to something with a less confusing name and call that from OnAnalyze()



Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create reports based on TFS Source Control woojtii Visual Studio 2005 0 March 28th, 2007 04:16 AM
Executing main() from a control btn aaadetos Visual C++ 3 November 19th, 2004 06:23 PM
server control event in modal dialog diyagp General .NET 0 August 26th, 2004 02:57 AM
Calendar control that is not server based badgolfer ASP.NET 1.0 and 1.1 Basics 0 June 11th, 2004 04:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.