Try this: Use the SetLayeredWindowAttributes like this :
for (int opacity = 0; opacity <= 255; opacity++)
{
::SetLayeredWindowAttributes(hWnd, RGB(0,0,0), opacity, LWA_ALPHA);
Sleep(20) ;
}
This will fade out the hWnd window in approximately 5 seconds. The hWnd window must be created with the WS_EX_LAYERED extended style.