Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 6146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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
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

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!