Ignore:
Timestamp:
Dec 4, 2015, 2:12:34 PM (10 years ago)
Author:
rousseau
Message:

Added Change Application Type code [apitest]

Changes:
o Added change application type code

With this we have a very simple console-window and printf can be used.

o Added a little more documentation in the 'doc' directory
o Added stubs for the test-menu items
o Corrected 'ids.h' which was generated with tabs
o Added 'ApiTest.properties'
o Added 'fc.mnu' so pressing F2 in File Commander shows its User Menu

Location:
branches/swt/testapp/apitest/src
Files:
4 edited

Legend:

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

    r22106 r22107  
    33* PmApiTest.cpp                                                               *
    44* --------------------------------------------------------------------------- *
    5 * This file is generated from an xmind-file !                                 *
    6 * It uses the newly designed transformation-sheet.                            *
    7 * While this sheet is still file-based, it will be moved to an Ant Property   *
    8 * later so it can be constructed from parts.                                  *
     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.                                                                    *
    910\*****************************************************************************/
    1011
     
    1819
    1920/*
    20 // Include the Platform headers.
     21// Include the Platform headers for OS/2.
    2122*/
    2223#define     INCL_DOS
     
    2627
    2728/*
     29// Module related include-files.
     30*/
     31#include    "ids.h"
     32
     33/*
    2834// Minimal Window Procedure.
    2935*/
    30 MRESULT EXPENTRY    MyWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
     36MRESULT EXPENTRY    PmWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
    3137    /*
    3238    // Local Variables follow here.
     
    6773                    hwnd,                       // Owner (client-window)
    6874                    HWND_TOP,                   // Z-order
    69                     123,                        // Window ID
     75                    ID_EXIT,                    // Window ID
    7076                    NULL,                       // Control Data (none)
    7177                    NULL                        // Presentation Parameters (none)
     
    8187        case WM_COMMAND:
    8288            switch (SHORT1FROMMP(mp1)) {
    83                 /* This is a message from our button, we post a message to close the window */
    84                 case 123:
     89
     90                /* Message from the button, we post a message to close the window */
     91                case ID_EXIT:
    8592                    WinPostMsg(hwnd, WM_CLOSE, NULL, NULL);
    8693                    break;
     94
     95                /* Exit Message from the File Menu, forward it to ID_EXIT */
     96                case ID_FILE_EXIT:
     97                    WinPostMsg(hwnd, WM_COMMAND, (MPARAM) ID_EXIT, NULL);
     98                    break;
     99
     100                /* Messages from the Test Menu */
     101                case ID_TEST1:
     102                    printf("WM_COMMAND received, id: %04d\n", SHORT1FROMMP(mp1));
     103                    break;
     104                case ID_TEST2:
     105                    printf("WM_COMMAND received, id: %04d\n", SHORT1FROMMP(mp1));
     106                    break;
     107                case ID_TEST3:
     108                    printf("WM_COMMAND received, id: %04d\n", SHORT1FROMMP(mp1));
     109                    break;
     110                case ID_TEST4:
     111                    printf("WM_COMMAND received, id: %04d\n", SHORT1FROMMP(mp1));
     112                    break;
     113                case ID_TEST5:
     114                    printf("WM_COMMAND received, id: %04d\n", SHORT1FROMMP(mp1));
     115                    break;
     116                case ID_TEST6:
     117                    printf("WM_COMMAND received, id: %04d\n", SHORT1FROMMP(mp1));
     118                    break;
     119                case ID_TEST7:
     120                    printf("WM_COMMAND received, id: %04d\n", SHORT1FROMMP(mp1));
     121                    break;
     122
    87123            }
    88             break;
     124            break;  /*WM_COMMAND*/
    89125
    90126        /*
     
    157193
    158194
    159     /* Initialize the Graphics System */
     195    /*
     196    // Switch the process type to PM so the command line app can create PM
     197    // windows. This makes it possible to use printf() to stdout.
     198    */
     199    do {
     200        PTIB   ptib;
     201        PPIB   ppib;
     202        //break;
     203        if(DosGetInfoBlocks(&ptib, &ppib) == 0) {
     204            ppib->pib_ultype = 3;
     205        }
     206    } while (0);
     207
     208
     209
     210    /* Initialize the PM Graphics System */
    160211    hab = WinInitialize(NULL);
    161212
     
    164215
    165216    /* Register the class of the Main Window */
    166     brc = WinRegisterClass(hab, pszClassClient, MyWindowProc, CS_SIZEREDRAW,  0);
     217    brc = WinRegisterClass(hab, pszClassClient, PmWindowProc, CS_SIZEREDRAW,  0);
    167218
    168219    /* Create the Main Window */
     
    178229        &hwndClient         // Storage for Client Handle
    179230    );
     231
     232
     233
     234    /*
     235    // Show the handles of the windows created.
     236    // The application has to be built as WINDOWCOMPAT and the code to change
     237    // the application-type to PM has to be active.
     238    */
     239    do {
     240        int delay = 1000;
     241        int i = 0;
     242        //break;
     243        printf("hwndFrame=%08X\n", hwndFrame);
     244        printf("hwndClient=%08X\n", hwndClient);
     245        break;
     246        for (i=5; i>0; i--) {
     247            i > 1 ? printf("Pausing for %d seconds...\n", i) : printf("Pausing for %d second...\n", i);
     248            DosSleep(delay);
     249        }
     250        printf("Continuing program...\n");
     251    } while (0);
    180252
    181253
     
    206278    brc = WinTerminate(hab);
    207279
     280    /* App is terminating */
     281    printf("PmApiTest is terminating...\n");
     282
    208283    /* Return our reply-code */
    209284    return 0;
     
    217292    printf("\n");
    218293    printf("%s\n","###############################################################################");
    219     printf("%s\n","# This is the PM version of ApiTest                      version.201511231348 #");
     294    printf("%s\n","# This is the PM version of ApiTest                      version.201512030711 #");
    220295    printf("%s\n","###############################################################################");
    221296    printf("\n");
     297    printf("%s\n","Switching to Graphical Mode with this Window as a Console Log...");
    222298
    223299    /*
  • branches/swt/testapp/apitest/src/PmApiTest.def

    r22106 r22107  
    66;# which is to test Odin32 from Native PM.                                    #
    77;# This version has low development priority since it does not directly       #
    8 ;# connection to SWT-OS2, which is the project depending on Odin32.           #
     8;# connect to SWT-OS2, which is the project depending on Odin32.              #
    99;##############################################################################
    1010
    11 NAME            PmApiTest   WINDOWAPI
     11
     12NAME            PmApiTest   WINDOWCOMPAT
    1213DESCRIPTION     'A Program to test the Odin32 API from Native PM'
    1314
  • branches/swt/testapp/apitest/src/ids.h

    r22106 r22107  
    55\*****************************************************************************/
    66
    7 #ifndef         __IDS_H__
    8 #define         __IDS_H__
     7#ifndef     __IDS_H__
     8#define     __IDS_H__
    99
    10 #define         IDR_MAINMENU    1
     10#define     IDR_MAINMENU    1
    1111
    12 #define         IDM_FILE                1000
    13 #define         ID_FILE_EXIT    1001
     12#define     IDM_FILE        1000
     13#define     ID_FILE_EXIT    1001
    1414
    15 #define         IDM_TESTING             1100
    16 #define         ID_TEST1                1101
    17 #define         ID_TEST2                1102
    18 #define         ID_TEST3                1103
    19 #define         ID_TEST4                1104
    20 #define         ID_TEST5                1105
    21 #define         ID_TEST6                1106
    22 #define         ID_TEST7                1107
     15#define     IDM_TESTING     1100
     16#define     ID_TEST1        1101
     17#define     ID_TEST2        1102
     18#define     ID_TEST3        1103
     19#define     ID_TEST4        1104
     20#define     ID_TEST5        1105
     21#define     ID_TEST6        1106
     22#define     ID_TEST7        1107
    2323
    24 #define         IDM_HELP                1200
    25 #define         ID_HELP_ABOUT   1201
     24#define     IDM_HELP        1200
     25#define     ID_HELP_ABOUT   1201
    2626
    27 #endif
     27#define     ID_EXIT         123
     28
     29#endif  /*__IDS_H__*/
  • branches/swt/testapp/apitest/src/resource.rc

    r22106 r22107  
    1111MENU IDR_MAINMENU PRELOAD
    1212BEGIN
    13     SUBMENU "~File",            IDM_FILE
     13    SUBMENU "~File",                IDM_FILE
    1414    BEGIN
    15         MENUITEM "E~xit",       ID_FILE_EXIT
     15        MENUITEM "E~xit",           ID_FILE_EXIT
    1616    END
    17     SUBMENU "~Testing",         IDM_TESTING
     17    SUBMENU "~Testing",             IDM_TESTING
    1818    BEGIN
    1919        MENUITEM "Test ~1",         ID_TEST1
Note: See TracChangeset for help on using the changeset viewer.