note: I'm assuming you are using the console. If I'm wrong, please correct me
can you help me with the code to make button. I just want to call a function on clicking the button. Thanks! |
Well it's like I said... widgetry libs are big and complicated. Creating a button is relatively simple once you have a window... but first you'd have to create the window, set up an event pump, etc, etc.
In WinAPI, a pushbutton can be created with code as shown in this thread:
http://cboard.cprogramming.com/windows-programming/51846-making-standard-button-win32.html
From there, Windows will send a WM_COMMAND message to your window whenever the button is pressed, which you can intercept and call whatever function you want.
Of course... out of context, that code will do you no good. You can't just drop it into your console program. You need to create a different kind of program -- you need to create a widgetry program.
So sadly, there is no simple solution here. You may have come to the point where you need to leave the console. Which means you're going to have to learn a whole new style of programming. You might want to look up some tutorials on getting started with WinAPI.
Or if you want a crossplatform solution, look into wxWidgets or Qt. There are lots of tutorials available for them as well.. but they are libs you will have to download/install/set up.