I am currently trying to write a simple program that allows the user to click in the "view" to define the start of a line, draw a line from the start to the mouse (where ever the mouse moves to and while it moves) and then complete the line when the user clicks in the view again.
The only hangup that I'm having is that after I click in the view and begin to move the mouse, I end up drawing lines to everywhere the mouse goes and eventually the screen looks a mess with lines all over it. I understand why this happens, I just don't know how not to make it happen.
I'm missing something to "brush" over the old mouse position each time OnMouseMove is called. I've looked at some sample code but haven't been able to get it to work.
Other samples have mentioned using Memory DC's and Storing the view as a Bitmap.
Anyone out there got a simple solution?
I'm fairly confident that once someone explains how to accomplish this, I'll be able to figure out the rest.
I don't have a "DRAW" sample. I have a "DRAWCLI" sample.
If these are the same then I know what you're talking about. However, the code isn't very portable and is way to complex for what I'm trying to do. The DRAWCLI sample uses OLE and ties the drawtool objects into the drawview cview so tightly that it becomes very difficult to pull just the drawtool object into a project and put it to use. Eventually I suppose I could trim the code down and disect it to where it fit my needs.
An easy solution is to use an XOR pen. When you draw your line it'll be XORed with whatever is already on the screen. When the mouse moves draw the previous line again using the XORed pen (this will remove the previous line) and then draw the new line, again using the XORed pen.
This works because XOR is it's own inverse.
To actually code this you'll need to use the api function SetROP2 before drawing. This determines how GDI merges pens (and some other drawing objects too) with what's already on the screen.
The only disadvantge is that an XOR pen isn't a solid colour, rather it appears as the inverse of the colour on the screen. Of course, this might actually be a good thing as it ensures your line is always visible no matter what you draw over.
Hope that helps.
Mr.Prakash wrote: VC++ compiles code writen in C++ so If you write something in C++ that VC++ cannot compile then its not a VC++ code.
what ever that meant.
You can write C code. And LRESULT CALLBACK Name(...) is a callback declaration of a C function callback, not C++. lauren said it's a static function, and because this is a (V)C++ forum C++ is the first hand language so a callback function is a static function (member function actually).
Mr.Prakash wrote: and in VC++ CALLBACK is different not callback but CALLBACK (something the original poster has asked the question about).
I hope now its clear.
if so, lauren explained what a callback was? not the defination of CALLBACK...
Rickard Andersson Here is my card, contact me later! UIN: 50302279 Sonork: 37318
i have just created a MDI application using CFormView. I have created 3 user interfaces - let's say Form A,B,and C. in form A i created a push button. i want to call form b by clicking form A's push button. and i want to call form C by clicking form B's push button. so how do i do it? plz i need the answer as fast as i can. i doing my final project using VC++.
Basically, in the class hiearchy, you have the main frame window. This owns the toolbar, the menu, and the child frame windows. Each child frame owns it's form view. So, if you need to issue a command that affects a form in the frames, you first need to obtain a pointer into the target view's class. Then use standard dialog commands to issue commands.
In order for this to work, you need pointers to the child frame windows. If you don't have them, you can enumerate through the childs of the main frame window by using GetTopWindow, then running a series of GetNextWindow calls along with a test to IsChild function. After you have all the pointers into the child frames, call GetActiveView through them to get the CView objects. Then cast down to CFormView, and voila, call the necessary functions.
You should also consider redesigning your application a bit if you don't have the pointers to the child windows. Enumerating through them is really troublesome. The easiest thing is to have pointers to the CFormView objects. You can always cast backwards or use GetParent to move back through the class hiearchy.
The definition of impossible is strictly dependant
on what we think is possible.
You define difference as the current estimate squared minus the original square input by the user. The closer you get, the smaller the difference should be until it is less than the value .00001. In your while statement you are expecting the square of your estimated root minus the difference to get smaller. It won't converge.
For a start, change
while(difference >= .00001);
Also, before you evaluate the difference, replace it by its absolute value. A difference of -.000009 satisfies the algorithm, but will not pass the test in the while statement.
Will Build Nuclear Missile For Food - No Target Too Small