HighTechTalks DotNet Forums  

Need a suggestion on how to make a button do something.

VC++.net microsoft.public.dotnet.languages.vc


Discuss Need a suggestion on how to make a button do something. in the VC++.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Keith
 
Posts: n/a

Default Need a suggestion on how to make a button do something. - 03-15-2010 , 09:21 PM






Hello,

I have invested years and years into Visual Basic in Visual Studio and the
MS Office products. Now, I’m taking a look at Visual c++ looking at it with
Visual c++ Express 2008. It looks really promising. And there are some
significant improvements since my old copy of Visual Studio was purhased. I
have written many plain old c functions in the vc++ environment, and today
moved to a new step.

I created a project with a form, (same as I did in VB) and added a button
“button1” then I looked at the code that shows properties for button1 and
that is shown below…


this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System:rawing::Point(136, 23);
this->button1->Name = L"button1";
this->button1->Size = System:rawing::Size(89, 42);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;



So it looks like I can make button1 call a function or do something by using
OnClick, but it would be helpful to see some code that does something when
OnClick happens. Does the code build on the followng?

this->button1->OnClick ... ??? how do I do something here, ie call a function
or is there some other way…

Thank you for giving me a lead on where this might go next.

Keith

Reply With Quote
  #2  
Old   
PvdG42
 
Posts: n/a

Default Re: Need a suggestion on how to make a button do something. - 03-31-2010 , 10:13 AM






"Keith" <Keith (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hello,

I have invested years and years into Visual Basic in Visual Studio and the
MS Office products. Now, I’m taking a look at Visual c++ looking at it
with
Visual c++ Express 2008. It looks really promising. And there are some
significant improvements since my old copy of Visual Studio was purhased.
I
have written many plain old c functions in the vc++ environment, and today
moved to a new step.

I created a project with a form, (same as I did in VB) and added a button
“button1” then I looked at the code that shows properties for button1 and
that is shown below…


this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System:rawing::Point(136, 23);
this->button1->Name = L"button1";
this->button1->Size = System:rawing::Size(89, 42);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;



So it looks like I can make button1 call a function or do something by
using
OnClick, but it would be helpful to see some code that does something when
OnClick happens. Does the code build on the followng?

this->button1->OnClick ... ??? how do I do something here, ie call a
function
or is there some other way…

Thank you for giving me a lead on where this might go next.

Keith

Assuming you are working with a C++/CLI (CLR) project, you can create event
procedures for the button and place any code you want to execute in the body
of the desired event procedure, just as you would in VB.

As the Click event is the default for a button, you can double-click on the
button in design view to create the event procedure shell.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.