Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 14-08-2009
Member
 
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.
Reply With Quote
  #2  
Old 14-08-2009
Member
 
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();

}
Reply With Quote
  #3  
Old 14-08-2009
Member
 
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.
Reply With Quote
  #4  
Old 14-08-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to create button on visual C++ Form"
Thread Thread Starter Forum Replies Last Post
how to get items in a form to auto-resize with the form using visual basic deansmylie93 Software Development 2 02-05-2011 07:06 AM
Form Help in MS Visual Basic 2008! NGV BalaKrishna Software Development 5 21-01-2010 10:07 PM
Procedure in VB to create form inside another form Jalabala Software Development 3 16-11-2009 02:14 PM
Closing out a form in Visual Basic Adel123 Software Development 3 31-08-2009 04:56 PM
How to create access clear button in the form using MS ACCESS T0tal L0$$ Software Development 3 09-06-2009 10:59 AM


All times are GMT +5.5. The time now is 03:57 AM.