Just construct an instance of
CSafeWaitCursor
at the begining of your
OnClick()
-reaction :) :
class CYourApp : public CWinApp
{
bool m_bShielded;
public:
void SetShielded(bool bSet) { m_bShielded = bSet; }
bool IsShielded() const { return m_bShielded; }
};
BOOL CYourApp::PreTranslateMessage(MSG* pMsg)
{
if (IsShielded()) {
if ((pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) ||
(pMsg>= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)) {
return TRUE;
}
}
return CWinApp::PreTranslateMessage(pMsg);
}
class CSafeWaitCursor
{
public:
CSafeWaitCursor()
{
CYourApp* pcApp = (CYourApp*) AfxGetApp();
pcApp->SetShielded(true);
pcApp->DoWaitCursor(1);
}
~CSafeWaitCursor()
{
CYourApp* pcApp = (CYourApp*) AfxGetApp();
pcApp->SetShielded(false);
pcApp->DoWaitCursor(-1);
}
};