|
|
1.1 ! root 1: /*--------------------- file identification ------------------------*/ ! 2: ! 3: /* ! 4: clipshow.c ! 5: ! 6: SHOWS THE CURRENT CONTENTS OF THE CLIPBOARD ! 7: ! 8: Created by Microsoft Corp., 1988 ! 9: ! 10: ! 11: SEE ALSO: ! 12: ! 13: the program clipput.exe will put some text on the ! 14: clipboard when its Copy menu item is chosen. ! 15: ! 16: ! 17: */ ! 18: ! 19: ! 20: /*---------------------- include files -----------------------------*/ ! 21: #define INCL_PM ! 22: #define INCL_DOS ! 23: #include <os2.h> ! 24: #include "clipshow.h" ! 25: ! 26: ! 27: /*------------------------------ main ------------------------------*/ ! 28: ! 29: BOOL main() ! 30: ! 31: { ! 32: /* ! 33: * local constants ! 34: */ ! 35: #define USE_DEF_QUEUE_SIZE 0 ! 36: ! 37: /* ! 38: * local variables ! 39: */ ! 40: QMSG qmsg; ! 41: ! 42: /* ! 43: * initialize this application thread's use of the PM ! 44: */ ! 45: habTheAnchorBlock = WinInitialize (NULL) ; ! 46: ! 47: /* ! 48: * create a message queue for this application thread ! 49: */ ! 50: hmqTheMessageQueue = WinCreateMsgQueue ! 51: (habTheAnchorBlock, USE_DEF_QUEUE_SIZE) ; ! 52: /* ! 53: * initialize the application ! 54: */ ! 55: if (!GenericInit()) ! 56: return(FALSE); /* failed loading */ ! 57: ! 58: hwndOldViewer = WinSetClipbrdViewer(habTheAnchorBlock,hwndClient); ! 59: ! 60: /* ! 61: * run the main event loop ! 62: */ ! 63: while ( WinGetMsg ( (HAB)NULL, &qmsg, (HWND)NULL, 0, 0 ) ) ! 64: WinDispatchMsg( (HAB)NULL, &qmsg ); ! 65: ! 66: ! 67: /* ! 68: * kill the window ! 69: */ ! 70: WinDestroyWindow( hwndFrame ); ! 71: ! 72: /* ! 73: * PM cleanup ! 74: */ ! 75: WinDestroyMsgQueue( hmqTheMessageQueue ); ! 76: WinTerminate( habTheAnchorBlock ); ! 77: } ! 78: ! 79: ! 80: /*--------------------- GenericInit -------------------------*/ ! 81: BOOL GenericInit() { ! 82: ! 83: ULONG lControlStyle = FCF_TITLEBAR | FCF_SYSMENU | ! 84: FCF_SIZEBORDER | FCF_MINMAX; ! 85: ! 86: ! 87: if (!WinRegisterClass( habTheAnchorBlock, ! 88: szClassName, ! 89: (PFNWP)GenericWndProc, ! 90: CS_SIZEREDRAW, ! 91: 0 )) ! 92: return( FALSE ); ! 93: ! 94: hwndFrame = WinCreateStdWindow( HWND_DESKTOP, ! 95: 0L, ! 96: &lControlStyle, ! 97: szClassName, ! 98: szClassName, ! 99: 0L, ! 100: NULL, ! 101: 0, ! 102: &hwndClient); ! 103: ! 104: WinSetWindowPos(hwndFrame, /* window */ ! 105: HWND_TOP, /* window behind */ ! 106: 50, /* x pos */ ! 107: 50, /* y pos */ ! 108: 200, /* x size */ ! 109: 200, /* y size */ ! 110: SWP_ACTIVATE|SWP_SIZE|SWP_MOVE|SWP_SHOW); /* flags */ ! 111: ! 112: ! 113: ! 114: if (!hwndFrame) ! 115: return(FALSE); ! 116: ! 117: return(TRUE); ! 118: } ! 119: ! 120: /*---------------- the main window procedure --------------------------*/ ! 121: MRESULT FAR PASCAL GenericWndProc( hwnd, usMessage, mp1, mp2 ) ! 122: HWND hwnd; ! 123: USHORT usMessage; ! 124: MPARAM mp1; ! 125: MPARAM mp2; ! 126: { ! 127: HPS hps; ! 128: RECTL rect; ! 129: HBITMAP hbitmap; ! 130: ULONG hText; ! 131: PSZ pszText; ! 132: POINTL ptlDest; ! 133: ! 134: switch (usMessage) { ! 135: case WM_PAINT: ! 136: hps = WinBeginPaint(hwnd,NULL,&rect); ! 137: WinFillRect(hps,&rect,CLR_WHITE); ! 138: WinSendMsg(hwnd,WM_DRAWCLIPBOARD,(MPARAM)0L,(MPARAM)0L); ! 139: WinEndPaint(hps); ! 140: return 0L; ! 141: ! 142: case WM_DRAWCLIPBOARD: ! 143: ! 144: if (! WinOpenClipbrd(habTheAnchorBlock)) ! 145: return 0L; ! 146: ! 147: if (hText = WinQueryClipbrdData(habTheAnchorBlock,CF_TEXT)) ! 148: { ! 149: pszText = MAKEP((SEL)hText,0); ! 150: ! 151: hps = WinGetPS(hwnd); ! 152: WinQueryWindowRect(hwnd,&rect); ! 153: WinDrawText(hps, ! 154: 0xFFFF, /* NULL teminated string */ ! 155: pszText, /* the string ?? */ ! 156: &rect, /* where to put it */ ! 157: CLR_BLACK, /* foreground */ ! 158: CLR_WHITE, /* background */ ! 159: DT_CENTER | DT_VCENTER | DT_ERASERECT); ! 160: WinValidateRect(hwnd,(PRECTL)NULL,FALSE); ! 161: WinReleasePS(hps); ! 162: WinCloseClipbrd(habTheAnchorBlock); ! 163: return 0L; ! 164: } ! 165: if (hbitmap = WinQueryClipbrdData(habTheAnchorBlock,CF_BITMAP)) ! 166: { ! 167: hps = WinGetPS(hwnd); ! 168: ptlDest.x = ptlDest.y = 0; ! 169: WinDrawBitmap(hps, ! 170: hbitmap, ! 171: (PRECTL)NULL, /* draw entire bitmap */ ! 172: &ptlDest, /* where to put it in dest */ ! 173: CLR_BLACK, /* foreground */ ! 174: CLR_WHITE, /* background */ ! 175: DBM_NORMAL); /* blit flags */ ! 176: WinValidateRect(hwnd,(PRECTL)NULL,FALSE); ! 177: WinReleasePS(hps); ! 178: WinCloseClipbrd(habTheAnchorBlock); ! 179: return 0L; ! 180: } ! 181: /* ! 182: * we fall through to here if none of our formats are ! 183: * available. ! 184: */ ! 185: WinCloseClipbrd(habTheAnchorBlock); ! 186: return 0L; ! 187: ! 188: ! 189: default: ! 190: return( WinDefWindowProc( hwnd, usMessage, mp1, mp2 ) ); ! 191: } ! 192: return(0L); ! 193: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.