请教关于模态窗口创建到显示到关闭。
请举个例子。

解决方案 »

  1.   

    CYourDialog dlg;
    dlg.DoModal();
      

  2.   

    调用如 isdong(西西) ;
    关闭调用CDialog::OnCancel();
      

  3.   

    怎么使用create
    showwindow
    destroywindow 这几个函数,给个实例先,tks
      

  4.   

    参考一下,我用的是DialogBoxParam,你需要自己建立一个资源
    void CVCDebugDlg::OnBtnwin() 
    {
    int iRet;
    // TODO: Add your control notification handler code here
    PGINA_CONTEXT pgContext;
        pgContext = (PGINA_CONTEXT)malloc(sizeof(GINA_CONTEXT));
        iRet = DialogBoxParam(AfxGetApp()->m_hInstance,
      (LPTSTR)MAKEINTRESOURCE(IDD_DLGTEST),
      AfxGetApp()->m_pMainWnd->m_hWnd,
      LogonDlgProc,
      (LPARAM)pgContext);
    if (iRet== 1)
    {
    ShowMessage("WLX_SAS_ACTION_NONE", "IDCANCEL", 1);
    }
    if (iRet== 2)
    {
    ShowMessage("WLX_SAS_ACTION_LOGON", "IDOK", 1);
    }
    if (iRet== 3)
    {
    ShowMessage"WLX_SAS_ACTION_SHUTDOWN", "BTNSHUTDOWN", 1);
    }
    }VOID
    CenterWindow(
        HWND    hwnd
        )
    {
        RECT    rect;
        LONG    dx, dy;
        LONG    dxParent, dyParent;
        LONG    Style;    // Get window rect
        GetWindowRect(hwnd, &rect);    dx = rect.right - rect.left;
        dy = rect.bottom - rect.top;    // Get parent rect
        Style = GetWindowLong(hwnd, GWL_STYLE);
        if ((Style & WS_CHILD) == 0) {        // Return the desktop windows size (size of main screen)
            dxParent = GetSystemMetrics(SM_CXSCREEN);
            dyParent = GetSystemMetrics(SM_CYSCREEN);
        } else {
            HWND    hwndParent;
            RECT    rectParent;        hwndParent = GetParent(hwnd);
            if (hwndParent == NULL) {
                hwndParent = GetDesktopWindow();
            }        GetWindowRect(hwndParent, &rectParent);        dxParent = rectParent.right - rectParent.left;
            dyParent = rectParent.bottom - rectParent.top;
        }    // Centre the child in the parent
        rect.left = (dxParent - dx) / 2;
        rect.top  = (dyParent - dy) / 3;    // Move the child into position
        SetWindowPos(hwnd, HWND_TOPMOST, rect.left, rect.top, 0, 0, SWP_NOSIZE);
        SetForegroundWindow(hwnd);
    }
    LogonDlgInit(
        HWND    hDlg,
        LPARAM  lParam)
    {
        CenterWindow(hDlg);
        return(TRUE);
    }
    int
    CALLBACK
    LogonDlgProc(
        HWND        hDlg,
        UINT        Message,
        WPARAM      wParam,
        LPARAM      lParam)
    {
        switch (Message)
        {
            case WM_INITDIALOG:
    return(LogonDlgInit(hDlg, lParam));        case WM_COMMAND:
                if (LOWORD(wParam) == IDCANCEL)
                {
                    EndDialog(hDlg, 1);
                }
          if (LOWORD(wParam) == IDOK)
                {
                    EndDialog(hDlg, 2);
                }
                if (LOWORD(wParam) == IDC_BTNSHUTDOWN)
    {
                    EndDialog(hDlg, 3);
    }
    break;
    return TRUE;
    }
    return FALSE;
    }
      

  5.   

    非模态显示
    CYouDialog *pDialog ;
    pDialog = new CYouDialog();
    pDialog->ShowWindow(SW_SHOW) ;
    销毁
    delete pDialog ;
      

  6.   

    taoni(堕落天使) 的方法好像不行.我刚试了一下
    至于SnowTopCh的方法,菜鸟迷惘中
      

  7.   

    CYouDialog dlg;
    dlg.Create(YOUR_ID)
    dlg.ShowWindow(SW_SHOW) ;
    whlie()
    。。
    dlg.DestroyWindow()
      

  8.   

    显示不出来,只是屏幕闪烁一下。
    while()
    .....
    是什么意思??
      

  9.   

    你不是把dlg.DestroyWindow()也跟上了吧
      

  10.   

    哦,漏写了一条语句,抱歉。
    CYouDialog *pDialog ;
    pDialog = new CYouDialog();
    pDialog->Create(ID_YOURDIALOG);//漏写了这条
    pDialog->ShowWindow(SW_SHOW)