Need some help on how to create a Line and how to move that line using mouse options
-
Hello, This is Venkatesh, I am working on VC++ (MFC). Currently i am working on one application which deals with the graphs and lines. i want to create one line and have to move (drag) that line horizotally from one end to other using mouse. Can any one help me out regarding this...? Any help would be much appreciated, because as it is very urgent requirement for me.. Thanks Venkatesh. :)
-
Hello, This is Venkatesh, I am working on VC++ (MFC). Currently i am working on one application which deals with the graphs and lines. i want to create one line and have to move (drag) that line horizotally from one end to other using mouse. Can any one help me out regarding this...? Any help would be much appreciated, because as it is very urgent requirement for me.. Thanks Venkatesh. :)
You need to declare WM_MOUSEMOVE and WM_LBUTTONUP/DOWN and you need to get current postion of mouse with GetCursorPos and then you can use of LineTo/MoveTo.
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
-
Hello, This is Venkatesh, I am working on VC++ (MFC). Currently i am working on one application which deals with the graphs and lines. i want to create one line and have to move (drag) that line horizotally from one end to other using mouse. Can any one help me out regarding this...? Any help would be much appreciated, because as it is very urgent requirement for me.. Thanks Venkatesh. :)
In addition to what Hamid said, you will also have to set the raster operation code to
R2_XORPEN
when you draw your line. Doing so you will be able to draw the line once to show the line, and then draw it again in the same spot to erase the line. UseCDC::SetROP2(R2_XORPEN)
in your drawing code.
You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!
-
Hello, This is Venkatesh, I am working on VC++ (MFC). Currently i am working on one application which deals with the graphs and lines. i want to create one line and have to move (drag) that line horizotally from one end to other using mouse. Can any one help me out regarding this...? Any help would be much appreciated, because as it is very urgent requirement for me.. Thanks Venkatesh. :)
You can use Rubberbanding[^] to create the line. (Ivor Horton is the best author to reference for sample graphics applications using MFC :) ) To interact with it you could simply use CRectTracker with a few modifications if you don't mind a simple rectangular hit test region. This is more than adequate for forms based line manipulations since a good portion or the lines will be vertical or horizontal. If you need more advanced hit testing that is not restricted to a rectangle, such as for an advanced graphics application, then you will likely need to roll your own tracker class.
-
You need to declare WM_MOUSEMOVE and WM_LBUTTONUP/DOWN and you need to get current postion of mouse with GetCursorPos and then you can use of LineTo/MoveTo.
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
-
In addition to what Hamid said, you will also have to set the raster operation code to
R2_XORPEN
when you draw your line. Doing so you will be able to draw the line once to show the line, and then draw it again in the same spot to erase the line. UseCDC::SetROP2(R2_XORPEN)
in your drawing code.
You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!
-
You can use Rubberbanding[^] to create the line. (Ivor Horton is the best author to reference for sample graphics applications using MFC :) ) To interact with it you could simply use CRectTracker with a few modifications if you don't mind a simple rectangular hit test region. This is more than adequate for forms based line manipulations since a good portion or the lines will be vertical or horizontal. If you need more advanced hit testing that is not restricted to a rectangle, such as for an advanced graphics application, then you will likely need to roll your own tracker class.