我运行程序后,按正常模式退出,结果在任务管理器里还有进程存在,也就是说我的主程序进程不能正常退出,怎么解决呢?

解决方案 »

  1.   

    //////////////////////////////
    //这是在View里加的一个菜单响应功能void CTextureView::OnEnhanceGabor() 
    {
    // TODO: Add your command handler code here
    CTextureDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    CGaborDlg dlg;
    dlg.m_strTempFile=pDoc->m_strFilePath;
    if (IDOK==dlg.DoModal())
    {
    //dlg.DestroyWindow();
    }
    }
    ////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////
    // CGaborDlg message handlers
         TCHAR  BitmapFilename[256];
         TCHAR  outputFilename[256];
    void CGaborDlg::OnGabor() 
    {
    // TODO: Add your control notification handler code here
    sprintf(outputFilename,"Temp.bmp");
    //   两种获取文件路径的方法
    //  int i = 0;
    //  int j = 0;
    //  while (BitmapFilename[i] != '\0')
    //  {
    //  if (BitmapFilename[i] == '\\')
    //  j = i;
    //  i++;
    //  }
    //      m_strTempFile=CString(BitmapFilename);
    //  m_inputfile=m_strTempFile.Left(j)+"\\Temp.bmp";
    enhancement *enh = new enhancement();
    // ::SetTimer(this->GetSafeHwnd(),1,4000,NULL); 
    enh->Create(IDD_DIALOG_enhance,this);
    enh->ShowWindow(SW_SHOW);    
    enh->m_prog.SetRange32(0,100);          
    // enh->m_prog.SetPos(20);// enh->m_text = " Determining the ridge direction ";
    // enh->m_prog.SetPos(66);
    // enh->UpdateData(false);
    strcpy(BitmapFilename,m_inputfile);
    enhance(enh,BitmapFilename,outputFilename);      
    enh->DestroyWindow(); HBITMAP newBmp;
    newBmp = (HBITMAP) LoadImage(NULL,outputFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    m_bmp2.SetBitmap(newBmp);
    }void CGaborDlg::Onbrowse() 
    {
    // TODO: Add your control notification handler code here

    GetBitmapFileName(BitmapFilename,sizeof(BitmapFilename) / sizeof(TCHAR), NULL);
    m_inputfile = CString(BitmapFilename);
    UpdateData(false); HBITMAP newBmp;
    newBmp = (HBITMAP) LoadImage(NULL,BitmapFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    m_bmp1.SetBitmap(newBmp);
    }BOOL CGaborDlg::GetBitmapFileName(TCHAR *filename, int len, HWND hWnd)
    {
    OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(OPENFILENAME));
    ofn.lStructSize = sizeof(OPENFILENAME);
    ofn.hwndOwner = hWnd;
    ofn.lpstrFilter = _T("Bitmap Files (*.bmp)\0*.bmp\0All Files (*.*)\0*.*\0\0");
    ofn.lpstrFile = filename;
    ofn.nMaxFile = len;
    ofn.lpstrTitle = _T("Browse");
    ofn.Flags = /*OFN_FILEMUSTEXIST |*/ OFN_HIDEREADONLY;
    return GetOpenFileName(&ofn);
    }BOOL CGaborDlg::OnInitDialog() 
    {
    CDialog::OnInitDialog();
    // GetBitmapFileName(BitmapFilename,sizeof(BitmapFilename) / sizeof(TCHAR), NULL);
    strcpy(BitmapFilename,m_strTempFile);
    m_inputfile = CString(BitmapFilename);
    // UpdateData(false); // TODO: Add extra initialization here
    //  两种获取文件路径的方法
    int i = 0;
    int j = 0;
    while (BitmapFilename[i] != '\0')
    {
    if (BitmapFilename[i] == '\\')
    j = i;
    i++;
    }
     //   int a=m_strTempFile.ReverseFind('\\');
        m_strTempFile=CString(BitmapFilename);
    m_inputfile=m_strTempFile.Left(j)+"\\Temp.bmp";
    UpdateData(FALSE);
    HBITMAP newBmp;
    newBmp = (HBITMAP) LoadImage(NULL,m_inputfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    m_bmp1.SetBitmap(newBmp);
    return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
    }
      

  2.   

    其他线程中没有没GetMessage循环?