各位高手,请大家指点一二,我在主窗口(CFrameWnd)中建立了一个子窗口(对话框)但是显示不出来,请多多指教。

解决方案 »

  1.   

    仅仅是建立对话框时设了它的属性为SW_VISIBLE
      

  2.   

    难道取消SW_VISIBLE这个属性就可以显示了?那你就把它取消不就得了。
      

  3.   

    CRect rc;
    pFramWnd->GetClientRect (rc);
    CDialog dialog;
    DLGTEMPLATE *pDlg;
    pDlg=new(DLGTEMPLATE);
    pDlg->style =WS_BORDER | DS_3DLOOK | WS_CHILD |WS_VISIBLE ;
    pDlg->cdit =1;
    pDlg->cx=30;
    pDlg->cy=short(rc.bottom -rc.top) ;
    pDlg->x =short(rc.left);
    pDlg->y =short(rc.right);
    pDlg->dwExtendedStyle =NULL;
    dialog.CreateIndirect (pDlg,pFramWnd);
      

  4.   

    在最后加一句
    dialog.ShowWindow(SW_SHOW);
    试试。MSDN中关于使用WS_VISIBLE的说明:
    Use the WS_VISIBLE style in the dialog-box template if the dialog box should appear when the parent window is created. Otherwise, you must call ShowWindow to cause it to appear. For more information on how you can specify other dialog-box styles in the template, see theDLGTEMPLATE structure in the Win32 SDK documentation. 
      

  5.   

    不行,因为在主窗口中我已经使用了ShowWindow(SW_SHOW);现在用了后就会有错误产生,不知道通过消息机制能不能达到要求
      

  6.   

    DLGTEMPLATE *pDlg;
    pDlg=new(DLGTEMPLATE);这两行定义转到其他地方试试,如果你的代码是在一个函数里的
    哪么函数执行结束,pDlg就被释放掉了,