//TestTFTColor是一个BUTTON的响应函数
void TestDlg::TestTFTColor()
{
    HANDLE hTFTTestEvent;    pColorTestDlg=new CDialogColorTest(this);
    //IDD_DIALOG_COLOR_TEST是一个测试对话框,连续点击几次后,会调用DestroyWindow销毁自己,
    pColorTestDlg->Create(IDD_DIALOG_COLOR_TEST); 
    
    pColorTestDlg->ModifyStyle(WS_CAPTION|WS_BORDER|WS_DLGFRAME|WS_THICKFRAME,0,0);
    pColorTestDlg->CenterWindow(GetDesktopWindow());
    int WINDOW_W= ::GetSystemMetrics(SM_CXSCREEN);
    int WINDOW_H= ::GetSystemMetrics(SM_CYSCREEN);
    pColorTestDlg->SetWindowPos(NULL, -3, -3, WINDOW_W+5, WINDOW_H+5, SWP_SHOWWINDOW); //全屏显示
    
    ///////////////////////////////////////////////////////////
    //下面代码是我的想法,但行不通,加了后,整个程序没有响应了
    hTFTTestEvent=CreateEvent(NULL,TRUE,FALSE,_T("TEST_TFT"));  
    if(hTFTTestEvent)
    {       
        while(1)
        {
            if(WaitForSingleObject(hTFTTestEvent, 0)!=WAIT_TIMEOUT )
                break;
            Sleep(200);
        }
        CloseHandle(hTFTTestEvent);
    }
    //我要在pColorTestDlg关闭后,在本函数中处理点其它事,
}//在IDD_DIALOG_COLOR_TEST对话框中,
//我调用如下代码关闭自己hTFTTestEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, L"TCC_REARCAM_STARTUP");
if(hTFTTestEvent)
{
    PulseEvent(hTFTTestEvent);
    CloseHandle(hTFTTestEvent);
}
DestroyWindow();

解决方案 »

  1.   


    发消息,hTFTTestEvent=CreateEvent(NULL,TRUE,FALSE,_T("TEST_TFT"));   
      if(hTFTTestEvent)
      {   
      while(1)
      {
      if(WaitForSingleObject(hTFTTestEvent, 0)!=WAIT_TIMEOUT )
      break;
      Sleep(200);
      }
      CloseHandle(hTFTTestEvent);
      }
      //我要在pColorTestDlg关闭后,在本函数中处理点其它事,
    }
    这段代码怎么改写??
    我要在当前的函数中处理对话框关闭事件啊。
      

  2.   

    CAboutDlg* pDlg = NULL;#define MSG_EXIT (WM_USER + 0x11)
    void CGSDlg::OnOK() 
    {
    // TODO: Add extra validation here
    if(NULL == pDlg)
    {
    pDlg = new CAboutDlg;
    pDlg->Create(IDD_ABOUTBOX, this);
    }

    pDlg->ShowWindow(SW_SHOW); MSG msg;
    while(GetMessage(&msg, NULL, 0, 0))
    {
    if(MSG_EXIT == msg.message)
    {
    break;
    }
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    AfxMessageBox(_T("OK"));
    }void CAboutDlg::OnClose() 
    {
    // TODO: Add your message handler code here and/or call default

    //CDialog::OnClose();
    GetParent()->PostMessage(MSG_EXIT, 0, 0); DestroyWindow();
    }