I can’t suggest a method to identify the drawn object from DC and modify the same.
But you can implement the above requirements (change shape of drawn objects) by following design.
Prepare separate classes for each graphic item, like Rectangle, Line, Triangle etc. These classes should be derived from a common base class, say it
virtual void Draw();
virtual bool IsInside( POINT ptMousePos);
virtual void MouseMove( POINT ptMousePos);
class GraphicRectangle: public GraphicBase
bool IsInside(POINT ptMousePos);
void MouseMove( POINT ptMousePos);
Here Draw() is used to draw a graphic object. IsInside() is used to identify whether an object is inside the graphic object. MouseMove() LButtonDown() and LButtonUp is used to resize the graphic item.
Main class( Dlg class) will hold all graphic items in a list, and whenever a mouse down recives in Dlg class, it will call IsInside() of all graphic items to idntify the graphic item need to be resized. Say it as m_pActiveGraphicItem. After that mouse move messages will send to the active graphic item, m_pActiveGraphicItem. The change in mouse movement is identified to apply resize action of the graphic item. Whenever mouse up received in Dlg class, it will stop resize action[By assigning
After each mouse movement, invalidating the entire client area to redraw all graphic items.
OnPaint() of Dlg class will be like this
for( i=0;m_GraphicItems.size(); i++)
to redraw the rectangle in new size. The intended DC should be shared to all Graphic items in any method, as static member function, or keep it as a protected member in
IsInside() of each graphic item should return whether incoming point is inside the graphic item or not. Please use HRGN or other method to identify the mouse position is inside the region of graphic item.