DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   MFC help (http://www.daniweb.com/forums/thread179843.html)

Sarlacc Mar 4th, 2009 6:27 am
MFC help
 
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

Freaky_Chris Mar 4th, 2009 6:38 am
Re: MFC help
 
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

Sarlacc Mar 4th, 2009 6:49 am
Re: MFC help
 
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

jencas Mar 4th, 2009 8:47 am
Re: MFC help
 
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.

Sarlacc Mar 17th, 2009 12:27 pm
Re: MFC help
 
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?

Ancient Dragon Mar 17th, 2009 1:05 pm
Re: MFC help
 
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).

Sarlacc Mar 17th, 2009 2:46 pm
Re: MFC help
 
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.

Ancient Dragon Mar 17th, 2009 3:08 pm
Re: MFC help
 
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()

Sarlacc Mar 17th, 2009 3:15 pm
Re: MFC help
 
would it make more sense to have the images being loaded rather than having them in the resources section?

Ancient Dragon Mar 17th, 2009 3:35 pm
Re: MFC help
 
Not necessarily -- if the images will never change then just put them in the resource section.


All times are GMT -4. The time now is 5:53 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC