Hello, I don't know MFC but seeing some net samples I think it will be similar except by calling the object class (and I suppose more other differences of course), but I think you'll find it usefull.

To draw a line using LineTo you have to set previously a pen or a brush; from the reference of LineTo function:

Code:
...
The line is drawn by using the current pen and, if the pen is a geometric pen, the current brush.
...
So if you want to select a pen or a brush you use SelectObject(HDC , HGDIOBJ ) where HGDIOBJ can be several types (bitmap, brush, pen, region and font); so if you have a pen you simply set it to the hdc.

In the other hand you have to create a pen (or a brush, or a font) or you have the option to get it from the default set of stock objects through the GetStockObject. This function returns a HGDIOBJ althought you can request several object types.

Code:
HPEN hpen = (HPEN)GetStockObject(BLACK_PEN);
HPEN holdpen = (HPEN)SelectObject(hdc, hpen);

or
HBRUSH hbrush = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
HBRUSH holdbrush = (HBRUSH)SelectObject(hdc, hbrush);
This works because HGDIOBJ is defined as a void pointer (void *), so you can typecast to other object types.

I don't know MFC, but in the 'standard' application procedures you have to catch the WM_PAINT in order to draw (ok, not only the WM_PAINT message is the only way to draw), so on the application load you create the brush (or the pen) or you acquire it from the stock objects, on the paint message you use it and on the unload you destroy it (if created). On the paint when you select an object the function returns the current object of the same type (which you are about to replace. So once you finished to do the drawing operations you have to restore the old objects.

A very simple lines of code to show what I was trying to explain :

Code:
/**
* global variables
*/
HBRUSH hRedBrush;


/**
* on loading application
*/
hRedBrush = CreateSolidBrush(0x000000ff);


/**
* on paint
*/
PAINTSTRUCT ps;
HDC hdc;
HBRUSH hPrevBrush;

hdc = BeginPaint(hwnd, &ps);

//select the brush for the line
hPrevBrush = (HBRUSH)SelectObject(hdc, hRedBrush);

//place line start line and draw it
MoveToEx(hdc, 0, 0, 0);
LineTo(hdc, 10, 10);

//restore brush
SelectObject(hdc, hPrevBrush);

EndPaint(hwnd, &ps);


/**
* on unload application
*/
DeleteObject(hRedBrush);
As I comment I don't know MFC, but I seen some examples on the net about MFC and the functions are the same, except they are inse the object class (like CBrush::CreateSolidBrush()).

Hope that helps

Regards
Niara