Where in the book did you EVER see the term "built in variable"???
Printable View
I tried to use this to base my object on :
http://www.codeguru.com/forum/archiv.../t-262641.html
I thought that I was declaring a pointer to the Window of where the object was called from (ie, my View class).
Do you mean where was m_pWnd first defined? That, I do not know.
Would it be better for me to use ::GetDC as mentioned before?
I hate to break this to you, but you can't get a C++ project done with this type of attempt of learning both the C++ language and Windows programming. Regardless of what it seems, the type of program you're attempting to write assumes you know C++ already to the point of understanding fully or (close to fully) classes, pointers, objects, etc.
As TheCPUWizard pointed out, a lack of understand of C++ (forget about graphics) is the issue. All member variables, whether they are pointers to CWnd, pointers to doubles, or pointers to anything you want, must be initialized before using them (i.e. dereferencing them).
Not knowing what your own program is doing doesn't bode too well for your assignment...Quote:
Do you mean where was m_pWnd first defined? That, I do not know.
And what is the window handle (HWND) you will be using as the argument to this function?Quote:
Would it be better for me to use ::GetDC as mentioned before?
Regards,
Paul McKenzie
Yeah - tell me about it hah! When I started this project I assumed my supervisor would be able to guide me in learning C++ while I do this project. I've done a little in a module, but we've mostly been taught Java.
I appreciate that my whole approach is wrong, but theres not much I can do about it now really - I *have* to make some attempt at getting this done.
The main part of my project is moving shapes around - I've done this with the help of the "tracker" example, but I want to be able to create more than one shape to move around so I thought the best way would be to use objects.
Once I figure out the drawing stuff I should be able to progress a little - though no doubt find a whole new bunch of problems.
Like I said, I know its a rubbish way of going about it, but not even my project supervisor.. who is a lecturer in the University and set the project!!!! knows how to do this..
Gareth
hmm anyone? :(
You might want to check out the DRAWCLI sample from MSDN. It uses drawing objects with their own drawing routines and has tracker rects for selecting and moving, bu it is a pretty complicated project.
http://msdn.microsoft.com/en-us/library/9t94971d.aspx
To draw on a window, you need the windows device context, which means you must have a valid HWND that represents that window to get the device context. A CWnd is nothing more than an MFC class that wraps an HWND.
Your original code created a class that has no relationship at all with anything to do with a window or an HWND, but you tried to make it a CWnd by casting. In effect, you were trying to turn an concrete block into gold. Given this, the obvious explanation that is brief enough is to make sure you have a window handle so that you can get its device context.
Other than that, no message board is going to give you an in-depth explanation of MFC, Windows, HWND's or CWnd's. That is in the realm of books and sample programs.
Regards,
Paul McKenzie
A choice....
1) Spend a few weeks/months properly learning what you need to know.
2) Pay someone who has invested the requisite time.
Since this is (I believe) a school assignment, option #2 would be considered cheating.
A final alternative would be to ask the instructor (in writing) to provide (again in writing) references to the material that was covered in the class [or is documented as a pre-requisite for the class] that would provide you with sufficient information to know how to properly program with MFC classes (or even Win32 API calls) ....
Thanks for the help so far Paul - even though I'm not really getting anywhere I do feel I'm beginning to understand a little more.
I appreciate that its probably not "the done thing" to code things for people, but all I was after was a quick and rough example of how to draw from a separate object - not an in depth tutorial.
I'd love to actually understand what I'm doing a lot more... but alas - that won't actually go that far to help me pass my degree. Counter-intuitive, I know!
Cheers
Gareth