我在主窗口的创建了一个线程类的对象,但是怎么弄都会提示出错m_FatherThread = AfxBeginThread(ThreadProc,(LPVOID)this);出错信息为'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned long (__cdecl *)(void *)'请大家看看到底是什么原因呢?

解决方案 »

  1.   

    ThreadProc
    这个函数定义的类型不正确。
      

  2.   


    如这样的:
    UINT MO_ThreadProc(LPVOID pParam);
    AfxBeginThread(MO_ThreadProc,this);
      

  3.   

    我定义为类中的一个静态函数,申明格式为这样
    static UINT WINAPI ThreadProc(LPVOID pParam);你们看看有什么不对吗?
      

  4.   

    static UINT ThreadProc(LPVOID pParam);
    这样就行了.
      

  5.   

    哈,正好我最近做线程程序
    你是用户线程还是辅助线程?
    用户界面线程(参数不能少,之前建CMyWinThread线程类):
    CWinThread* m_pThread;
    m_pThread = AfxBeginThread(RUNTIME_CLASS(CMyWinThread),
    THREAD_PRIORITY_NORMAL,
    0,
    CREATE_SUSPENDED,
    NULL);
    辅助线程:
    CWinThread* m_pUpdateThread;
    m_pUpdateThread = AfxBeginThread(NewThreadProc,(LPVOID)this,THREAD_PRIORITY_NORMAL);
    声明:
    UINT NewThreadProc( LPVOID pParam );
    UINT NewThreadProc( LPVOID pParam ){
    ...
    }