Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy doesn't the OnDraw suffice (in MFC, Scribble tutorial)
    primarykey
    data
    text
    <p>I'm making the Scribble tutorial to learn MFC and there's this code on the MouseMove event:</p> <pre><code>void CScribbleView::OnMouseMove(UINT nFlags, CPoint point) { // Mouse movement is interesting in the Scribble application // only if the user is currently drawing a new stroke by // dragging the captured mouse. if( GetCapture( ) != this ) return; // If this window (view) didn't capture the // mouse, the user isn't drawing in this window. // Add the new point to the current stroke m_pStrokeCur-&gt;m_pointArray.Add(point); CClientDC dc( this ); // Draw a line from the previous detected point in the mouse // drag to the current point. CPen* pOldPen = dc.SelectObject( GetDocument( )-&gt;GetCurrentPen( ) ); dc.MoveTo( m_ptPrev ); dc.LineTo( point ); dc.SelectObject( pOldPen ); m_ptPrev = point; CView::OnMouseMove(nFlags, point); } </code></pre> <p>And this one on the draw function of the stroke (which is called by the OnDraw of the view):</p> <pre><code>BOOL CStroke::DrawStroke( CDC* pDC ) { CPen penStroke; if( !penStroke.CreatePen(PS_SOLID, m_nPenWidth, RGB(0,0,0))) return FALSE; CPen* pOldPen = pDC-&gt;SelectObject( &amp;penStroke ); pDC-&gt;MoveTo( m_pointArray[0] ); for( int i=1; i &lt; m_pointArray.GetSize(); i++ ) { pDC-&gt;LineTo( m_pointArray[i] ); } pDC-&gt;SelectObject( pOldPen ); return TRUE; } </code></pre> <p>I've checked this function is being called on every frame update. However, if I take away the drawing on the mouse move event, it won't happen anything, even though I'm registering all the strokes and the draw stroke function is being called. Only if I make changes to the window (like maximizing) will the then appear.If the function </p> <p>is being called, why doesn't it draw on the window? I'm trying to figure out the inner workings of MFC here, it's not a bug or anything.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload