MFC VC++ .NET Newbie Help

G

Guest

For reasons beyond my control, I've been coerced into transitioning from VBA
to VC++ .NET. My question is simple. When using Forms in VBA, I can reference
a variable defined in the UserForm (say strName for example) from my main
Module by using the following statement

var x
x = UserForm1.strName

I have yet to find a corollary in Visual C++ where I can reference a
variable defined in my Dialog in my Main code. How can I get information from
the Dialog to the Main{} section of my *.cpp file?
 
G

Guest

First off, congratulations on switching to Visual C++. It's a very powerful
language that can do alot of nice things. To answer your question, if you
want to get say text from a textbox, what you need to do is very simple.
First off, go to the part where you inserted the textbox, right click on the
textbox control, select add variable. The Add Variable Dialog will now
appear. Now make sure that the Catagory is selected as Control from the
Catagory dropdown. Now under variable name, enter the name of that you would
like to call this variable. For instance MyTextBox. Now go back to looking
at your code. If you called the textbox MyTextBox, here is a snippet as far
as how to make the control display text :
// This line of code is the down and dirty way of setting text
// in a textbox
MyTextBox.SetWindowText("Hello World");
// This line of code will refresh the dialog box
MyTextBox.UpdateData(FALSE);
There are other different ways of getting the job done.
Here are some websites that should help get you started in your Visual C++
endevour :
www.codeproject.com
www.codeguru.com
www.mindcracker.com
www.mvps.org
http://bobmoore.mvps.org/

I hope that this helps you.

Sincerely,
James Simpson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top