CDialog::CreateIndirect()和CDialog::InitModalIndirect()
用来create模式的和非模式的对话框

解决方案 »

  1.   

    http://www.csdn.net/expert/topic/411/411075.shtm
    分数为150分
    十万火级,如能给出答案,再送300分
    有兴趣的人留下email
    我把程序发给你们。 
    一个很cool的表格程序,请问如何改为activeX控件,有兴趣的我把源代码发给你们,感兴趣的人留下email,
    是vc写的非常cool 
      

  2.   

    我觉得先提取公共特性建一个对话框资源,
    再动态添加其它的控件,
    这样就不必用CreateIndirect和InitModalIndirect
      

  3.   

    m_szClass =AfxRegisterWndClass(0);
    bSuccess=CreateEx(NULL,m_szClass,NULL,WS_POPUP,0,0,0,0,pParentWnd->GetSafeHwnd(), NULL, NULL);
    SetWindowPos(&wndTop, 0, 0, 100, 100, SWP_NOACTIVATE | SWP_SHOWWINDOW);
      

  4.   

    www863(心网):用嵌套对话框方法解决,先建一个对话框容器,然后将别的对话框动态显示在容器里。 这个办法应该可以实现。
    可以参考下面
    BOOL CScreenInDlg::OnInitDialog() 
    {
    CDialog::OnInitDialog();

    // TODO: Add extra initialization here

    CViewApp * pWinApp=(CViewApp *)AfxGetApp();
    CRecordset rs(pWinApp->p_appDatabase);
    CRecordset rsTemp(pWinApp->p_appDatabase);
    CDBVariant varValue; CString strSql="select FD_ComponentType,FD_ComponentName,FD_ComponentState,FD_CanChangeState,FD_Number from VW_XT_TwoComponent where FD_StationName='"+m_screeninStationName+"' and FD_ScreenName='"+m_screeninScreenName+"' order by FD_Number,FD_ComponentName";
    rs.Open(CRecordset::snapshot, strSql); int leftPos=0;
    int topPos=0;
    int widthDlg=120;
    int heightDlg=150; int numberComponent=0;
    int colComponent=0;
    int rowComponent=0; while( !rs.IsEOF( ) )
    {

    rowComponent=numberComponent/5;
    colComponent=(numberComponent%5); rs.GetFieldValue("FD_ComponentType",varValue); if(*varValue.m_pstring=="电源开关")
    {
    CTwoComponentPowerSwitchDlg* pDlg=new CTwoComponentPowerSwitchDlg();
    m_screeninDlgArray.Add(pDlg);//加入对话框链表
    pDlg->Create(IDD_TWOCOMPONENT_POWERSWITCH_DLG,this);
    pDlg->SetWindowPos(this,colComponent*widthDlg,rowComponent*heightDlg, widthDlg, heightDlg, SWP_NOZORDER);

    rs.GetFieldValue("FD_ComponentName",varValue);
    pDlg->m_dlgTwoComponentName=*varValue.m_pstring;

    //先从二次元件的临时表中去读取该元件的状态////////////////////
    strSql="select FD_ComponentState from #TB_XT_TempTwoComponent where FD_ComponentName='"+pDlg->m_dlgTwoComponentName+"'";
    rsTemp.Open(CRecordset::snapshot, strSql);

    if( !rsTemp.IsEOF( ) )
    rsTemp.GetFieldValue("FD_ComponentState",varValue);
    else
    rs.GetFieldValue("FD_ComponentState",varValue);

    rsTemp.Close();
    ////////////////////////////////////////////////////////////// pDlg->m_dlgTwoComponentState=*varValue.m_pstring;
    if(*varValue.m_pstring=="合上")
    {
    pDlg->m_dlgBitmapCloseState.ShowWindow(SW_SHOW);
    pDlg->m_dlgBitmapOpenState.ShowWindow(SW_HIDE);
    }
    if(*varValue.m_pstring=="拉开")
    {
    pDlg->m_dlgBitmapCloseState.ShowWindow(SW_HIDE);
    pDlg->m_dlgBitmapOpenState.ShowWindow(SW_SHOW);
    } pDlg->p_dlgView=p_screeninView;

    pDlg->UpdateData(FALSE);
    pDlg->ShowWindow(SW_SHOW); }

    if(*varValue.m_pstring=="旋扭开关")
    {
    CTwoComponentKnobSwitchDlg* pDlg=new CTwoComponentKnobSwitchDlg();
    m_screeninDlgArray.Add(pDlg);
    pDlg->Create(IDD_TWOCOMPONENT_KNOBSWITCH_DLG,this);
    pDlg->SetWindowPos(this,colComponent*widthDlg,rowComponent*heightDlg, widthDlg, heightDlg, SWP_NOZORDER);

    rs.GetFieldValue("FD_ComponentName",varValue);
    pDlg->m_dlgTwoComponentName=*varValue.m_pstring;

    //先从二次元件的临时表中去读取该元件的状态////////////////////
    strSql="select FD_ComponentState from #TB_XT_TempTwoComponent where FD_ComponentName='"+pDlg->m_dlgTwoComponentName+"'";
    rsTemp.Open(CRecordset::snapshot, strSql);

    if( !rsTemp.IsEOF( ) )
    rsTemp.GetFieldValue("FD_ComponentState",varValue);
    else
    rs.GetFieldValue("FD_ComponentState",varValue);

    rsTemp.Close();
    ////////////////////////////////////////////////////////////// pDlg->m_dlgTwoComponentState=*varValue.m_pstring;
    if(*varValue.m_pstring=="合")
    {
    pDlg->m_dlgBitmapCloseState.ShowWindow(SW_SHOW);
    pDlg->m_dlgBitmapOpenState.ShowWindow(SW_HIDE);
    }
    if(*varValue.m_pstring=="开")
    {
    pDlg->m_dlgBitmapCloseState.ShowWindow(SW_HIDE);
    pDlg->m_dlgBitmapOpenState.ShowWindow(SW_SHOW);
    } pDlg->p_dlgView=p_screeninView; pDlg->UpdateData(FALSE);
    pDlg->ShowWindow(SW_SHOW);
    } rs.MoveNext();
    numberComponent++;
    }
    }
      

  5.   

    我希望那个对话框的POPUP型的!
      

  6.   

    不一定需要资源。
    看到CreateDialogIndirect的第二个参数了吧,只要你按照合法的方式弄一个DLGTEMPLATE出来就可以的。
      

  7.   

    to:rocks_lee(石子儿)
    我是这么写了 可是 老是出错
    谁有例子吗??