File:  [OS/2 SDKs] / pmsdk / samples / hello / hello.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:28:12 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: pmsdk-1988, HEAD
Microsoft OS/2 SDK PM 08-08-1988

/****************************** Module Header ******************************\
* Module Name: HELLO.C
*
* Example of a simple OS/2 Presentation Manager application
*
* Created by Microsoft Corp., 1988
*
\***************************************************************************/

#define INCL_PM
#include <os2.h>
#include "hello.h"

HAB     hAB;
HMQ     hmqHello;
HWND    hwndHello;
HWND    hwndHelloFrame;

CHAR    szClassName[] = "Hello";
CHAR    szMessage[]   = "Hello World";


/***************************** Private Function ****************************\
*
* Hello World Main procedure
*
* Effects: Set globals   - hAB        Handle to Application Anchor Block
*                        - hmqHello   Handle to application window msg     queue
*
* Warnings: None
*
\***************************************************************************/

int cdecl main( )
{
    QMSG qmsg;
    ULONG ctldata;

    hAB = WinInitialize(NULL);

    hmqHello = WinCreateMsgQueue(hAB, 0);

    if (!WinRegisterClass( hAB,
                           (PCH)szClassName,
                           (PFNWP)HelloWndProc,
                           CS_SYNCPAINT | CS_SIZEREDRAW,
                           0))
        return( 0 );

    ctldata = FCF_STANDARD & ~FCF_MENU;

    hwndHelloFrame = WinCreateStdWindow( HWND_DESKTOP,
                                         WS_VISIBLE | FS_ICON,
  					 &ctldata,
                                         (PCH)szClassName,
                                         (PCH)szMessage,
                                         0L,
                                         (HMODULE)NULL,
                                         HELLOICON,
                                         (HWND FAR *)&hwndHello );

    WinShowWindow( hwndHelloFrame, TRUE );


    /* Poll messages from event queue */

    while( WinGetMsg( hAB, (PQMSG)&qmsg, (HWND)NULL, 0, 0 ) )
    {
        WinDispatchMsg( hAB, (PQMSG)&qmsg );
    }

    WinDestroyWindow( hwndHelloFrame );
    WinDestroyMsgQueue( hmqHello );
    WinTerminate( hAB );
}



/***************************** Private Function ****************************\
*
* Procedure which processes window messages
*
* Effects: None
*
* Warnings: None
*
\***************************************************************************/

MRESULT EXPENTRY HelloWndProc( hWnd, msg, mp1, mp2 )
HWND   hWnd;
USHORT msg;
MPARAM mp1;
MPARAM mp2;
{
    HPS    hPS;
    POINTL pt;
    CHARBUNDLE cb;

    switch (msg)
    {
    case WM_CLOSE:
        WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
        break;

    case WM_PAINT:
        hPS = WinBeginPaint( hWnd, (HPS)NULL, (PWRECT)NULL );
        pt.x = pt.y = 0L;
        cb.lColor = CLR_BLACK;
        GpiSetAttrs(hPS, PRIM_CHAR, CBB_COLOR, 0L, (PBUNDLE)&cb);

        GpiCharStringAt( hPS, (PPOINTL)&pt, (LONG)sizeof(szMessage)-1,
                        (PCH)szMessage );
        WinEndPaint( hPS );
        break;

    case WM_ERASEBACKGROUND:
        return( TRUE );
        break;

    default:
        return( WinDefWindowProc( hWnd, msg, mp1, mp2 ) );
        break;
    }
    return(0L);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.