Code for OnLButtonUp Message Map. // nnodes: total number of nodes added to the graph // nodeCount: current node selection state for adding edges (either 0 or 1) // FindNode: If the user clicks on an existing node, FindNode returns the index of that node. If user does not click on an existing node, FindNode returns -1. void CDykstraView::OnLButtonUp(UINT nFlags, CPoint point) { ~~ declare local variables. switch(state) { case: ADDNODES nodes[nnodes++] = new Node(point); break; case: ADDEDGES // If first node not selected yet if (nodeCount == 0) { fromNode = FindNode(point); if (fromNode != -1) nodeCount++; } else { toNode = FindNode(point); if (toNode != -1) { ~~ Show modal dialog to get cost. ~~ Add two directed edges to CEdge array. } ~~ Update node array. ~~ reset nodeCount back to 0 } break; case: SETSTART index = FindNode(point); if (index != -1) startnode = index; break; case: SETDEST ~ Look at case SETSTART. break; } Invalidate(); }