我MDI的项目,然后起先做了个LOGIN对话框,SOCKET就与消息绑定不了。。MDI下,怎么使用SOCKET呢?SOCKET消息绑定到哪?是不是用FORMVIEW,就可以喝对话框模式一样了?

解决方案 »

  1.   


    BOOL Cclient_dvApp::InitInstance()
    {
    CWinApp::InitInstance(); // 初始化 OLE 库
    if (!AfxOleInit())
    {
    AfxMessageBox(IDP_OLE_INIT_FAILED);
    return FALSE;
    }
    AfxEnableControlContainer();
    // 标准初始化
    // 如果未使用这些功能并希望减小
    // 最终可执行文件的大小,则应移除下列
    // 不需要的特定初始化例程
    // 更改用于存储设置的注册表项
    // TODO: 应适当修改该字符串,
    // 例如修改为公司或组织名
    SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
    LoadStdProfileSettings(4);  // 加载标准 INI 文件选项(包括 MRU)
    // 注册应用程序的文档模板。文档模板
    // 将用作文档、框架窗口和视图之间的连接         LoginDlg dlg;
            dlg.DoModal(); CMultiDocTemplate* pDocTemplate;
    pDocTemplate = new CMultiDocTemplate(IDR_client_dvTYPE,
    RUNTIME_CLASS(Cclient_dvDoc),
    RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架
    RUNTIME_CLASS(Cclient_dvView));
    if (!pDocTemplate)
    return FALSE;
    AddDocTemplate(pDocTemplate); // 创建主 MDI 框架窗口
    CMainFrame* pMainFrame = new CMainFrame;
    if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
    {
    delete pMainFrame;
    return FALSE;
    }
    m_pMainWnd = pMainFrame;
    // 仅当具有后缀时才调用 DragAcceptFiles
    //  在 MDI 应用程序中,这应在设置 m_pMainWnd 之后立即发生
    // 分析标准外壳命令、DDE、打开文件操作的命令行
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    // 调度在命令行中指定的命令。如果
    // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
    if (!ProcessShellCommand(cmdInfo))
    return FALSE;
    // 主窗口已初始化,因此显示它并对其进行更新
    pMainFrame->ShowWindow(m_nCmdShow);
    pMainFrame->UpdateWindow(); return TRUE;
    }
    void CS_conn::bindtodlg(HWND mhWnd,int messageid)
    {
    WSAAsyncSelect(m_client, mhWnd, messageid, FD_READ|FD_WRITE);
    }我这么用的,然后在执行进去下面那段的时候,出错。
      

  2.   


    LPCTSTR lpszCommands = (LPCTSTR)::GlobalLock(hCommands);
    ENSURE_THROW(lpszCommands != NULL, ::AfxThrowMemoryException() );
    TRACE(traceAppMsg, 0, _T("%s: Execute '%s'.\n"), lpszPrefix, lpszCommands);
    ::GlobalUnlock(hCommands);
    Afxtrace.cpp里的这里出错