Dear all,
i have developed an application and the one thing that kept me busy i
the cursor.
From the MainFrm file i start an Interface Thread which is anothe
dialog. The thing is, before the dialog appearance, i connect to a
external database to get my data. Therefor the time between the butto
for starting the thread amd the appearance of the dialog is a bi
long.
I tried every way i could find on the web for showing the Hourglas
cursor while starting the thread and nothing worked.
It seams that when the code moves from the MainFrm to the Thread th
cursor changes.
_*CODE:*__
IN MAINFRM.H WHEN A BUTTON IS PRESSED
//Multithread
//
/****************************************/
//BeginWaitCursor();
//theApp.LoadCursor(IDC_WAIT);
//CWaitCursor wait;
/*****************************************/
if( pThread != NULL )
{
if (AfxIsValidAddress(pThread, sizeof(CWinThread)) &&
AfxIsValidAddress(pThread->m_pMainWnd, sizeof(CWnd)))
{
if (::IsWindow(pThread->m_pMainWnd->GetSafeHwnd()))
{
pThread->PostThreadMessage( WM_PCARDKILLTHREAD, 0, 0);
}
}
}
// OK, we need to create a new thread
pThread=AfxBeginThread( RUNTIME_CLASS(CPCardThread) );
IN THREAD STARTU
BOOL CPCardThread::InitInstance()
{
m_pMainWnd = &dlg;
CMRSApp* pApp = (CMRSApp*) AfxGetApp();
dlg.PRN = pApp->PRN;
dlg.DoModal();
return FALSE;
}
IN DIALOG STARTU
BOOL CPCardDlg::OnInitDialog()
{
CResizableDialog::OnInitDialog();
////////////////
//LOad Icon
////////////////
HICON hicon = AfxGetApp()->LoadIcon(IDI_NEWP);
ASSERT( hicon != NULL );
SetIcon( hicon, true );
////////////////
//Init Toolbar
////////////////
if( !m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBarEx
IDR_PCARD_TOOLBAR) )
{
TRACE("Cannot create toolbar!!!!\n");
EndDialog( IDCANCEL );
}
//Set buttons text
EkSetToolBarText( &m_wndToolBar, IDS_BUTTONS_TOOLBAR );
//Get windows version and load proper toolbar size
CMRSApp* pApp = (CMRSApp*) AfxGetApp();
if( strcmp( pApp->WinVer, "WinXP" ) == 0 )
m_wndToolBar.SetSizes( CSize(62, 62), CSize(32,32) );
else
m_wndToolBar.SetSizes( CSize(52, 52), CSize(32,32) );
CRect rcClientStart;
CRect rcClientNow;