Results 1 to 4 of 4

Thread: How to create button on visual C++ Form

  1. #1
    Join Date
    Dec 2008
    Posts
    51

    How to create button on visual C++ Form

    I am quite new to programming and visual c++. and I have requirement to create form using form design, and on that form I wish to create two button One "Submit" and "Cancel" on the same form, which should opens up a new form and then later close that form and return to my original form.

  2. #2
    Join Date
    Oct 2008
    Posts
    180

    Re: How to create button on visual C++ Form

    Open the first form in Visual Studio Designer and double-click on your button. The Click handler will be opened. Then type a fragment like this:

    namespace Form1 {

    using namespace System;
    using namespace System:: ComponentModel;
    using namespace System:: Collections;
    using namespace System:: Windows::Forms;
    using namespace System:: Data;
    using namespace System:: Drawing;

    MySecondForm ^ form = gcnew MySecondForm;

    form->ShowDialog();

    }

  3. #3
    Join Date
    Feb 2008
    Posts
    180

    Re: How to create button on visual C++ Form

    There are a lot more than 10. but if you want 10, just off the top of my head, would be picturebox, listbox, combobox, textbox, label, button, checkbox, optionbutton (or radio button), tabstrip, timer. It is not obvious how to add additional buttons. Perhaps they are instances of CButton. But there are no examples. CButton is defined in afxwin.h (MFC) and derived from CWnd. A text property is defined under CWnd - use GetWindowText & SetWindowText. There does not appear to be a property for the button text. There are many more, those are just the first 10 I thought of.
    Source(s):
    Open up C++ and look at the toolbar on your left. That has all the basic controls on it.

  4. #4
    Join Date
    Feb 2008
    Posts
    121

    Re: How to create button on visual C++ Form

    The buttons appear to be defined in *.rc (resource file). It will be called when you click on the Button when the application is running. The code instantiates the new window and shows it. Of course MySecondForm has to be replaced by your Window/Form class. Notice also that *.rc is the name of the displayed form. You would think that there would be a way to add another mfc component to the form.

Similar Threads

  1. Replies: 2
    Last Post: 02-05-2011, 07:06 AM
  2. Form Help in MS Visual Basic 2008!
    By NGV BalaKrishna in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 10:07 PM
  3. Procedure in VB to create form inside another form
    By Jalabala in forum Software Development
    Replies: 3
    Last Post: 16-11-2009, 02:14 PM
  4. Closing out a form in Visual Basic
    By Adel123 in forum Software Development
    Replies: 3
    Last Post: 31-08-2009, 04:56 PM
  5. How to create access clear button in the form using MS ACCESS
    By T0tal L0$$ in forum Software Development
    Replies: 3
    Last Post: 09-06-2009, 10:59 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,894,030.10405 seconds with 17 queries