How do i go about creating an app in mfc where there is a series of buttons and when you press one it loads an image, then if you press another one a different image loads?
i am using vc++ 2008 to do this

Well you need to give us a starting point as to what you have, my suggestion is that you have an image placeholder thingy, and then change the source of it when each button is pressed, ofcourse I can't use any technical names because I dis-like MFC :)

Chris

ok, at the moment i have the buttons in place but there not actually doing anything and i used the picture control for the image but at the moment thats just one static image

Member Avatar for jencas

Did you build the dialog with the vs2008 resource editor?
If yes, click the right mouse button while selecting the dialog in the resource editor and create a dialog class. After that double click the button and create an event handler as member of your new dialog class.

Im affraid im a little lost at the moment. I tried creating a new class, which i assume you meant a c++ class. But once ive done that and double clicked the button i dont quite know where to go, or what i should write in the class.

What i want is for each button to display a different picture so what would need to go in the class for selecting each pic?

you need to write an event handler for each of those buttons. Inside the event handler is where you put the code to load and display the image you want. As I recall, to create an event handler function for a button just right-click the button and you will see the option(s).

I understand the event handler side of things as the buttons I have are already being used to play a wav file once pressed, its just what I need to put in the class that was suggested.

I have 13 buttons representing notes on a piano keyboard and want to display like A, A#, B and so on in pictoral form and I have 13 images which are easy enough to display statically.

The class that was Jencas previously mentioned was of type CDialog. He was trying to describe how to create an event handler, which apparently you already know how to do.

You said in your original post you want to "load and image" when you hit a button. All that involves is LoadBitmap()

would it make more sense to have the images being loaded rather than having them in the resources section?

Not necessarily -- if the images will never change then just put them in the resource section.

Theres the option to loadbitmap and loadimage. do either of these load the picture into something like the picture control so that the image appears there when the button is pressed.

Do you know of any useful sites that show how to use these functions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.