#include "afxwin.h"
#include "STOPDialog.h"
class UIWorker :
public CWinThread
{
DECLARE_DYNCREATE(UIWorker);



public:
UIWorker(void);
~UIWorker(void);
bool CreateMyDlg( void );

void SetOwnerWnd( HWND hWnd );

void DestroyMyDlg( void );

bool GetDoneFlag();

BOOL InitInstance();
int ExitInstance();


private:

STOPDialog* m_pDlgTest;

HWND m_hOwnerWnd;
bool b_isShow;

 


};

 

#include "UIWorker.h"
#include "Resource.h"
IMPLEMENT_DYNCREATE(UIWorker,CWinThread)


UIWorker::UIWorker(void)
{
b_isShow=false;

}

UIWorker::~UIWorker(void)
{
}
bool UIWorker::GetDoneFlag()
{
return b_isShow;

}
bool UIWorker::CreateMyDlg( void )

{

m_pDlgTest = new STOPDialog;

if ( NULL == m_pDlgTest )

{

return false;

}

CWnd* pWnd = NULL;

/* if ( NULL != m_hOwnerWnd )

{

pWnd = reinterpret_cast<CWnd*>( CWnd::FromHandle( m_hOwnerWnd ));

if ( NULL == pWnd )

{

return false;

}

}*/

 

//BOOL bSuccess = m_pDlgTest->Create( IDD_DIALOG_STOP, pWnd );
BOOL bSuccess = m_pDlgTest->Create( IDD_DIALOG_STOP, NULL );

b_isShow=true;

if ( bSuccess )

{

bSuccess = m_pDlgTest->ShowWindow( SW_SHOW );
b_isShow=bSuccess;

}

MSG msg;
while(GetMessage(&msg,0,0,0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}

 

return bSuccess?true:false;

}

 

void UIWorker::DestroyMyDlg( void )

{

if ( NULL != m_pDlgTest )

{

delete m_pDlgTest;

m_pDlgTest = NULL;

}

}

BOOL UIWorker::InitInstance()
{
return CreateMyDlg();

}
int UIWorker::ExitInstance()
{
DestroyMyDlg();
return 0;
}

void UIWorker::SetOwnerWnd( HWND hWnd )
{
m_hOwnerWnd=hWnd;
}

 

void CcudamfcView::On32797()
{
// TODO: 在此添加命令处理程序代码
//if(m_pUIWorker!=NULL) delete m_pUIWorker;

m_pUIWorker = static_cast<UIWorker*>( AfxBeginThread(

RUNTIME_CLASS( UIWorker )));
//
while ( !m_pUIWorker->GetDoneFlag())

{

MSG msg;

::GetMessage( &msg, this->m_hWnd, NULL, NULL );

::TranslateMessage( &msg );

::DispatchMessage( &msg );

}
double m=0.0;
for(int i=1;i<100000;i++)
for(int j=1;j<1000000;j++)
for(int k=1;k<100000;k++)
m=i*j*k;

}

 

创建的对话框无法响应按钮事件

 

 

posted on 2013-03-05 21:26  30斤大番薯  阅读(1186)  评论(0编辑  收藏  举报