SRGraphComponent::DrawingUsing

voidSRGraphComponent::DrawingUsing(CDC *pDC, CWnd *pCWnd)

Sets the m_pDC, m_pCWnd, and m_bDrawing members

Defined in: SRGComp.cpp

Parameters

pDC

Pointer to a valid CDC for the drawing processes

pCWnd

Pointer to a CWnd object in which drawing will take place

Example

The following code segment shows how to draw a wiget in response to a mouse click, for example:

SRGraphDisplay *pD = (SRGraphDisplay *)GetGraph()-&gtGetComponent(0,IDS_SRG_DISPLAYTYPE);
if(pD!=NULL)
{
               CDC *pDC=GetDC();
               GetGraph()-&gtDrawingUsing(pDC, this);
               pD-&gtDrawingUsing(pDC, this);
               CPoint datapoint= [ omitted ]
               SRGraphStyle * pStyle = GetGraph()-&gtGetDefaultDataStyle();
               pD-&gtDrawWiget(datapoint,pStyle);
               pD-&gtNotDrawing();
               GetGraph()-&gtNotDrawing();
               ReleaseDC(pDC);
}

Developer Notes

Use this function before accessing any component drawing or sizing functions outside the normal drawing process -- DrawComponentList(). During DrawComponentList() processing, this routine is not needed because all relevant information is given at draw time. However, if the component is created ad-hoc by either the standard or custom software or the component functions are being used outside the draw process, there is a need to tell the component which CDC and CWnd objects are being used. This is required because certain operations, like the use of fonts or the measurement of logical pixel sizes, depend upon a valid CDC object being available.
This routine is used by some of the updated display routines which create and destroy new component objects themselves.
For example, an SRGraphDisplay component may create a label block on the stack, fill the block with labels, and then test the labels for sizes before adjusting the display rectangle to its final size. In order to test the labels without actually drawing them, the label block requires the m_pDC and m_pCWnd from the display object so that things like GetOutputTextExtent() work properly.

See also...

 SRGraph::DrawComponentList  SRGraph::DrawingUsing  NotDrawing