C++ Tutorial - UI Application using visual studio 2012

THE SIMPLEST UI PROGRAM
  • Select Visual C++ CLR and CLR Empty Project 
    and type in RandomNumberGenerator for the project name. The, OK.
  • Project->Add New Item... 
    Select UI under Visual C++.
    Leave the Form name as given by default MyForm.h.
    Then, click Add

    MyForm.png 


  • We need to edit the MyForm.cpp file:
    #include "MyForm.h"
    
    using namespace System;
    using namespace System::Windows::Forms;
    
    
    [STAThread]
    void Main(array<String^>^ args)
    {
    	Application::EnableVisualStyles();
    	Application::SetCompatibleTextRenderingDefault(false);
    
    	RandomNumberGenerator::MyForm form;
    	Application::Run(%form);
    }
      
    The System namespace provides functions to work with UI controls.
  • At the right-mouse click on RandomNumberGenerator, we get the Properties window. 
    Configuration Properties->Linker->System
    Select Windows (/SUBSYSTEM:WINDOWS) for SubSystem.
    Advanced->Entry Point, type in Main.
    The, hit OK.
  • Hit F5, then we will have to run result, the Form.


UI SETUP
  • Locate the ToolBox, and then expand the list of Common Controls.
    Double-click its Label items to add it to our Form
    Do this seven times.
    We need to add two Buttons and a PixtureBox
    Double-click those as well from the list.
  • Resize and rearrange the items. Rename the buttons and tile of the Form, then it should look like this: 

    MyFormWithLabelsAndButtons.png 

  • We can put the picture onto the PictureBox. 
    At a right mouse click, we get Choosing Picture...
    Then, select the image file we want to use.
  • Let's try if it works.
    Run it (Hit F5). 

    FormWithPictureRun.png 

- See more at: http://www.bogotobogo.com/cplusplus/application_visual_studio_2013.php#sthash.ki4tvyDQ.dpuf
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值