码迷,mamicode.com
首页 > 其他好文 > 详细

HelloWorld1

时间:2014-12-18 10:08:27      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:style   blog   ar   io   color   os   sp   for   on   

  1 //HelloWorld.cpp
  2 
  3 /*
  4 Copyright 2000-2004 The VCF Project.
  5 Please see License.txt in the top level directory
  6 where you installed the VCF.
  7 */
  8 
  9 
 10 /**
 11 *A hello world application
 12 *This demonstrates the simplest
 13 *code possible to create a running app
 14 *and display a window with the text
 15 *"Hello World" in it‘s caption bar.
 16 */
 17 
 18 
 19 /**
 20 *include the ApplicationKit.h
 21 *this has all the core files you‘ll need to get started.
 22 *In general, you‘ll probably want to make this
 23 *the first header you include within your .cpp files
 24 */
 25 
 26 
 27 #include "vcf/ApplicationKit/ApplicationKit.h"
 28 
 29 
 30 /**
 31 *use the VCF namespace to make it more convenient
 32 *to refer to VCF classes
 33 */
 34 using namespace VCF;
 35 
 36 
 37 class HelloWorldApp : public Application {
 38 public:
 39     HelloWorldApp( int argc, char** argv ): Application(argc, argv) {
 40 
 41     }
 42 
 43     virtual bool initRunningApplication() {
 44         Application::initRunningApplication();
 45 
 46         /**
 47         *create the main Window here.
 48         *Note that is on the heap, not the stack.
 49         *The application will clean it up for you,
 50         *so do NOT make this a stack based object
 51         */
 52         Window* mainWindow = new Window();
 53 
 54         /**
 55         *set the Application‘s main window.
 56         *Failure to do this will prevent the Application
 57         *of being notified to close correctly, and it will not
 58         *be able to free up the heap based memory for the
 59         *Window object.
 60         *In the VCF there is always a main window for GUI based
 61         *applications, which can be a Dialog or a Window object.
 62         *When this main window closes, the app shuts down as well.
 63         */
 64         setMainWindow( mainWindow );
 65 
 66 
 67         /**
 68         *Set the caption of the main window. Setting the caption
 69         *cause the text passed in to the method to appear on
 70         *the window frame‘s caption bar.
 71         */
 72         mainWindow->setCaption( "Hello World" );
 73 
 74         /**
 75         *show the main window.
 76         *By default the window is invisible until
 77         *either show() or setVisible(true) is called.
 78         *We could have called mainWindow->setVisible(true)
 79         *and it would have worked as well.
 80         */
 81         mainWindow->show();
 82 
 83         return true;
 84     }
 85 
 86 };
 87 
 88 
 89 /**
 90 here‘s the heart of the program, in good old main.
 91 yes this will work on Windows without displaying any
 92 console
 93 */
 94 int main(int argc, char *argv[])
 95 {
 96     /**
 97     create an instance of the HelloWorldApp class
 98     on the heap - DO NOT create it on the stack or
 99     you will get a crash whn you close you application.
100     This will be the only instance of this class in the process.
101     */
102     Application* app = new HelloWorldApp( argc, argv );
103 
104     /**
105     hand off the command line to the static appMain() call
106     which in turn begins the main application loop.
107     */
108 
109     Application::main();
110 
111     return 0;
112 
113 
114 }
115 
116 
117 /**
118 $Id: HelloWorld.cpp 2647 2006-04-28 16:42:38Z kdmix $
119 */

 

HelloWorld1

标签:style   blog   ar   io   color   os   sp   for   on   

原文地址:http://www.cnblogs.com/elitiwin/p/4171004.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!