It took a while to sort things out but I have finally cracked it.
Based on the info I got from nv3 and Espen Harlin and a very instructive video I found http://msdn.microsoft.com/en-us/vstudio/cc843613
I introduced a custom dialog control Called CGraph based on class Cwnd and integrated it into my dialog box application.
Integrating it into the dialog box is ultimately dead easy once you know how. Simply adding a custom control to the dialog and specify its class to be "GraphClass" (see c++ code) does the trick.
It works very well now and does everything I want and expect it to do.
In reality its just another case of "Glaringly obvious once pointed out".
What really tricked me is that when the dialog box initialises windows is capable of and does work on the basis of the dialog box's main WM_PAINT message and subsequent OnPaint() function, it just never repeats it afterwards.
The result was that I did get the expected graph, the code faithfully executed again without any error but it did no more redraw.
Thanks for all the help.
This is the header file for the new class:
class CGraph : public CWnd
static TCHAR m_szWndClass;
afx_msg void OnPaint();
This is the bit of c++ code that handles it:
TCHAR CGraph::m_szWndClass = _T("GraphClass");
m_iCount = 0;
if (::GetClassInfo(AfxGetInstanceHandle(),m_szWndClass, &wndclass))
wndclass.style = 0;
wndclass.lpfnWndProc = ::DefWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = ::AfxGetInstanceHandle();
wndclass.hIcon = NULL;
wndclass.hCursor = NULL;
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = m_szWndClass;
int fdtest =1;
CPaintDC dc (this);
CPen lpen(PS_SOLID, 1, RGB(255, 0, 0));