Ignore:
Timestamp:
Jan 25, 2016, 4:22:26 PM (10 years ago)
Author:
rousseau
Message:

And then there were three: (Pm32, Odin32 and Win32) [apitest]

This commit introduces the Odin32 and Win32 variants of ApiTest.
All three are generated from a software-model and composed from
source-snippets, a process that will continue to be enhanced at the
developer site.

File:
1 edited

Legend:

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

    r22109 r22112  
    1 
     1//! GENINFO :: platform:OS/2, version:20.45, target:ApiTest.generate
    22/*****************************************************************************\
    3 * ApiTestPm.cpp                                                               *
     3* ApiTestPm.cpp :: This is the PM variant of ApiTest                          *
    44* --------------------------------------------------------------------------- *
    5 * This is the PM version of the ApiTest program.                              *
    6 * It is used as a casco to construct the basic structure.                     *
    7 * Note that this is not the program of focus, that would be the Odin32 and    *
    8 * Win32 variants which will use the Odin32-API and will be added in upcoming  *
    9 * commits.                                                                    *
     5* The PM version has a different purpose than the Odin Based and Windows      *
     6* variants. Here the focus is not directly on testing the Odin32-API, but     *
     7* rather on testing the OS/2-API. While Odin implements a lot of Win32        *
     8* functionality from scratch, there are also situations where things are      *
     9* delegated to OS/2. This variant provides that angle.                        *
    1010\*****************************************************************************/
    1111
    1212
    1313/*
    14 // Include the standard C/C++ headers.
     14// Standard C/C++ Headers
    1515*/
    1616#include    <stdlib.h>
     
    1818#include    <string.h>
    1919
    20 /*
    21 // Include the Platform headers for OS/2.
     20
     21
     22/*
     23// Platform Headers for OS/2
    2224*/
    2325#define     INCL_DOS
     
    2628
    2729
    28 /*
    29 // Module related include-files.
     30
     31/*
     32// Module Headers
    3033*/
    3134#include    "ids.h"
    32 
    33 /*
    34 // Minimal Window Procedure.
    35 */
    36 MRESULT EXPENTRY    PmWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
     35#include    "ApiTestPm.hpp"
     36
     37
     38
     39/*
     40// Minimal Window Procedure
     41*/
     42MRESULT EXPENTRY Pm32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
    3743    /*
    3844    // Local Variables follow here.
     
    5460            /*
    5561            // Create a button on the client-window
    56             // ------------------------------------
    57             // So we can quickly exit the application by just pressing
    58             // the space-bar.
    5962            */
    6063            do {
     
    6366                /* Create the button */
    6467                hwndButton = WinCreateWindow(
    65                     hwnd,                       // Parent (client-window)
    66                     WC_BUTTON,                  // We want a window of class WC_BUTTON
    67                     (PSZ)"Bye",                 // The button-text
    68                     WS_VISIBLE|BS_PUSHBUTTON,   // Make it visible
    69                     20,                         // The x-pos from llc
    70                     20,                         // The y-pos from llc
    71                     100,                        // Width of the button
    72                     50,                         // Height of the button
    73                     hwnd,                       // Owner (client-window)
    74                     HWND_TOP,                   // Z-order
    75                     ID_EXIT,                    // Window ID
    76                     NULL,                       // Control Data (none)
    77                     NULL                        // Presentation Parameters (none)
     68                    hwnd,                           // Parent (client-window)
     69                    WC_BUTTON,                      // We want a window of class WC_BUTTON
     70                    (PSZ)"Bye",                     // The button-text
     71                    WS_VISIBLE|BS_PUSHBUTTON,       // Make it visible
     72                    20,                             // The x-pos from llc
     73                    20,                             // The y-pos from llc
     74                    100,                            // Width of the button
     75                    50,                             // Height of the button
     76                    hwnd,                           // Owner (client-window)
     77                    HWND_TOP,                       // Z-order
     78                    ID_EXIT,                        // Window ID
     79                    NULL,                           // Control Data (none)
     80                    NULL                            // Presentation Parameters (none)
    7881                );
    7982                /* Give the focus to the button */
     
    120123                    printf("WM_COMMAND received, id: %04d\n", SHORT1FROMMP(mp1));
    121124                    break;
    122 
     125                default:
     126                    mres = WinDefWindowProc(hwnd, msg, mp1, mp2);
     127                    break;
    123128            }
    124129            break;  /*WM_COMMAND*/
     
    133138
    134139        /*
     140        // Request to quit the application.
     141        */
     142        case WM_QUIT:
     143            printf("WM_QUIT received\n");
     144            mres = WinDefWindowProc(hwnd, msg, mp1, mp2);
     145            break;
     146
     147        /*
    135148        // Request to close the application.
     149        // On PM this this posts a WM_QUIT message which in turn terminates
     150        // the message-loop. Only an explicit call to WinDestroyWindow()
     151        // seems to generate a WM_DESTROY message, which we do after the loop
     152        // has terminated.
     153        // On Win32 WM_CLOSE does a DestroyWindow() but does not post a WM_QUIT
     154        // message and thus does not terminate the message-loop.
    136155        */
    137156        case WM_CLOSE:
     
    142161        /*
    143162        // Window is being destroyed, time to cleanup resources allocated.
     163        // This message seems only to be sent on a WinDestroyWindow() call.
     164        // When clicking the close-button and not doing an explicit
     165        // WinDestroyWindow() does not output the message below.
    144166        */
    145167        case WM_DESTROY:
     
    166188
    167189/*
    168 // PmMain Selective EntryPoint.
    169 */
    170 int     PmMain(int argc, char* argv[]) {
     190// Gui EntryPoint for Presentation Manager
     191*/
     192int APIENTRY PmMain(int argc, char* argv[]) {
    171193    BOOL    brc     = FALSE;    // Boolean return values
    172194    APIRET  ulrc    = -1;       // Numeric return values
     
    185207                FCF_TASKLIST        // Put the beast in the task-list
    186208            };
    187     PSZ     pszClassClient  = (PSZ) "PmMainWindow";             // Window Class Name
    188     PSZ     pszTitle        = (PSZ) "ApiTestPm :: Main Window"; // Window Title
     209    PSZ     pszClassClient  = (PSZ) "ApiTestPm";                // Window Class Name
     210    PSZ     pszTitle        = (PSZ) "ApiTestPm :: Main Window [generated:201601252233]";    // Window Title
    189211    ULONG   flStyleClient   = 0;                                // Style for Client Window
    190212    HWND    hwndFrame       = NULL;                             // Receives handle for Frame Window
    191213    HWND    hwndClient      = NULL;                             // Receives handle for Client Window
    192 
    193214
    194215
     
    207228
    208229
    209 
    210230    /* Initialize the PM Graphics System */
    211231    hab = WinInitialize(NULL);
     
    215235
    216236    /* Register the class of the Main Window */
    217     brc = WinRegisterClass(hab, pszClassClient, PmWindowProc, CS_SIZEREDRAW,  0);
     237    brc = WinRegisterClass(hab, pszClassClient, Pm32WindowProc, CS_SIZEREDRAW,  0);
    218238
    219239    /* Create the Main Window */
     
    229249        &hwndClient         // Storage for Client Handle
    230250    );
    231 
    232251
    233252
     
    250269        printf("Continuing program...\n");
    251270    } while (0);
    252 
    253271
    254272
     
    272290        WinDispatchMsg(hab, &qmsg);
    273291
     292    /* Destroy the Main Window -- causes WM_DESTROY to be sent */
     293    brc = WinDestroyWindow(hwndFrame);
     294
    274295    /* Destroy the message-queue for this (main) thread */
    275296    brc = WinDestroyMsgQueue(hmq);
     
    286307
    287308
    288 /*
    289 // This is the standard C/C++ EntryPoint.
     309
     310/*
     311// This is the standard C/C++ EntryPoint
    290312*/
    291313int     main(int argc, char* argv[]) {
    292314    printf("\n");
    293315    printf("%s\n","###############################################################################");
    294     printf("%s\n","# This is the PM version of ApiTest                      version.201512030711 #");
     316    printf("%s\n","# This is the PM variant of ApiTest                      version.201601252233 #");
    295317    printf("%s\n","###############################################################################");
    296318    printf("\n");
Note: See TracChangeset for help on using the changeset viewer.