Hi,
Can anyone help me to start a simple program with MS VC++.
Enter your name: xyz
Enter 1st number : 10
Enter 2nd Number: 23
Hello XYZ, Sum of those numbers is: 33
Zahid
Hi,
Can anyone help me to start a simple program with MS VC++.
Enter your name: xyz
Enter 1st number : 10
Enter 2nd Number: 23
Hello XYZ, Sum of those numbers is: 33
Zahid
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
Well first I would do this on a dialog. Have a static text called Name: followed by a edit control with a member variable called m_Name. Then on the next line have another static text called First Number: followed by another edit control with a member variable called m_First. (Do the same for Second, and Total).
Then have a button labeld Get Total. And on the OnGetTotal() fuction declare 3 variables of type int for your First, Second and Total and one variable of type CString Name.
Use m_First.GetWindowText(First);
Use the same for Second and Name.
Then Total = First + Second.
<edit:>
m_Total.SetWindowText("Hello "+Name+" your total is "+Total);
</edit>
And call UpdateData(FALSE);
Last edited by ski6ski; 12-11-2001 at 08:54 AM.
C++ Is Powerful
I use C++
There fore I am Powerful
Hi ski6ski,
Actually I do program in C. VC++ is very new to me. So, can you help me little more.. Just tell me step by step from
Starting VC++
Click File from Menu
Select New
Select Win32 Application, put a project name, Press OK
.. .. ... ..
.. .. ... ..
This is the first time, I'm sure next time I will do better.
Zahid
Last edited by zahid; 12-11-2001 at 10:01 PM.
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
You are asking a lot there zahid.
Try a search on 'callback', 'winmain'
Look for links to Petzold's web site. He wrote the "Programming Windows" books, one of the best learning guides for WIN32 API programming.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
In this thread...
http://www.cprogramming.com/cboard/s...&threadid=6452
... towards the end, I gave this guy a step by step walk through to get his code to link, have a look at it. The message start "I did this, try the same...". Of course, if you want your own application, you can't use his source and header, but the basic steps are there for creating a Windows program.
Are you sure you want to write a windows program yet. A "Hello World" is normally done in a console.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Sorry I was using AppWizard. If you want to do it the hard way (code everything) then you will have to do it the way that Adrian or novacain suggested.
C++ Is Powerful
I use C++
There fore I am Powerful
Hello adrian,
I have tried your code, I compiled it, found no error, but it is not displaying anything.
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
Well, as I said, if you want your program to something specific, you'll have to code that up. Looking at his code, I would agree, it doesn't look like it is doing anything, he simply wanted a step by step guide to building an app with VC++, that is what you asked for!
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Yeah.. but I wanted
Enter your name: xyz
Enter 1st number : 10
Enter 2nd Number: 23
Hello XYZ, Sum of those numbers is: 33
This minimum functionality. Anyway.. I guess I have to study little more. Though I have tried, may be I have to try more to find the starting point.
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
Well, as I said before...
>>>
Are you sure you want to write a windows program yet. A "Hello World" is normally done in a console.
<<<
... I do not believe you need to write a Windows program to do this. As you have seen from the other guys code, even the simplest Windows program involves a lot before it actually does anything.
To do what you want in a console would take probably less than 20 lines of code.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
adrianxw has given you the window. If you MUST have a non console then ....
You need controls to get the input / display the output.
Look at CreateWindow()
Remember to cast the HMENU as the ID of the control ie
#define IDC_USERNAME 10001 //unique int ID code
then in the CreateWindow use (HMENU)IDC_USERNAME
Capture msg's to these controls in the callback with another switch for WM_COMMAND
ie
That is the next step.Code:case WM_COMMAND: idControl = GET_WM_COMMAND_ID( wParam, lParam) ; switch(idControl) { case IDC_USERNAME: //do your validation here / capture input here break;
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
I don't know am I finding windows programming difficult? I guess I'm missing proper guide line.
Can anyone suggest me the easiest reknown book for windows programming?
[ Never code before desk work ]
-------------------------------------:-->
A man who fears Nothing is the man who Loves Nothing
If you Love Nothing, what joy is there in your life.
=------------------------------------------------------= - I may be wrong.
As I said above
>>Look for links to Petzold's web site. He wrote the "Programming Windows" books, one of the best learning guides for WIN32 API programming.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill