Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EndDialog vs DestroyWindow

HI I am create a mimic of the Windows Context menu.

Show dialog does the follow:

  1. creates a dialog using CreateDialogIndirectParam
  2. runs a message loop:

    while ( ContinueModal() && GetMessage(&msg, NULL, 0, 0) )
    {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }
    
  3. I the dialog I look for lost focus event of the new window there I set the ContinueModel flag to false and call EndDialog / DestroyWindow.

    • Calling EndDialog doesn't kill my dialog, DestroyWindow does. Is this ok, can anyone explain why?

Thanks! D.

like image 518
Dory Zidon Avatar asked Dec 21 '25 05:12

Dory Zidon


1 Answers

Like it says in the first line of the documentation, EndDialog ends modal dialogs. Your dialog is not modal, so EndDialog is the wrong function. The documentation for CreateDialogIndirectParam says

To destroy the dialog box, use the DestroyWindow function.

like image 138
Raymond Chen Avatar answered Dec 22 '25 19:12

Raymond Chen