_duDE_'s largely hit the problem on the head - at least as far as the cause goes: If pDC is a pointer to a CDC object you can't cast it to a Windows GDI HDC. If you dereference the pointer first (the way _duDE_ does) the cast function in CDC kicks in and you'll get the HDC. However that's a bit clunky and a bit hard to follow if you don't know what you're up to.
So here's a bit of advice - stop casting and use automatic type deduction! You don't need casting in this case AND you never need a C style cast in C++. Instead why not just not read the HDC from the CDC object? I'd suggest:
auto hdc = pDC->m_hDC;
and let the compiler deduce the type of hdc AND subsequently warn you if you try and use the object in a weird way.