Help On Graphics

plz some body tell me how to make a button like thing on c++. I mean something with the shape of an elongated ellipse. Also it would be a great help if u could explain the code to make an ellip.

Our answer depends on what graphics library you want to use-SFML, SDL, Allegro, Ogre etc. The process and approaches for creating buttons varies from library to library.

I'd suggest SFML. Here's how ellipses are made in SFML :
Thanks for your help. But sfml looks more complicated to me. I want to know about graphics.h library and the function ellipse(some_parameters); . well the thing i was unable to understand is these parameters. It says about some angles i think and i dont understand whats that. Thanks for help.
Are you using turbo C++ ? I think graphics.h is too old to run on newer os's ? (if i'm not mistaken?) i recommend better using windows.h library

By the way a google for ellipse function on graphics.h gave me:

Or if you want win32 which is i think a little harder:
thank you very much. It was very help full.
FWIW... making buttons usually does not involve actually drawing the button yourself. Most widget APIs just let you create a button with a single function call. They'll handle the drawing, tabbing, etc etc automatically, and will forward user clicks to you in the form of a "message" or "signal".

So rather than looking for an Eclipse function, you should be looking for a CreateButton function.

The downside is... widgetry libs are big... and usually complicated to get set up. I'm a fan of wxWidgets, but Qt is also very good. If you don't care about portability, you can use WinAPI directly... though I find WinAPI very frustrating to work with.
can you help me with the code to make button. I just want to call a function on clicking the button. Thanks!
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:

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.
Topic archived. No new replies allowed.