|
|
Microsoft OS/2 SDK PM 08-08-1988
/*--------------------- file identification ------------------------*/
/*
clipshow.c
SHOWS THE CURRENT CONTENTS OF THE CLIPBOARD
Created by Microsoft Corp., 1988
SEE ALSO:
the program clipput.exe will put some text on the
clipboard when its Copy menu item is chosen.
*/
/*---------------------- include files -----------------------------*/
#define INCL_PM
#define INCL_DOS
#include <os2.h>
#include "clipshow.h"
/*------------------------------ main ------------------------------*/
BOOL main()
{
/*
* local constants
*/
#define USE_DEF_QUEUE_SIZE 0
/*
* local variables
*/
QMSG qmsg;
/*
* initialize this application thread's use of the PM
*/
habTheAnchorBlock = WinInitialize (NULL) ;
/*
* create a message queue for this application thread
*/
hmqTheMessageQueue = WinCreateMsgQueue
(habTheAnchorBlock, USE_DEF_QUEUE_SIZE) ;
/*
* initialize the application
*/
if (!GenericInit())
return(FALSE); /* failed loading */
hwndOldViewer = WinSetClipbrdViewer(habTheAnchorBlock,hwndClient);
/*
* run the main event loop
*/
while ( WinGetMsg ( (HAB)NULL, &qmsg, (HWND)NULL, 0, 0 ) )
WinDispatchMsg( (HAB)NULL, &qmsg );
/*
* kill the window
*/
WinDestroyWindow( hwndFrame );
/*
* PM cleanup
*/
WinDestroyMsgQueue( hmqTheMessageQueue );
WinTerminate( habTheAnchorBlock );
}
/*--------------------- GenericInit -------------------------*/
BOOL GenericInit() {
ULONG lControlStyle = FCF_TITLEBAR | FCF_SYSMENU |
FCF_SIZEBORDER | FCF_MINMAX;
if (!WinRegisterClass( habTheAnchorBlock,
szClassName,
(PFNWP)GenericWndProc,
CS_SIZEREDRAW,
0 ))
return( FALSE );
hwndFrame = WinCreateStdWindow( HWND_DESKTOP,
0L,
&lControlStyle,
szClassName,
szClassName,
0L,
NULL,
0,
&hwndClient);
WinSetWindowPos(hwndFrame, /* window */
HWND_TOP, /* window behind */
50, /* x pos */
50, /* y pos */
200, /* x size */
200, /* y size */
SWP_ACTIVATE|SWP_SIZE|SWP_MOVE|SWP_SHOW); /* flags */
if (!hwndFrame)
return(FALSE);
return(TRUE);
}
/*---------------- the main window procedure --------------------------*/
MRESULT FAR PASCAL GenericWndProc( hwnd, usMessage, mp1, mp2 )
HWND hwnd;
USHORT usMessage;
MPARAM mp1;
MPARAM mp2;
{
HPS hps;
RECTL rect;
HBITMAP hbitmap;
ULONG hText;
PSZ pszText;
POINTL ptlDest;
switch (usMessage) {
case WM_PAINT:
hps = WinBeginPaint(hwnd,NULL,&rect);
WinFillRect(hps,&rect,CLR_WHITE);
WinSendMsg(hwnd,WM_DRAWCLIPBOARD,(MPARAM)0L,(MPARAM)0L);
WinEndPaint(hps);
return 0L;
case WM_DRAWCLIPBOARD:
if (! WinOpenClipbrd(habTheAnchorBlock))
return 0L;
if (hText = WinQueryClipbrdData(habTheAnchorBlock,CF_TEXT))
{
pszText = MAKEP((SEL)hText,0);
hps = WinGetPS(hwnd);
WinQueryWindowRect(hwnd,&rect);
WinDrawText(hps,
0xFFFF, /* NULL teminated string */
pszText, /* the string ?? */
&rect, /* where to put it */
CLR_BLACK, /* foreground */
CLR_WHITE, /* background */
DT_CENTER | DT_VCENTER | DT_ERASERECT);
WinValidateRect(hwnd,(PRECTL)NULL,FALSE);
WinReleasePS(hps);
WinCloseClipbrd(habTheAnchorBlock);
return 0L;
}
if (hbitmap = WinQueryClipbrdData(habTheAnchorBlock,CF_BITMAP))
{
hps = WinGetPS(hwnd);
ptlDest.x = ptlDest.y = 0;
WinDrawBitmap(hps,
hbitmap,
(PRECTL)NULL, /* draw entire bitmap */
&ptlDest, /* where to put it in dest */
CLR_BLACK, /* foreground */
CLR_WHITE, /* background */
DBM_NORMAL); /* blit flags */
WinValidateRect(hwnd,(PRECTL)NULL,FALSE);
WinReleasePS(hps);
WinCloseClipbrd(habTheAnchorBlock);
return 0L;
}
/*
* we fall through to here if none of our formats are
* available.
*/
WinCloseClipbrd(habTheAnchorBlock);
return 0L;
default:
return( WinDefWindowProc( hwnd, usMessage, mp1, mp2 ) );
}
return(0L);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.