home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Unleashed
/
Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso
/
repease
/
rep_blk.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-14
|
6KB
|
192 lines
/*==============================================================================
REP_BLK.C
Report Ease clipboard functions.
ReportEase Plus
Sub Systems, Inc.
ReportEase Plus, Copyright (c) 1993, Sub Systems, Inc. All Rights Reserved.
159 Main Street, #8C, Stoneham, MA 02180
(617) 438-8901.
Software License Agreement (1993)
----------------------------------
This license agreement allows the purchaser the right to modify the
source code to incorporate in their application.
The target application must not be distributed as a standalone report writer
or a mail merge product.
Sub Systems, Inc. reserves the right to prosecute anybody found to be
making illegal copies of the executable software or compiling the source
code for the purpose of selling there after.
===============================================================================*/
#include "windows.h"
#if defined (_WIN32)
#if !defined(WIN32)
#define WIN32
#endif
#endif
#if !defined(WIN32)
#include "print.h"
#endif
#include "stdio.h"
#include "stdlib.h"
#include "ctype.h"
#include "fcntl.h"
#include "io.h"
#include "sys\types.h"
#include "sys\stat.h"
#include "string.h"
#include "setjmp.h"
#include "rep.h"
#define PREFIX extern
#include "rep1.h"
/******************************************************************************
PictureFromClipboard:
Routine to copy a picture in the BITMAP format the current cursor
location.
*******************************************************************************/
PictureFromClipboard()
{
HANDLE hClip;
int pict;
//**** open and access the clipboard ***********************************
if (!OpenClipboard(hFrWnd)) { // open buffer
MessageBox(hFrWnd,"Clipboard in use by another application","Not Available",MB_OK);
return FALSE;
}
if (NULL==(hClip=GetClipboardData(CF_BITMAP))) {
MessageBox(hFrWnd,"Clipboard does not contain a Picture Bitmap Data","Not Available",MB_OK);
CloseClipboard();
return FALSE;
}
if ((pict=FrCreateDIB(hClip))==-1) { // create a device independent bitmap
CloseClipboard();
return FALSE;
}
if (!FrXlateDIB(hFrDC,pict)) { // translate DIB to device bitmap
CloseClipboard();
return FALSE;
}
// END COPY
CloseClipboard();
NewPict=pict; // update the global variable
return TRUE;
}
/******************************************************************************
PictureFromFile:
This routine asks for a bitmap file name. It load the bitmap
in the font table and saves the font table index in a global variable.
*******************************************************************************/
PictureFromFile()
{
LPSTR pImage;
LPBITMAPINFOHEADER pInfo;
int pict,height,width;
char name[128];
WORD BmSign;
HFILE iFile=HFILE_ERROR;
BITMAPFILEHEADER hdr;
DWORD ImageSize,InfoSize,FileSize;
if ((pict=FindOpenSlot())==-1) return FALSE; // ran out of picture table
// get the file name from the user and open the bitmap file
name[0]=0;
while (iFile==HFILE_ERROR) {
if (!GetFileName(TRUE,name,"Bitmap Files(*.BMP)|*.BMP|")) return FALSE;
FileSize=GetFileLength(name); // get the file length
if (HFILE_ERROR==(iFile=_lopen(name,OF_READ))) {
MessageBox(hFrWnd,"Can not Open the Bitmap File",NULL,MB_OK);
continue;
}
if (_lread(iFile,&hdr,sizeof(BITMAPFILEHEADER))!=sizeof(BITMAPFILEHEADER) ) {
MessageBox(hFrWnd,"Can not Read the Bitmap File",NULL,MB_OK);
_lclose(iFile);
iFile=HFILE_ERROR;
continue;
}
BmSign=(((WORD)'M')<<8)|'B'; // signature of the bitmap file
if (hdr.bfType!=BmSign) {
MessageBox(hFrWnd,"Invalid Bitmap File",NULL,MB_OK);
_lclose(iFile);
iFile=HFILE_ERROR;
continue;
}
}
//************ calculate image and info structure sizes **
InfoSize=hdr.bfOffBits-sizeof(BITMAPFILEHEADER);
ImageSize=FileSize-sizeof(BITMAPFILEHEADER)-InfoSize;
//************ Allocate Space for image and info *********
if (NULL==(FrFont[pict].hImage=GlobalAlloc(GMEM_MOVEABLE,ImageSize))
|| NULL==(FrFont[pict].hInfo=GlobalAlloc(GMEM_MOVEABLE,InfoSize))
|| NULL==(pImage=GlobalLock(FrFont[pict].hImage))
|| NULL==(pInfo=(LPBITMAPINFOHEADER)GlobalLock(FrFont[pict].hInfo)) ) {
MessageBox(hFrWnd,"Ran Out of Memory",NULL,MB_OK);
InitFrObject(pict);
_lclose(iFile);
return FALSE;
}
//********** Read image and info data *******************
if (!FrFarRead(iFile,InfoSize,(LPSTR)pInfo)
|| !FrFarRead(iFile,ImageSize,pImage) ) {
MessageBox(hFrWnd,"Ran Out of Memory",NULL,MB_OK);
InitFrObject(pict);
_lclose(iFile);
return FALSE;
}
if (pInfo->biSize!=sizeof(BITMAPINFOHEADER)) {
MessageBox(hFrWnd,"Unrecognized Bitmap File Format!",NULL,MB_OK);
InitFrObject(pict);
_lclose(iFile);
return FALSE;
}
//******** initialize other FrFont variables **********
height=(int)(pInfo->biHeight); // dimensions in pixel units
width=(int)(pInfo->biWidth);
FrFont[pict].InUse=TRUE;
FrFont[pict].PictHeight=(UINT)((DWORD)(height)*72L/(DWORD)ResY); // dimension in point sizes
FrFont[pict].PictWidth=(UINT)((DWORD)(width)*72L/(DWORD)ResX);
FrFont[pict].ImageSize=ImageSize;
FrFont[pict].InfoSize=InfoSize;
FrFont[pict].IsPict=TRUE;
GlobalUnlock(FrFont[pict].hImage);
GlobalUnlock(FrFont[pict].hInfo);
//***************** translate into device bitmap *********************
if (!FrXlateDIB(hFrDC,pict)) { // translate DIB to device bitmap
InitFrObject(pict);
_lclose(iFile);
return FALSE;
}
// end of routine
_lclose(iFile);
NewPict=pict; // update the global variable for output
return TRUE;
}