MFC art program

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

Join Date: Dec 2004
Posts: 489
Reputation: Acidburn is an unknown quantity at this point 
Solved Threads: 5
Acidburn Acidburn is offline Offline
Posting Pro in Training

MFC art program

 
0
  #1
Feb 1st, 2006
Hello, I'm wanting to print a circle to a screen, or should I say on a form. Any ideas?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: MFC art program

 
0
  #2
Feb 1st, 2006
Originally Posted by Acidburn
Hello, I'm wanting to print a circle to a screen, or should I say on a form. Any ideas?

Thanks
Here
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: MFC art program

 
0
  #3
Feb 2nd, 2006
Originally Posted by WolfPack
Here
Or betta still use c# or java, it takes away most of the pain of using MFC. :mrgreen:
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 489
Reputation: Acidburn is an unknown quantity at this point 
Solved Threads: 5
Acidburn Acidburn is offline Offline
Posting Pro in Training

Re: MFC art program

 
0
  #4
Feb 2nd, 2006
I get this error when trying to call a premade function:

g:\University work\Year 2\GUI\Hangman\HangmanDlg.cpp(98): error C2373: 'Ellipse' : redefinition; different type modifiers
Whilst I'm not understanding the code very well, I've gone away and implemented a print function:

  1. void classname::print()
  2. {
  3. BOOL Ellipse(
  4. HDC hdc, // handle to DC
  5. int nLeftRect, // x-coord of upper-left corner of rectangle
  6. int nTopRect, // y-coord of upper-left corner of rectangle
  7. int nRightRect, // x-coord of lower-right corner of rectangle
  8. int nBottomRect // y-coord of lower-right corner of rectangle
  9. }
  10. ...
  11.  
  12. print();
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: MFC art program

 
0
  #5
Feb 2nd, 2006
Looks like you are trying to call the Ellipse function provided by the Windows API. Then you dont have to redefine it inside the
  1. void classname::print()
function. Just call it like this.
  1. void classname::print
  2. (
  3. HDC hdc, // handle to DC
  4. int nLeftRect, // x-coord of upper-left corner of rectangle
  5. int nTopRect, // y-coord of upper-left corner of rectangle
  6. int nRightRect, // x-coord of lower-right corner of rectangle
  7. int nBottomRect // y-coord of lower-right corner of rectangle
  8. )
  9. {
  10. Ellipse( hdc, nLeftRect, nTopRect, nRightRect, nBottomRect );
  11. // Do other stuff you want inside the print function
  12. //...
  13. }

Then call it like this
  1. classname classobject;
  2. classobject::print( hdc, 10, 100, 30, 140 );

If you get errors, better post the code.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 489
Reputation: Acidburn is an unknown quantity at this point 
Solved Threads: 5
Acidburn Acidburn is offline Offline
Posting Pro in Training

Re: MFC art program

 
0
  #6
Feb 2nd, 2006
I get one more error:

g:\University work\Year 2\GUI\Hangman\HangmanDlg.cpp(93): error C2065: 'hdc' : undeclared identifier
I've edited the following:

the print protoypte now reads:

  1. void print(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);

implemenation now reads:

  1. void CHangmanDlg::print
  2. (
  3. HDC hdc, // handle to DC
  4. int nLeftRect, // x-coord of upper-left corner of rectangle
  5. int nTopRect, // y-coord of upper-left corner of rectangle
  6. int nRightRect, // x-coord of lower-right corner of rectangle
  7. int nBottomRect // y-coord of lower-right corner of rectangle
  8. )
  9. {
  10. Ellipse( hdc, nLeftRect, nTopRect, nRightRect, nBottomRect );
  11. }

whilst calling it inside a button which is:

  1. void CHangmanDlg::OnBnClickedCancel()
  2. {
  3. CHangmanDlg::print(hdc, 10, 100, 30, 140 );
  4.  
  5. OptionsDlg dlg;
  6. dlg.DoModal();
  7. }


Hmm any ideas?

cheers for your assistnce so far
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: MFC art program

 
0
  #7
Feb 2nd, 2006
Just do this.

  1. void CHangmanDlg::print
  2. (
  3. int nLeftRect, // x-coord of upper-left corner of rectangle
  4. int nTopRect, // y-coord of upper-left corner of rectangle
  5. int nRightRect, // x-coord of lower-right corner of rectangle
  6. int nBottomRect // y-coord of lower-right corner of rectangle
  7. )
  8. {
  9. CDC* pcdc = this->GetDC();
  10. if ( pcdc)
  11. {
  12. pcdc->Ellipse( nLeftRect, nTopRect, nRightRect, nBottomRect );
  13. if ( this->ReleaseDC( pcdc ) > 0 )
  14. {
  15. // Successfully Released
  16. }
  17. else
  18. {
  19. // Error in Releasing Device Context
  20. }
  21. }
  22. }

  1. void CHangmanDlg::OnBnClickedCancel()
  2. {
  3. CHangmanDlg::print(10, 100, 30, 140 );
  4. OptionsDlg dlg;
  5. dlg.DoModal();
  6. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 489
Reputation: Acidburn is an unknown quantity at this point 
Solved Threads: 5
Acidburn Acidburn is offline Offline
Posting Pro in Training

Re: MFC art program

 
0
  #8
Feb 2nd, 2006
Originally Posted by WolfPack
Just do this.

  1. void CHangmanDlg::print
  2. (
  3. int nLeftRect, // x-coord of upper-left corner of rectangle
  4. int nTopRect, // y-coord of upper-left corner of rectangle
  5. int nRightRect, // x-coord of lower-right corner of rectangle
  6. int nBottomRect // y-coord of lower-right corner of rectangle
  7. )
  8. {
  9. CDC* pcdc = this->GetDC();
  10. if ( pcdc)
  11. {
  12. pcdc->Ellipse( nLeftRect, nTopRect, nRightRect, nBottomRect );
  13. if ( this->ReleaseDC( pcdc ) > 0 )
  14. {
  15. // Successfully Released
  16. }
  17. else
  18. {
  19. // Error in Releasing Device Context
  20. }
  21. }
  22. }

  1. void CHangmanDlg::OnBnClickedCancel()
  2. {
  3. CHangmanDlg::print(10, 100, 30, 140 );
  4. OptionsDlg dlg;
  5. dlg.DoModal();
  6. }
Thanks for the reply, it seems to have done the trick, is they a way of getting a set of co-ordinates on the screen? I want it the fursthers right but a very small cirlce. I've been filling it with some radmon but logical numbers and not getting very far

I also have a few more questions. Can I chose not to fill the circle? so its just an outline? Also can I draw lines with this code? or is that something to do with the paintbrush?

Also can I change the background colour of the entire mfc window? I can't find that in the properities of the dlg box anywhere.

Thanks

John
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: MFC art program

 
0
  #9
Feb 2nd, 2006
is they a way of getting a set of co-ordinates on the screen? I want it the fursthers right but a very small cirlce. I've been filling it with some radmon but logical numbers and not getting very far
Sorry but I dont know what you mean. What were the values you used and what do you mean by you didnt get very far? Maybe a problem with the mapping mode. Look for CDC::MapMode()
Can I chose not to fill the circle? so its just an outline? Also can I draw lines with this code? or is that something to do with the paintbrush?
Yes you can. And yes, it has to do with the paintbrush. And I think also with the CPen Object you select. Go through the documentation for CPen and CBrush in MSDN.
Also can I change the background colour of the entire mfc window? I can't find that in the properities of the dlg box anywhere.
Maybe not in Visual C++ 6.0. But I think it was possible in Visual Studio .NET. Anyway do it programmatically. You could probably do it by using the CDC:etBkColor() method. You will have to search for the COLORREF datatype also.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 489
Reputation: Acidburn is an unknown quantity at this point 
Solved Threads: 5
Acidburn Acidburn is offline Offline
Posting Pro in Training

Re: MFC art program

 
0
  #10
Feb 2nd, 2006
As regards to question 1 I'm trying to put the circle at a set point on the screen. See here:

www.bsc-coding.com/temp/screenie.png

However I'm finding myself entering different co-ordinates and getting different shapes but none of the desired ones.

As for changing the background color I've located the function which is virtual so I've tried to include my own understanding of implementation which can be as followed:

  1.  
  2. //optionDlg.cpp file
  3.  
  4. static COLORREF i = 0x2555555;
  5.  
  6. ..
  7. ..
  8. ..
  9. COLORREF OptionsDlg::SetBkColor(COLORREF crColor )
  10. {
  11. return crColor;
  12. }

but nothing changes I've edited the cancel button to display a message box and the call that SetBkColor but nothing happens... can anyone assist in this dept?

Thanks for your patience, it seems like the msdn is not very clear at explaing things at all!
Reply With Quote Quick reply to this message  
Reply

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



Other Threads in the C++ Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC