|
|
1.1 ! root 1: /****************************** Module Header ******************************\ ! 2: * Module Name: tempres.c ! 3: * ! 4: * Resident portion of Presentation Manager Template Application ! 5: * ! 6: * Created by Microsoft Corp., 1988 ! 7: * ! 8: \***************************************************************************/ ! 9: ! 10: #define INCL_WIN ! 11: ! 12: #include <os2.h> ! 13: #include "template.h" ! 14: ! 15: extern HAB hAB; ! 16: extern HMQ hMsgQ; ! 17: extern HWND hwndTemplate; ! 18: extern HWND hwndTemplateFrame; ! 19: ! 20: SHORT cdecl main( ) ! 21: { ! 22: QMSG qMsg; ! 23: ! 24: hAB = WinInitialize(NULL); ! 25: hMsgQ = WinCreateMsgQueue( hAB, 0 ); ! 26: ! 27: if ( !TemplateInitApp( ) ) ! 28: return( FALSE ); ! 29: ! 30: while( WinGetMsg( hAB, (PQMSG)&qMsg, (HWND)NULL, 0, 0 ) ) ! 31: { ! 32: WinDispatchMsg( hAB, (PQMSG)&qMsg ); ! 33: } ! 34: ! 35: WinDestroyWindow( hwndTemplateFrame ); ! 36: WinDestroyMsgQueue( hMsgQ ); ! 37: WinTerminate( hAB ); ! 38: } ! 39: ! 40: ! 41: ! 42: MRESULT EXPENTRY TemplateWndProc( hWnd, message, mp1, mp2 ) ! 43: HWND hWnd; ! 44: USHORT message; ! 45: MPARAM mp1; ! 46: MPARAM mp2; ! 47: { ! 48: /* Procedures which make up the window class. */ ! 49: ! 50: HPS hPS; ! 51: RECTL rect; ! 52: ! 53: switch( message ) ! 54: { ! 55: case WM_CREATE: ! 56: /***********************************************************\ ! 57: * Window's being created; mp2 contains lpParam field ! 58: * passed to CreateWindow ! 59: \***********************************************************/ ! 60: TemplateCreate( hWnd, (ULONG)mp2 ); ! 61: break; ! 62: ! 63: case WM_ACTIVATE: ! 64: /***********************************************************\ ! 65: * Window is becoming active window if LOUSHORT(mp1) is ! 66: * TRUE, inactive if LOUSHORT(mp1) is FALSE. mp2 is ! 67: * the window handle of the window being deactivated. ! 68: \***********************************************************/ ! 69: if ( SHORT1FROMMP(mp1) && SHORT2FROMMP(mp1) ) ! 70: WinSetFocus( HWND_DESKTOP, hWnd ); ! 71: break; ! 72: ! 73: case WM_SETFOCUS: ! 74: /***********************************************************\ ! 75: * The window is getting the focus. mp1 contains the ! 76: * window handle of the window that previously had the focus. ! 77: \***********************************************************/ ! 78: TemplateSetFocus( hWnd ); ! 79: break; ! 80: ! 81: case WM_PAINT: ! 82: /***********************************************************\ ! 83: * Time for the window to draw itself. ! 84: \***********************************************************/ ! 85: hPS = WinBeginPaint( hWnd, (HPS)NULL, (PRECTL)&rect ); ! 86: TemplatePaint( hWnd, hPS ); ! 87: WinEndPaint( hPS ); ! 88: break; ! 89: ! 90: case WM_CHAR: ! 91: /***********************************************************\ ! 92: * Character input. The low word of mp1 contains the ! 93: * key type flags, the high word of mp1 contains the ! 94: * auto-repeat count, and the low word of mp2 contains ! 95: * the character code. ! 96: \***********************************************************/ ! 97: TemplateCharInput( hWnd, SHORT1FROMMP(mp2), SHORT1FROMMP(mp1), ! 98: SHORT2FROMMP(mp1) ); ! 99: break; ! 100: ! 101: case WM_CLOSE: ! 102: /***********************************************************\ ! 103: * message from system to close the Client window. ! 104: \***********************************************************/ ! 105: TemplateQueryQuit( hWnd ); ! 106: break; ! 107: ! 108: case WM_COMMAND: ! 109: /***********************************************************\ ! 110: * A menu item has been selected, or a control is notifying ! 111: * its parent. mp1 is the menu item value (for menus), ! 112: * or control ID (for controls). For controls, the low word ! 113: * of mp2 has the window handle of the control, and the hi ! 114: * word has the notification code. For menus, mp2 contains ! 115: * 0L. ! 116: \***********************************************************/ ! 117: TemplateCommand( hWnd, SHORT1FROMMP(mp1), SHORT1FROMMP(mp2), ! 118: SHORT2FROMMP(mp2)); ! 119: break; ! 120: ! 121: case WM_TIMER: ! 122: /***********************************************************\ ! 123: * Timer message. mp1 contains the timer ID value ! 124: \***********************************************************/ ! 125: TemplateTimer( hWnd, SHORT1FROMMP(mp1) ); ! 126: break; ! 127: ! 128: case WM_VSCROLL: ! 129: /***********************************************************\ ! 130: * Vertical scroll bar input. mp1 contains the ! 131: * scroll code. For the thumb movement codes, the low ! 132: * word of mp2 contain the new scroll position. ! 133: * Possible values for mp1 are: SB_LINEUP, SB_LINEDOWN, ! 134: * SB_PAGEUP, SB_PAGEDOWN, SB_THUMBPOSITION, SB_THUMBTRACK ! 135: \***********************************************************/ ! 136: TemplateVertScroll( hWnd, HIUSHORT(mp2), LOUSHORT(mp2) ); ! 137: break; ! 138: ! 139: case WM_HSCROLL: ! 140: /***********************************************************\ ! 141: * Horizontal scroll bar input. Parameters same as for ! 142: * WM_HSCROLL. UP and DOWN should be interpreted as LEFT ! 143: * and RIGHT, respectively. ! 144: \***********************************************************/ ! 145: TemplateHorzScroll( hWnd, HIUSHORT(mp2), LOUSHORT(mp2) ); ! 146: break; ! 147: ! 148: case WM_ERASEBACKGROUND: ! 149: /* ! 150: * Let frame control erase background for us ! 151: */ ! 152: return (TRUE); ! 153: break; ! 154: ! 155: /***********************************************************\ ! 156: * For each of following mouse window messages, mp1 contains ! 157: * bits indicating whether or not various virtual keys are down, ! 158: * and mp2 is a WPOINT containing the mouse coordinates. The ! 159: * keydown bits of mp1 are: MK_LBUTTON (set if Left Button is ! 160: * down); MK_RBUTTON (set if Right Button is down); MK_SHIFT (set ! 161: * if Shift Key is down); MK_CONTROL (set if Control Key is down). ! 162: * Since this sample does nothing with the mouse message it is ! 163: * passed to DefWindowProc for handling ! 164: \***********************************************************/ ! 165: ! 166: case WM_MOUSEMOVE: ! 167: case WM_BUTTON1DOWN: ! 168: case WM_BUTTON1UP: ! 169: case WM_BUTTON2DOWN: ! 170: case WM_BUTTON2UP: ! 171: case WM_BUTTON1DBLCLK: ! 172: case WM_BUTTON2DBLCLK: ! 173: ! 174: default: ! 175: /***********************************************************\ ! 176: * Everything else comes here. This call MUST exist ! 177: * in your window proc. ! 178: \***********************************************************/ ! 179: ! 180: return( (ULONG)WinDefWindowProc(hWnd, message, mp1, mp2)); ! 181: break; ! 182: } ! 183: return( 0L ); ! 184: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.