Newbie - DialogBox

Hi all, i'm a newbie. I'm have a question that i don't quite get after reading those online win32 api beginner tutorials.

When we click on the "X" on the upper right of a (CreateWindowEx) window, is the WM_DESTROY message sent before the window is destroyed?

Is the WM_DESTROY message sent for all types of window created with CreateWindow/CreateWindowEx?

I'm asking cause i'm confused with the behaviour/procedure associated with the "X" control on a normal window (created with CreateWindowEx) and the "X" control on a dialog window (created with the DialogBox macro).

Clicking on the "X" on a normal window terminates the window, but clicking on the "X" on a dialog box does nothing. I already put the EndDialog(hwnd, NULL) under switch case WM_DESTROY for the dialog box's procedure but it doesn't work. The EndDialog(hwnd, NULL) works fine when i use it under the switch case WM_COMMAND for an "OK" control.

I'm really confused. Anyone please help me out with my stupid question.



Comments

  • : Hi all, i'm a newbie. I'm have a question that i don't quite get after reading those online win32 api beginner tutorials.
    :
    : When we click on the "X" on the upper right of a (CreateWindowEx) window, is the WM_DESTROY message sent before the window is destroyed?
    :
    : Is the WM_DESTROY message sent for all types of window created with CreateWindow/CreateWindowEx?
    :
    : I'm asking cause i'm confused with the behaviour/procedure associated with the "X" control on a normal window (created with CreateWindowEx) and the "X" control on a dialog window (created with the DialogBox macro).
    :
    : Clicking on the "X" on a normal window terminates the window, but clicking on the "X" on a dialog box does nothing. I already put the EndDialog(hwnd, NULL) under switch case WM_DESTROY for the dialog box's procedure but it doesn't work. The EndDialog(hwnd, NULL) works fine when i use it under the switch case WM_COMMAND for an "OK" control.
    :
    : I'm really confused. Anyone please help me out with my stupid question.
    :
    :
    :
    :
    [blue]You need Petzold's book.

    First of all - use debugger more often and you will see how messages are coming and what is going on in Windows in general.

    The dialog will respond to WM_COMMAND, instead of WM_DESTROY. You should have this in your dialog box procedure:
    [code]
    case WM_COMMAND:
    if ((wParam==IDOK) || (wParam==IDCANCEL)) {
    EndDialog (hWnd, wParam);
    }
    break;
    [/code]
    [/blue]
  • [b][red]This message was edited by aljpson at 2003-10-31 13:1:47[/red][/b][hr]
    [b][red]This message was edited by aljpson at 2003-10-31 13:0:42[/red][/b][hr]
    Thanks for the reply. I'll look into the book and debug exercise you mentioned. Anyhow, what i originally intend to do is make an dialog box without any OK or CANCEL buttons so the only way to close it is through the "X" button on the upper right of the dialog box.

    What i don't get and still trying to figure out is: since we're not allowed to use DefDlgProc() in Dialog Procedures (and as i've just learned, dialog box don't use WM_DESTROY), what is the WPARAM for message WM_COMMAND that is sent when users click on the "X" control? What should i use should i use for comparison with wParam?


    : : Hi all, i'm a newbie. I'm have a question that i don't quite get after reading those online win32 api beginner tutorials.
    : :
    : : When we click on the "X" on the upper right of a (CreateWindowEx) window, is the WM_DESTROY message sent before the window is destroyed?
    : :
    : : Is the WM_DESTROY message sent for all types of window created with CreateWindow/CreateWindowEx?
    : :
    : : I'm asking cause i'm confused with the behaviour/procedure associated with the "X" control on a normal window (created with CreateWindowEx) and the "X" control on a dialog window (created with the DialogBox macro).
    : :
    : : Clicking on the "X" on a normal window terminates the window, but clicking on the "X" on a dialog box does nothing. I already put the EndDialog(hwnd, NULL) under switch case WM_DESTROY for the dialog box's procedure but it doesn't work. The EndDialog(hwnd, NULL) works fine when i use it under the switch case WM_COMMAND for an "OK" control.
    : :
    : : I'm really confused. Anyone please help me out with my stupid question.
    : :
    : :
    : :
    : :
    : [blue]You need Petzold's book.
    :
    : First of all - use debugger more often and you will see how messages are coming and what is going on in Windows in general.
    :
    : The dialog will respond to WM_COMMAND, instead of WM_DESTROY. You should have this in your dialog box procedure:
    : [code]
    : case WM_COMMAND:
    : if ((wParam==IDOK) || (wParam==IDCANCEL)) {
    : EndDialog (hWnd, wParam);
    : }
    : break;
    : [/code]
    : [/blue]
    :






  • just got the book "programming windows 98 - 5th ed" by Protzold.
    every1 says its the bible for win32 api prog so just decided its a must-have.
    thanks for the recommendaton

  • The X button sends an IDCANCEL message.
  • Stupid me. Now i get.
    Thanks for helping out a newbie.

    : The X button sends an IDCANCEL message.
    :

  • : Stupid me. Now i get.
    : Thanks for helping out a newbie.
    :
    : : The X button sends an IDCANCEL message.
    : :
    :
    :
    [blue]Do not beat yourself up - everyone is learning...[/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories