|
|
1.1 ! root 1: /****************************** Module Header ******************************\ ! 2: * Module Name: skelnres.c ! 3: * ! 4: * Non-resident portion of Presentation Manager Skel Application ! 5: * ! 6: * It illustrates the building of a class record, the registering of ! 7: * that class record with Presentattion Manager and the creation of a window ! 8: * of that class. See Skel.DEF for the associated module definition ! 9: * file ! 10: * ! 11: * This is a MIDDLE model application, it has three code segments _RES, _INIT ! 12: * and _NRES and one data segment _DATA. ! 13: * ! 14: * For MIDDLE model, procedures that are accessed from another segment ! 15: * must be declared FAR (see Skel.h). ! 16: * ! 17: * Code that is NOT part of the Skel but is merely for demo purposes is ! 18: * marked as being for demo purposes and should be replaced/removed when this ! 19: * Skel is converted to a real application. ! 20: * ! 21: * Created: 25-Jul-88 (adapted from PM Template App.) ! 22: * ! 23: * Created by Microsoft Corporation ! 24: * ! 25: * ! 26: \***************************************************************************/ ! 27: ! 28: #define INCL_GPI ! 29: #define INCL_WIN ! 30: #define INCL_AVIO ! 31: #define INCL_BASE ! 32: ! 33: #include <stdlib.h> ! 34: #include <os2.h> ! 35: #include <stdio.h> ! 36: #include "Skel.h" ! 37: ! 38: /* min and max macros */ ! 39: #define max(a,b) (((a) > (b)) ? (a) : (b)) ! 40: #define min(a,b) (((a) < (b)) ? (a) : (b)) ! 41: ! 42: HAB hAB; ! 43: HMQ hMsgQ; ! 44: HWND hwndSkel; ! 45: HWND hwndSkelFrame; ! 46: HDC hDC; ! 47: HVPS hVPS; ! 48: HPS hPS; ! 49: USHORT Vid_Cols, Vid_Rows; ! 50: ! 51: /************************************************************************\ ! 52: * The following following are variables and definitions that are part of ! 53: * the Skel only for demo purposes and will be replaced when the ! 54: * Skel is converted to an application ! 55: \************************************************************************/ ! 56: ! 57: #define RGBBLACK 0L ! 58: #define CCHSTR 15 ! 59: #define CSTR 7 ! 60: #define POSMIN 0 ! 61: #define POSMAX 100 ! 62: #define LINEINC 5 ! 63: #define PAGEINC 25 ! 64: ! 65: CHAR szContent[31]; ! 66: CHAR szStr[CCHSTR+1]; ! 67: CHAR szDefault[CCHSTR+1]; ! 68: CHAR szAppName[10]; ! 69: BOOL bCheckBox = TRUE; ! 70: BOOL fDoAsync = FALSE; ! 71: BOOL fDoFlash = FALSE; ! 72: SHORT fDisplay = IDMCOLOR; ! 73: SHORT cchContent; ! 74: SHORT iSel = 2; ! 75: SHORT posV = 50; ! 76: SHORT posH = 50; ! 77: ! 78: /*********** End of demo purpose variables and definitions ************/ ! 79: ! 80: /***********************************************************************\ ! 81: * ! 82: * Procedures in alphabetical order ! 83: * ! 84: \***********************************************************************/ ! 85: ! 86: ! 87: ULONG FAR PASCAL SkelAboutDlg( hWndDlg, message, mp1, mp2 ) ! 88: HWND hWndDlg; ! 89: USHORT message; ! 90: MPARAM mp1; ! 91: MPARAM mp2; ! 92: { ! 93: switch( message ) ! 94: { ! 95: case WM_COMMAND: /* the user has pressed a button */ ! 96: switch( SHORT1FROMMP( mp1 ) ) /* which button? */ ! 97: { ! 98: case DID_OK: ! 99: case DID_CANCEL: ! 100: WinDismissDlg( hWndDlg, TRUE ); ! 101: break; ! 102: ! 103: default: ! 104: return( FALSE ); ! 105: } ! 106: break; ! 107: ! 108: default: ! 109: return( (ULONG) WinDefDlgProc( hWndDlg, message, mp1, mp2 ) ); ! 110: } ! 111: return( FALSE ); ! 112: } ! 113: ! 114: ! 115: ! 116: VOID SkelCharInput( hWnd, ch, flags, cRepeat ) ! 117: HWND hWnd; ! 118: SHORT ch; ! 119: SHORT flags; ! 120: SHORT cRepeat; ! 121: { ! 122: /* ignore cRepeat if you want to ignore auto-repeated keys */ ! 123: while (cRepeat-- != 0) ! 124: { ! 125: } ! 126: } ! 127: ! 128: VOID SkelCommand(hWnd, id, source, mouse) ! 129: HWND hWnd; ! 130: SHORT id; ! 131: SHORT source; ! 132: BOOL mouse; ! 133: { ! 134: /******* The code below is for demo purposes only *******/ ! 135: ! 136: RECTL rect; ! 137: HPS hPS; ! 138: ! 139: switch( id ) ! 140: { ! 141: case IDMFLASH: ! 142: WinQueryWindowRect( hWnd, (PRECTL)&rect ); ! 143: hPS = WinGetPS(hWnd ); ! 144: WinInvertRect( hPS, (PRECTL)&rect ); ! 145: WinInvertRect( hPS, (PRECTL)&rect ); ! 146: WinReleasePS( hPS ); ! 147: break; ! 148: ! 149: case IDMABOUT: ! 150: WinDlgBox( HWND_DESKTOP, hWnd, (PFNWP)SkelAboutDlg, NULL, ! 151: IDD_ABOUT, NULL ); ! 152: break; ! 153: ! 154: } ! 155: /******* The code above is for demo purposes only *******/ ! 156: } ! 157: ! 158: VOID InvisoCursor() ! 159: { ! 160: VIOCURSORINFO vci; ! 161: vci.yStart = 0; /* beginning scan line for cursor */ ! 162: vci.cEnd = 0; /* ending scan line, zero-based */ ! 163: vci.cx = 0; /* default width, one character */ ! 164: vci.attr = -1; /* invisible attribute */ ! 165: VioSetCurType(&vci, hVPS); ! 166: } ! 167: ! 168: VOID SkelCreate(hWnd, lParam) ! 169: HWND hWnd; ! 170: LONG lParam; ! 171: { ! 172: char *pch1; ! 173: char *pch2; ! 174: ! 175: /******* The code below is for demo purposes only *******/ ! 176: ! 177: cchContent = WinLoadString(hAB, NULL, IDSCONTENT, sizeof(szContent), ! 178: (PCH)szContent); ! 179: ! 180: WinLoadString(hAB, NULL, IDSDEFAULT, sizeof(szDefault), (PCH)szDefault); ! 181: ! 182: /* copy default string into szStr */ ! 183: for (pch1 = szStr, pch2 = szDefault; *pch1++ = *pch2++; ) ! 184: ; ! 185: ! 186: /******* The code above is for demo purposes only *******/ ! 187: ! 188: /* open Device Context for the window */ ! 189: /* hWnd is the client window */ ! 190: hDC = WinOpenWindowDC(hWnd); ! 191: ! 192: /* open PS for text drawing */ ! 193: VioCreatePS( &hVPS, VIO_PS_ROWS, VIO_PS_COLUMNS, 0, CATTRBYTES, 0); ! 194: ! 195: /* associate VIO PS with the device context */ ! 196: VioAssociate( hDC, hVPS); ! 197: ! 198: /* make cursor invisible */ ! 199: InvisoCursor(); ! 200: ! 201: } ! 202: ! 203: ! 204: VOID SkelSetFocus( hWnd ) ! 205: HWND hWnd; ! 206: { ! 207: } ! 208: ! 209: ! 210: ! 211: VOID SkelHorzScroll( hWnd, code, posNew ) ! 212: HWND hWnd; ! 213: SHORT code; ! 214: SHORT posNew; ! 215: { ! 216: switch( code ) ! 217: { ! 218: case SB_LINEUP: /* line left */ ! 219: break; ! 220: case SB_LINEDOWN: /* line right */ ! 221: break; ! 222: case SB_PAGEUP: /* page left */ ! 223: break; ! 224: case SB_PAGEDOWN: /* page right */ ! 225: break; ! 226: case SB_SLIDERPOSITION: /* position to posNew */ ! 227: break; ! 228: case SB_SLIDERTRACK: ! 229: break; ! 230: } ! 231: } ! 232: ! 233: VOID SkelPaint( hWnd, hPS ) ! 234: HWND hWnd; ! 235: HPS hPS; ! 236: { ! 237: ! 238: /* Here the application paints its window. */ ! 239: /* draw the text */ ! 240: VioShowPS( VIO_PS_ROWS, VIO_PS_COLUMNS, 0, hVPS); ! 241: } ! 242: ! 243: ! 244: ! 245: /******* The code below is for demo purposes only *******/ ! 246: ! 247: VOID SkelQueryQuit( hWnd ) ! 248: HWND hWnd; ! 249: { ! 250: CHAR szOkClose[CCHMAXSTRING]; ! 251: CHAR szClose[CCHMAXSTRING]; ! 252: ! 253: WinLoadString(hAB, NULL, IDSOKCLOSE, CCHMAXSTRING , (PCH)szOkClose); ! 254: WinLoadString(hAB, NULL, IDSCLOSE, CCHMAXSTRING , (PCH)szClose ); ! 255: WinAlarm( HWND_DESKTOP, WA_WARNING ); ! 256: if ( WinMessageBox(HWND_DESKTOP, hWnd, (PCH)szOkClose, (PCH)szClose, ! 257: NULL, MB_OKCANCEL|MB_ICONQUESTION ) == DID_OK ) ! 258: WinPostMsg( hWnd, WM_QUIT, 0L, 0L ); ! 259: } ! 260: ! 261: /******* The code above is for demo purposes only *******/ ! 262: ! 263: ! 264: /******* The code below is for demo purposes only *******/ ! 265: ! 266: VOID SkelTimer( hWnd, id ) ! 267: HWND hWnd; ! 268: USHORT id; ! 269: { ! 270: } ! 271: ! 272: /******* The code above is for demo purposes only *******/ ! 273: ! 274: ! 275: /******* The code below is for demo purposes only *******/ ! 276: ! 277: VOID SkelVertScroll( hWnd, code, posNew ) ! 278: HWND hWnd; ! 279: SHORT code; ! 280: USHORT posNew; ! 281: { ! 282: switch( code ) ! 283: { ! 284: case SB_LINEUP: ! 285: VioWrtCharStr("Line Up ", /* string to display */ ! 286: 12, /* length of string */ ! 287: 12, /* row */ ! 288: 30, /* column */ ! 289: hVPS); /* video handle */ ! 290: break; ! 291: case SB_LINEDOWN: ! 292: VioWrtCharStr("Line Down ", /* string to display */ ! 293: 12, /* length of string */ ! 294: 12, /* row */ ! 295: 30, /* column */ ! 296: hVPS); /* video handle */ ! 297: break; ! 298: case SB_PAGEUP: ! 299: VioWrtCharStr("Page Up ", /* string to display */ ! 300: 12, /* length of string */ ! 301: 12, /* row */ ! 302: 30, /* column */ ! 303: hVPS); /* video handle */ ! 304: break; ! 305: case SB_PAGEDOWN: ! 306: VioWrtCharStr("Page Down ", /* string to display */ ! 307: 12, /* length of string */ ! 308: 12, /* row */ ! 309: 30, /* column */ ! 310: hVPS); /* video handle */ ! 311: break; ! 312: case SB_SLIDERPOSITION: ! 313: VioWrtCharStr("Slider Pos ", /* string to display */ ! 314: 12, /* length of string */ ! 315: 12, /* row */ ! 316: 30, /* column */ ! 317: hVPS); /* video handle */ ! 318: break; ! 319: case SB_SLIDERTRACK: ! 320: VioWrtCharStr("Slider Track", /* string to display */ ! 321: 12, /* length of string */ ! 322: 12, /* row */ ! 323: 30, /* column */ ! 324: hVPS); /* video handle */ ! 325: break; ! 326: } ! 327: } ! 328: ! 329: /******* 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.