MFC help

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 12
Reputation: Sarlacc is an unknown quantity at this point 
Solved Threads: 0
Sarlacc Sarlacc is offline Offline
Newbie Poster

MFC help

 
0
  #1
Mar 4th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 670
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: MFC help

 
0
  #2
Mar 4th, 2009
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
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 12
Reputation: Sarlacc is an unknown quantity at this point 
Solved Threads: 0
Sarlacc Sarlacc is offline Offline
Newbie Poster

Re: MFC help

 
0
  #3
Mar 4th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 359
Reputation: jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice 
Solved Threads: 69
jencas jencas is offline Offline
Posting Whiz

Re: MFC help

 
0
  #4
Mar 4th, 2009
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.
If you are forced to reinvent the wheel at least try to invent a better one!

Please use code tags - Please mark solved threads as solved
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 12
Reputation: Sarlacc is an unknown quantity at this point 
Solved Threads: 0
Sarlacc Sarlacc is offline Offline
Newbie Poster

Re: MFC help

 
0
  #5
Mar 17th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,334
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1454
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: MFC help

 
0
  #6
Mar 17th, 2009
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).
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 12
Reputation: Sarlacc is an unknown quantity at this point 
Solved Threads: 0
Sarlacc Sarlacc is offline Offline
Newbie Poster

Re: MFC help

 
0
  #7
Mar 17th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,334
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1454
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: MFC help

 
0
  #8
Mar 17th, 2009
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()
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 12
Reputation: Sarlacc is an unknown quantity at this point 
Solved Threads: 0
Sarlacc Sarlacc is offline Offline
Newbie Poster

Re: MFC help

 
0
  #9
Mar 17th, 2009
would it make more sense to have the images being loaded rather than having them in the resources section?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,334
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1454
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: MFC help

 
0
  #10
Mar 17th, 2009
Not necessarily -- if the images will never change then just put them in the resource section.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC