This is a guess so please forgive me if it doesn't work (I don't use mfc).
Code:
void CMouseDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
/*nChar is a UINT to cover UNICODE and ANSI so there's little point in casting it*/
/* similarly your HCURSOR is a local variable (does mfc, automatically free cursor resources when they go out of scope?)*/
switch (nChar)
{
case TEXT('A'):
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW);
break;
case TEXT('B'):
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_IBEAM));
break;
case TEXT('C'):
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
break;
case TEXT('X'):
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
OnOK();
break;
default:
m_bCursor = TRUE;
::SetCursor(0); //? not sure about this
}
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
If that works ok then the original problem was that your HCURSOR was of local scope and therefore died off at the end of the fn. Try defining it with class scope.
Sorry for re-writing your code - it was to make it easier for simple me to follow.
I hope that's of some use to you.