File:  [OS/2 SDKs] / pmsdk / samples / template / tempres.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:28:13 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: tempres.c
*
*   Resident portion of Presentation Manager Template Application
*
*   Created by Microsoft Corp., 1988
*
\***************************************************************************/

#define INCL_WIN

#include <os2.h>
#include "template.h"

extern HAB     hAB;
extern HMQ     hMsgQ;
extern HWND    hwndTemplate;
extern HWND    hwndTemplateFrame;

SHORT cdecl main(  )
{
    QMSG   qMsg;

    hAB   = WinInitialize(NULL);
    hMsgQ = WinCreateMsgQueue( hAB, 0 );

    if ( !TemplateInitApp( ) )
        return( FALSE );

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

    WinDestroyWindow( hwndTemplateFrame );
    WinDestroyMsgQueue( hMsgQ );
    WinTerminate( hAB );
}



MRESULT EXPENTRY TemplateWndProc( hWnd, message, mp1, mp2 )
HWND   hWnd;
USHORT message;
MPARAM  mp1;
MPARAM  mp2;
{
    /* Procedures which make up the window class. */

    HPS     hPS;
    RECTL   rect;

    switch( message )
    {
        case WM_CREATE:
            /***********************************************************\
            *  Window's being created; mp2  contains lpParam field
            *  passed to CreateWindow
            \***********************************************************/
            TemplateCreate( hWnd, (ULONG)mp2 );
            break;

        case WM_ACTIVATE:
            /***********************************************************\
            *  Window is becoming active window if LOUSHORT(mp1) is
            *  TRUE, inactive if LOUSHORT(mp1) is FALSE.  mp2     is
            *  the window handle of the window being deactivated.
            \***********************************************************/
            if ( SHORT1FROMMP(mp1) && SHORT2FROMMP(mp1) )
                WinSetFocus( HWND_DESKTOP, hWnd );
            break;

        case WM_SETFOCUS:
            /***********************************************************\
            *  The window is getting the focus.  mp1     contains the
            *  window handle of the window that previously had the focus.
            \***********************************************************/
            TemplateSetFocus( hWnd );
            break;

        case WM_PAINT:
            /***********************************************************\
            *  Time for the window to draw itself.
            \***********************************************************/
            hPS = WinBeginPaint( hWnd, (HPS)NULL, (PRECTL)&rect );
            TemplatePaint( hWnd, hPS );
            WinEndPaint( hPS );
            break;

        case WM_CHAR:
            /***********************************************************\
            *  Character input. The low word of mp1     contains the
            *  key type flags, the high word of mp1     contains the
            *  auto-repeat count, and the low word of mp2     contains
            *  the character code.
            \***********************************************************/
            TemplateCharInput( hWnd, SHORT1FROMMP(mp2), SHORT1FROMMP(mp1),
                                SHORT2FROMMP(mp1) );
            break;

        case WM_CLOSE:
            /***********************************************************\
            *  message from system to close the Client window.
            \***********************************************************/
            TemplateQueryQuit( hWnd );
            break;

        case WM_COMMAND:
            /***********************************************************\
            *  A menu item has been selected, or a control is notifying
            *  its parent.  mp1     is the menu item value (for menus),
            *  or control ID (for controls).  For controls, the low word
            *  of mp2     has the window handle of the control, and the hi
            *  word has the notification code.  For menus, mp2     contains
            *  0L.
            \***********************************************************/
            TemplateCommand( hWnd, SHORT1FROMMP(mp1), SHORT1FROMMP(mp2),
                            SHORT2FROMMP(mp2));
            break;

        case WM_TIMER:
            /***********************************************************\
            *  Timer message.  mp1     contains the timer ID value
            \***********************************************************/
            TemplateTimer( hWnd, SHORT1FROMMP(mp1) );
            break;

        case WM_VSCROLL:
            /***********************************************************\
            *  Vertical scroll bar input.  mp1     contains the
            *  scroll code.  For the thumb movement codes, the low
            *  word of mp2     contain the new scroll position.
            *  Possible values for mp1     are: SB_LINEUP, SB_LINEDOWN,
            *  SB_PAGEUP, SB_PAGEDOWN, SB_THUMBPOSITION, SB_THUMBTRACK
            \***********************************************************/
            TemplateVertScroll( hWnd, HIUSHORT(mp2), LOUSHORT(mp2) );
            break;

        case WM_HSCROLL:
            /***********************************************************\
            *  Horizontal scroll bar input.  Parameters same as for
            *  WM_HSCROLL.  UP and DOWN should be interpreted as LEFT
            *  and RIGHT, respectively.
            \***********************************************************/
            TemplateHorzScroll( hWnd, HIUSHORT(mp2), LOUSHORT(mp2) );
            break;

        case WM_ERASEBACKGROUND:
            /*
             * Let frame control erase background for us
             */
            return (TRUE);
            break;
            
            /***********************************************************\
            *  For each of following mouse window messages, mp1     contains
            *  bits indicating whether or not various virtual keys are down,
            *  and mp2     is a WPOINT containing the mouse coordinates.   The
            *  keydown bits of mp1     are:  MK_LBUTTON (set if Left Button is
            *  down); MK_RBUTTON (set if Right Button is down); MK_SHIFT (set
            *  if Shift Key is down); MK_CONTROL (set if Control Key is down).
            *  Since this sample does nothing with the mouse message it is
            *  passed to DefWindowProc for handling
            \***********************************************************/

        case WM_MOUSEMOVE:
        case WM_BUTTON1DOWN:
        case WM_BUTTON1UP:
        case WM_BUTTON2DOWN:
        case WM_BUTTON2UP:
        case WM_BUTTON1DBLCLK:
        case WM_BUTTON2DBLCLK:

        default:
            /***********************************************************\
            *  Everything else comes here.  This call MUST exist
            *  in your window proc.
            \***********************************************************/

            return( (ULONG)WinDefWindowProc(hWnd, message, 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.