CString temp_t;
for(it3=l_return.begin();it3!=l_return.end();it3++){
AfxMessageBox(*it3);//怎么能让它每次出现一次文件名提示。就自动结束
                                                            //文件名一次又一次出现提示很多。一个一个点击确认,
                                                            // 要点击几百次。有没有让对话框自动关闭自己函数?对话框只显示一下。
                                                            //或者机器使用自动的回车动作?
temp_t = (*it3);
temp_t.TrimRight("jpg");       
temp_t += "txt";               
l_txt.push_back(temp_t);
}
for (it4=l_txt.begin();it4!=l_txt.end();it4++)
AfxMessageBox(*it4); //和上面的一样,有多少个*it3。就是多少个对话框,自动关闭这些对话框。
SendMessage((HWND)pParam, WM_FILEFOUND, 0, 0); 
}
                        CString temp_t;
for(it3=l_return.begin();it3!=l_return.end();it3++){
AfxMessageBox(*it3);//怎么能让它每次出现一次文件名提示。就自动结束
                                                            //文件名一次又一次出现提示很多。一个一个点击确认,
                                                            // 要点击几百次。有没有让对话框自动关闭自己函数?对话框只显示一下。
                                                            //或者机器使用自动的回车动作?
temp_t = (*it3);
temp_t.TrimRight("jpg");       
temp_t += "txt";               
l_txt.push_back(temp_t);
}
for (it4=l_txt.begin();it4!=l_txt.end();it4++)
AfxMessageBox(*it4); //和上面的一样,有多少个*it3。就是多少个对话框,自动关闭这些对话框。
SendMessage((HWND)pParam, WM_FILEFOUND, 0, 0); 
}哪位能给看看。先谢谢了。
电邮是:[email protected]
有问题请留言。或电邮。真的是心急如焚。

解决方案 »

  1.   

    不要用 AfxMessageBox 用TRACE
    调试程序、在output查看内容TRACE( "%s\n", (LPCTSTR)*it );
      

  2.   

    如果你要显示一会就自动隐藏,就自己实现一个非模态的Dialog、启动一个定时器,过一会把自己关闭
      

  3.   

    不要将“AfxMessageBox(*it3);”这句放到循环里。
      

  4.   

    自己做个对话框来代替AfxMessageBox,在该对话框的OnInitDialog函数中调用SetTimer函数定时,响应WM_TIMER消息,先KillTimer,然后关闭自己。
      

  5.   

    可以写一个带有定时关闭功能的MessageBox
    void CMsgBox::MessageBox(CString sMsg, CString sCaption, UINT nSleep,  UINT nFlags, bool bAutoClose)

       // Save the caption, for finding this 
       // message box window later 
       m_Caption = sCaption; 
       // If auto close then, start the timer.
       if(bAutoClose) SetTimer(100, nSleep, NULL); 
       // Show the message box
       CWnd::MessageBox(sMsg, sCaption, nFlags);
    }
     
    void CMsgBox::OnTimer(UINT nIDEvent) 
    {
       // TODO: Add your message handler code here and/or call default 
       BOOL bRetVal = false; 
       // Find the message box window using the caption
       CWnd* pWnd = FindWindow(NULL, m_Caption); 
       if(pWnd != NULL) 
       {
           // Send close command to the message box window 
           ::PostMessage(pWnd->m_hWnd, WM_CLOSE, 0, 0);
       } 
       // Kill the timer 
       KillTimer(100); 
       CWnd::OnTimer(nIDEvent);

    可以从这下载源代码
    http://www.codeproject.com/KB/dialog/AutoCloseMessageBox.aspx
      

  6.   

    如果这些名还有用,最好用一个listbox把它存起来.
      

  7.   

    我编了一个简单的可以定时结束的弹出对话框类,LZ可此在基础上扩展,代码如下:
    //定时结束的弹出对话框类
    class MsgBox : public CThunkBase
    {
    public:
        MsgBox(char* strPrompt, char* strTitle, DWORD dwMilliseconds = 2000)
        {
    strcpy(m_strPrompt, strPrompt);
    strcpy(m_strTitle, strTitle);
    m_dwMilliseconds = dwMilliseconds;
    //启动一个单独的线程
    m_uType = MB_OK;
    m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)GetFuncAddr(&MsgBox::MessageProc), &m_uType, 0, &m_dwThreadId);
        }
    ~MsgBox()
    {
    Sleep(m_dwMilliseconds); //两秒钟自动结束
    PostThreadMessage(m_dwThreadId, WM_QUIT, 0, 0);
    WaitForSingleObject(m_hEvent, INFINITE);
    CloseHandle(m_hThread);
    }
    int CALLBACK MessageProc(LPVOID lpParameter)
    {
    MSG msg;
    UINT uType = (UINT)*(UINT*)lpParameter; MessageBox(NULL, m_strPrompt, m_strTitle, uType); while(GetMessage(&msg, NULL, 0, 0)); SetEvent(m_hEvent);
    return 0;
    }
    private:
        char m_strPrompt[100],m_strTitle[100];
    HANDLE m_hThread;
    UINT m_uType;
    DWORD m_dwThreadId,m_dwMilliseconds;
    HANDLE m_hEvent;
    };
    int main()
    {   
    MsgBox("aa","bb");

    return 0;
    }说明:CThunkBase类是前些日子我编的一个用来回调类成员函数的基类,代码可在我的博客空间里获取。
      

  8.   

    楼上的算法很经典,学习了。
    我给楼主的建议就是别把AfxMessageBox放在循环里,害处太多了。
      

  9.   

    最好不用消息框来调试这么多的信息,用TRACE宏输出到VC的调试输出窗口