win32/beginner

Started by
2 comments, last by epp289 22 years, 6 months ago
Hello. I would like to ask you something on win32 API.I have already downloaded some tutorials from the Internet. I understood the basics. But I found it difficult for me to make a little more complex program. For example I would like to make a simple dialog box in which there are 2 edit boxes where you type 2 numbers. When you press a button then the sum of these 2 numbers must be displayed in a label (or on the title or maybe on buttons’ caption) How I can program it? Help me please
Advertisement
if you are using MSVC....
then create a dialog in the resource editor with the edit boxes and the push button and the label.
Then look into the funcntion
DialogBox(....................);
to create the dialo0g box that you made in the resource editor.
Then look into the SendMessage(..........) function to retrieve information from the dialog box such as the values placed in the edit boxes. Then when you detect that the button was pressed, ,get the values out of the edit boxes with SendMessage(.........), add them together, and place the answer in the label with SendMessage(...........)

"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T
i suggest you look up GetDlgItemText() SetDlgItemText()
Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.
You need to call the GetDlgText function(may not be correct spelling and I forget the exact parameters) on both edit boxes and have 2 variables to store these numbers. Then add them and display them using sprintf()[need stdio.h for this] to form a whole string that say something like The sum of so and so is so and so.

If you aren''t familiar with sprintf, here is how you use it:

sprintf(string_to_write_too, "Here is the sum: %d", sum);

That will put the string "Here is the sum: --" and fill in the -- with the actual sum. If you knew how to use printf then that should be familiar to you. Its the only easy way to put numbers in an integer form right into a character string. The %d means that the first parameter after the string will be an integer, and any following %d''s in the string will correspond to additional parameters. Note that you need to use other special characters for other data types.

"Ogun''s Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.
"Ogun's Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.

This topic is closed to new replies.

Advertisement