|
|
Microsoft OS/2 SDK PM 08-08-1988
/****************************** Module Header ******************************\
* Module Name: skelnres.c
*
* Non-resident portion of Presentation Manager Skel Application
*
* It illustrates the building of a class record, the registering of
* that class record with Presentattion Manager and the creation of a window
* of that class. See Skel.DEF for the associated module definition
* file
*
* This is a MIDDLE model application, it has three code segments _RES, _INIT
* and _NRES and one data segment _DATA.
*
* For MIDDLE model, procedures that are accessed from another segment
* must be declared FAR (see Skel.h).
*
* Code that is NOT part of the Skel but is merely for demo purposes is
* marked as being for demo purposes and should be replaced/removed when this
* Skel is converted to a real application.
*
* Created: 25-Jul-88 (adapted from PM Template App.)
*
* Created by Microsoft Corporation
*
*
\***************************************************************************/
#define INCL_GPI
#define INCL_WIN
#define INCL_AVIO
#define INCL_BASE
#include <stdlib.h>
#include <os2.h>
#include <stdio.h>
#include "Skel.h"
/* min and max macros */
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
HAB hAB;
HMQ hMsgQ;
HWND hwndSkel;
HWND hwndSkelFrame;
HDC hDC;
HVPS hVPS;
HPS hPS;
USHORT Vid_Cols, Vid_Rows;
/************************************************************************\
* The following following are variables and definitions that are part of
* the Skel only for demo purposes and will be replaced when the
* Skel is converted to an application
\************************************************************************/
#define RGBBLACK 0L
#define CCHSTR 15
#define CSTR 7
#define POSMIN 0
#define POSMAX 100
#define LINEINC 5
#define PAGEINC 25
CHAR szContent[31];
CHAR szStr[CCHSTR+1];
CHAR szDefault[CCHSTR+1];
CHAR szAppName[10];
BOOL bCheckBox = TRUE;
BOOL fDoAsync = FALSE;
BOOL fDoFlash = FALSE;
SHORT fDisplay = IDMCOLOR;
SHORT cchContent;
SHORT iSel = 2;
SHORT posV = 50;
SHORT posH = 50;
/*********** End of demo purpose variables and definitions ************/
/***********************************************************************\
*
* Procedures in alphabetical order
*
\***********************************************************************/
ULONG FAR PASCAL SkelAboutDlg( hWndDlg, message, mp1, mp2 )
HWND hWndDlg;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
switch( message )
{
case WM_COMMAND: /* the user has pressed a button */
switch( SHORT1FROMMP( mp1 ) ) /* which button? */
{
case DID_OK:
case DID_CANCEL:
WinDismissDlg( hWndDlg, TRUE );
break;
default:
return( FALSE );
}
break;
default:
return( (ULONG) WinDefDlgProc( hWndDlg, message, mp1, mp2 ) );
}
return( FALSE );
}
VOID SkelCharInput( hWnd, ch, flags, cRepeat )
HWND hWnd;
SHORT ch;
SHORT flags;
SHORT cRepeat;
{
/* ignore cRepeat if you want to ignore auto-repeated keys */
while (cRepeat-- != 0)
{
}
}
VOID SkelCommand(hWnd, id, source, mouse)
HWND hWnd;
SHORT id;
SHORT source;
BOOL mouse;
{
/******* The code below is for demo purposes only *******/
RECTL rect;
HPS hPS;
switch( id )
{
case IDMFLASH:
WinQueryWindowRect( hWnd, (PRECTL)&rect );
hPS = WinGetPS(hWnd );
WinInvertRect( hPS, (PRECTL)&rect );
WinInvertRect( hPS, (PRECTL)&rect );
WinReleasePS( hPS );
break;
case IDMABOUT:
WinDlgBox( HWND_DESKTOP, hWnd, (PFNWP)SkelAboutDlg, NULL,
IDD_ABOUT, NULL );
break;
}
/******* The code above is for demo purposes only *******/
}
VOID InvisoCursor()
{
VIOCURSORINFO vci;
vci.yStart = 0; /* beginning scan line for cursor */
vci.cEnd = 0; /* ending scan line, zero-based */
vci.cx = 0; /* default width, one character */
vci.attr = -1; /* invisible attribute */
VioSetCurType(&vci, hVPS);
}
VOID SkelCreate(hWnd, lParam)
HWND hWnd;
LONG lParam;
{
char *pch1;
char *pch2;
/******* The code below is for demo purposes only *******/
cchContent = WinLoadString(hAB, NULL, IDSCONTENT, sizeof(szContent),
(PCH)szContent);
WinLoadString(hAB, NULL, IDSDEFAULT, sizeof(szDefault), (PCH)szDefault);
/* copy default string into szStr */
for (pch1 = szStr, pch2 = szDefault; *pch1++ = *pch2++; )
;
/******* The code above is for demo purposes only *******/
/* open Device Context for the window */
/* hWnd is the client window */
hDC = WinOpenWindowDC(hWnd);
/* open PS for text drawing */
VioCreatePS( &hVPS, VIO_PS_ROWS, VIO_PS_COLUMNS, 0, CATTRBYTES, 0);
/* associate VIO PS with the device context */
VioAssociate( hDC, hVPS);
/* make cursor invisible */
InvisoCursor();
}
VOID SkelSetFocus( hWnd )
HWND hWnd;
{
}
VOID SkelHorzScroll( hWnd, code, posNew )
HWND hWnd;
SHORT code;
SHORT posNew;
{
switch( code )
{
case SB_LINEUP: /* line left */
break;
case SB_LINEDOWN: /* line right */
break;
case SB_PAGEUP: /* page left */
break;
case SB_PAGEDOWN: /* page right */
break;
case SB_SLIDERPOSITION: /* position to posNew */
break;
case SB_SLIDERTRACK:
break;
}
}
VOID SkelPaint( hWnd, hPS )
HWND hWnd;
HPS hPS;
{
/* Here the application paints its window. */
/* draw the text */
VioShowPS( VIO_PS_ROWS, VIO_PS_COLUMNS, 0, hVPS);
}
/******* The code below is for demo purposes only *******/
VOID SkelQueryQuit( hWnd )
HWND hWnd;
{
CHAR szOkClose[CCHMAXSTRING];
CHAR szClose[CCHMAXSTRING];
WinLoadString(hAB, NULL, IDSOKCLOSE, CCHMAXSTRING , (PCH)szOkClose);
WinLoadString(hAB, NULL, IDSCLOSE, CCHMAXSTRING , (PCH)szClose );
WinAlarm( HWND_DESKTOP, WA_WARNING );
if ( WinMessageBox(HWND_DESKTOP, hWnd, (PCH)szOkClose, (PCH)szClose,
NULL, MB_OKCANCEL|MB_ICONQUESTION ) == DID_OK )
WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
}
/******* The code above is for demo purposes only *******/
/******* The code below is for demo purposes only *******/
VOID SkelTimer( hWnd, id )
HWND hWnd;
USHORT id;
{
}
/******* The code above is for demo purposes only *******/
/******* The code below is for demo purposes only *******/
VOID SkelVertScroll( hWnd, code, posNew )
HWND hWnd;
SHORT code;
USHORT posNew;
{
switch( code )
{
case SB_LINEUP:
VioWrtCharStr("Line Up ", /* string to display */
12, /* length of string */
12, /* row */
30, /* column */
hVPS); /* video handle */
break;
case SB_LINEDOWN:
VioWrtCharStr("Line Down ", /* string to display */
12, /* length of string */
12, /* row */
30, /* column */
hVPS); /* video handle */
break;
case SB_PAGEUP:
VioWrtCharStr("Page Up ", /* string to display */
12, /* length of string */
12, /* row */
30, /* column */
hVPS); /* video handle */
break;
case SB_PAGEDOWN:
VioWrtCharStr("Page Down ", /* string to display */
12, /* length of string */
12, /* row */
30, /* column */
hVPS); /* video handle */
break;
case SB_SLIDERPOSITION:
VioWrtCharStr("Slider Pos ", /* string to display */
12, /* length of string */
12, /* row */
30, /* column */
hVPS); /* video handle */
break;
case SB_SLIDERTRACK:
VioWrtCharStr("Slider Track", /* string to display */
12, /* length of string */
12, /* row */
30, /* column */
hVPS); /* video handle */
break;
}
}
/******* The code above is for demo purposes only *******/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.