Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ EndDialog vs DestroyWindow_C++_Windows_Winapi_Win32gui_Windows Messages - Fatal编程技术网

C++ EndDialog vs DestroyWindow

C++ EndDialog vs DestroyWindow,c++,windows,winapi,win32gui,windows-messages,C++,Windows,Winapi,Win32gui,Windows Messages,您好,我正在创建一个模拟Windows上下文菜单 “显示”对话框执行以下操作: 使用CreateDialogIndirectParam 运行消息循环: while ( ContinueModal() && GetMessage(&msg, NULL, 0, 0) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } 我在对话框中查找新窗口的失焦事件,在那里我将ContinueM

您好,我正在创建一个模拟Windows上下文菜单

“显示”对话框执行以下操作:

  • 使用
    CreateDialogIndirectParam
  • 运行消息循环:

    while ( ContinueModal() && GetMessage(&msg, NULL, 0, 0) )
    {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }
    
  • 我在对话框中查找新窗口的失焦事件,在那里我将
    ContinueModel
    标记设置为false,并调用
    EndDialog
    /
    destronWindow

    • 调用
      EndDialog
      不会终止我的对话框,
      DestroyWindow
      会终止。这样行吗,有人能解释一下原因吗
  • 谢谢!
    D.

    如文档第一行所述。您的对话框不是模态对话框,因此
    EndDialog
    是错误的函数。说

    要销毁对话框,请使用DestroyWindow函数


    事实上,我在doucment挖掘了更多的数据后,发现了很多。但是你是对的,谢谢你!!我玩Spy++玩得很开心:)2021更新:现在看来
    EndDialog
    也关闭了无模式对话框(至少在我的系统上一直如此)。这有点酷,因为它有时允许使用相同的
    DLGPROC
    ,而不管对话框是否以模式显示。但实际上你不能真正使用它,因为它没有文档记录。这是加倍糟糕的,因为你不能依赖一个没有文档记录的“功能”,但同时,错误会被忽视,因为它碰巧起作用。我没有看到你描述的行为。EndDialog仍然没有破坏对话框。@Raymond进一步调查后,您完全正确(在Visual Studio中的新“Windows桌面应用程序”模板项目中进行了测试,用
    CreateDialog
    +
    ShowWindow
    替换
    对话框
    调用(“关于”框)。它不会破坏对话框,但会有效地隐藏对话框。不过,在Spy++中,我没有看到
    WM_ShowWindow
    消息,因此不能使用
    ShowWindow
    。事实上,我不知道它到底做了什么,但它删除了
    WS\u VISIBLE
    。无论如何,这是一个很难找到的错误,因为乍一看,它似乎做了正确的事情。