   [DirectX9 C++] - Creating a selection rerctangle.
  Hi, i am trying to implement a feature seen in so many games and applications :click & drag so that a rectangle is being drawn. Mostly used for selecting things within the drawn rectangle. So i would like to know if there is some common technique/code in doing it.  What i need is:1)I click on my rendering window - dragging starts - DONE with DirectInput2)As long as i am dragging a rectangle is drawn. Its one corner is the point i clicked and its other is the current point of the cursor. 3)Detect stop dragging them do stuff - DONE.So actually i want (2). A way to draw a rectangle depending on mouse state and position. If there is some fast solution, let me know.  Thanx in advance,stakon.   
  Simple versionOn WM_LBUTTONDOWNCreate a rectangle using mouse pos as top/left and bottom/rightSet a bool to say you are draggin, m_bDragging = true;On WM_MOUSEMOVEif (m_bDragging) Get current mouse pos into rect right/bottom ste a flag for renderer so it knows to draw the rectangle invalidate view to redraw itOn WM_LBUTTONUPif (m_bDragging) Get final mouse pos into rect right/bottom Set m_bDragging = false invalidate again to render viewIn your renderer if you have a rectangle, draw it. Might need the sides swapping so left is left of right, top is above bottom.Is that the kind of thing you are looking for?;  Get mouse position on mouse down event, get mouse position on each mouse move event. With these two points, create a vertex buffer with the four line segments and render it as a D3DPT_LINELIST.;  Hi,that was fast!I thought about the same method. What i am looking for is a way to do this with directX. Some ideas: I have a vertexbuffer  p_VB;on click: Set p_VB 's start pointon drag : Set p_VB 's endpoint + calculate rectangle's other 2 points.on_render: if(dragging) Set_StreamSource(p_VB) + DrawLinePrimitives(4) As a method it's pretty straightforward, so i hoped there was a quick sample code to use instead wasting an hour to implement something that common.