Ignore:
Timestamp:
Feb 9, 2016, 12:57:59 PM (10 years ago)
Author:
rousseau
Message:

Changed application termination [apitest]

Termination is now redirected to WM_CLOSE.
WM_CLOSE does a DestroyWindow(), which in turn generates a WM_DESTROY
message, which is where the main message-loop is ended by doing a call
to PostQuitMessage().

At exit however, the 'wParam' field of the 'msg' structure does not
contain the exit-code as provided with PostQuitMessage().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/swt/testapp/apitest/src/ApiTestOdin.cpp

    r22113 r22115  
    9292                /* Message from the button, we post a message to close the window */
    9393                case ID_EXIT:
    94                     PostQuitMessage(0);
    95                     break;
    96 
    97                 /* Exit Message from the File Menu, forward it to ID_EXIT */
     94                    PostMessage(hwnd, WM_CLOSE, NULL, NULL);
     95                    break;
     96
     97                /* Message from the button, we post a message to close the window */
    9898                case ID_FILE_EXIT:
    99                     PostMessage(hwnd, WM_COMMAND, (UINT) ID_EXIT, NULL);
     99                    PostMessage(hwnd, WM_CLOSE, NULL, NULL);
    100100                    break;
    101101
     
    129129
    130130        /*
    131         // Request to quit the application.
     131        // This message is generated by a call to PostQuitMessage() or the
     132        // posting of a WM_QUIT message. It causes GetMessage() to return zero
     133        // and thus the message-loop to end. So this message is never
     134        // dispatched and this case thus never reached. After the message-loop
     135        // ends, the message-structure contains this message with an exit-code
     136        // (from PostQuitMessage()) in wParam.
    132137        */
    133138        case WM_QUIT:
     
    137142
    138143        /*
    139         // Request to close the application.
    140         // On Win32 WM_CLOSE does a DestroyWindow() but does not post a WM_QUIT
    141         // message and thus does not terminate the message-loop.
     144        // This message is sent when the close-button is clicked.
     145        // On Win32, DefWindowProc() does a DestroyWindow(), but does not post
     146        // a WM_QUIT message and thus does not terminate the message-loop.
    142147        */
    143148        case WM_CLOSE:
    144149            printf("WM_CLOSE received\n");
    145150            lres = DefWindowProc(hwnd, msg, wparam, lparam);
    146             PostQuitMessage(0);
    147             break;
    148 
    149         /*
    150         // Window is being destroyed, time to cleanup resources allocated.
     151            break;
     152
     153        /*
     154        // This message is generated by a call to DestroyWindow().
     155        // At the time this message is received, the windows and its children
     156        // are not destroyed yet.
    151157        */
    152158        case WM_DESTROY:
    153159            printf("WM_DESTROY received\n");
    154160            lres = DefWindowProc(hwnd, msg, wparam, lparam);
     161            PostQuitMessage(99);
    155162            break;
    156163
     
    262269    hwnd = CreateWindow(
    263270        MainWndClass,                   // Our Window Class
    264         "ApiTestOdin :: Main Window [generated:201602071054]",  // Caption Text
     271        "ApiTestOdin :: Main Window [generated:201602071950]",  // Caption Text
    265272        WS_OVERLAPPEDWINDOW,            // Window Stype
    266273        100,                            // The x-pos from ulc
     
    288295    }
    289296
     297    /* Last Message Info */
     298    printf("\n");
     299    printf("Last Message:\n");
     300    printf("msg.hwnd=%08X\n", msg.hwnd);
     301    printf("msg.message=%08X (%d)\n", msg.message, msg.message);
     302    printf("msg.wParam=%08X (%d)\n", msg.wParam, msg.wParam);
     303    printf("msg.lParam=%08X (%d)\n", msg.lParam, msg.lParam);
     304
    290305    /* App is terminating */
     306    printf("\n");
    291307    printf("ApiTestOdin is terminating...\n");
    292308
     
    303319    printf("\n");
    304320    printf("%s\n","###############################################################################");
    305     printf("%s\n","# This is the Odin variant of ApiTest                    version.201602071054 #");
     321    printf("%s\n","# This is the Odin variant of ApiTest                    version.201602071950 #");
    306322    printf("%s\n","###############################################################################");
    307323    printf("\n");
Note: See TracChangeset for help on using the changeset viewer.