Esempio n. 1
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     ENHMETAHEADER emh ;
     HDC           hdc, hdcEMF ;
     HENHMETAFILE  hemfOld, hemf ;
     PAINTSTRUCT   ps ;
     RECT          rect ;
     
     switch (message)
     {
     case WM_CREATE:
          
               // Retrieve existing metafile and header
          
          hemfOld = GetEnhMetaFile (TEXT ("..\\emf3\\emf3.emf")) ;
          
          GetEnhMetaFileHeader (hemfOld, sizeof (ENHMETAHEADER), &emh) ;
          
               // Create a new metafile DC
          
          hdcEMF = CreateEnhMetaFile (NULL, TEXT ("emf7.emf"), NULL,
                                      TEXT ("EMF7\0EMF Demo #7\0")) ;
          
               // Enumerate the existing metafile
          
          EnumEnhMetaFile (hdcEMF, hemfOld, EnhMetaFileProc, NULL,
                           (RECT *) & emh.rclBounds) ;
          
               // Clean up
          
          hemf = CloseEnhMetaFile (hdcEMF) ;
          
          DeleteEnhMetaFile (hemfOld) ;
          DeleteEnhMetaFile (hemf) ;
          return 0 ;
          
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;
          
          GetClientRect (hwnd, &rect) ;
          
          rect.left   =     rect.right  / 4 ;
          rect.right  = 3 * rect.right  / 4 ;
          rect.top    =     rect.bottom / 4 ;
          rect.bottom = 3 * rect.bottom / 4 ;
          
          hemf = GetEnhMetaFile (TEXT ("emf7.emf")) ;
          
          PlayEnhMetaFile (hdc, hemf, &rect) ;
          DeleteEnhMetaFile (hemf) ;
          EndPaint (hwnd, &ps) ;
          return 0 ;
          
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
Esempio n. 2
0
void Picture_writeToWindowsMetafile (Picture me, MelderFile file) {
	try {
		HENHMETAFILE metafile = copyToMetafile (me);
		MelderFile_delete (file);   // overwrite any existing file with the same name
		DeleteEnhMetaFile (CopyEnhMetaFile (metafile, Melder_peek32toW (file -> path)));
		DeleteEnhMetaFile (metafile);
	} catch (MelderError) {
		Melder_throw (U"Picture not written to Windows metafile ", file);
	}
}
Esempio n. 3
0
void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea)
{
     ENHMETAHEADER emh ;
     HENHMETAFILE  hemf ;
     int           cxMms, cyMms, cxPix, cyPix, cxImage, cyImage ;
     RECT          rect ;
     
     cxMms = GetDeviceCaps (hdc, HORZSIZE) ;
     cyMms = GetDeviceCaps (hdc, VERTSIZE) ;
     cxPix = GetDeviceCaps (hdc, HORZRES) ;
     cyPix = GetDeviceCaps (hdc, VERTRES) ;
     
     hemf = GetEnhMetaFile (TEXT ("emf11.emf")) ;
     
     GetEnhMetaFileHeader (hemf, sizeof (emh), &emh) ;
     
     cxImage = emh.rclFrame.right - emh.rclFrame.left ;
     cyImage = emh.rclFrame.bottom - emh.rclFrame.top ;
     
     cxImage = cxImage * cxPix / cxMms / 100 ;
     cyImage = cyImage * cyPix / cyMms / 100 ;
     
     rect.left   = (cxArea - cxImage) / 2 ;
     rect.top    = (cyArea - cyImage) / 2 ;
     rect.right  = (cxArea + cxImage) / 2 ;
     rect.bottom = (cyArea + cyImage) / 2 ;
     
     PlayEnhMetaFile (hdc, hemf, &rect) ;
   
     DeleteEnhMetaFile (hemf) ;
}
Esempio n. 4
0
bool EmfPaintEngine::end()
{
	HENHMETAFILE  metafile = CloseEnhMetaFile( metaDC );
	DeleteEnhMetaFile( metafile );
	DeleteDC( metaDC );
 	return true;
}
Esempio n. 5
0
void __RPC_USER HENHMETAFILE_UserFree(unsigned long *pFlags, HENHMETAFILE *phEmf)
{
    TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *phEmf);

    if (LOWORD(*pFlags) != MSHCTX_INPROC)
        DeleteEnhMetaFile(*phEmf);
}
VOID SaveMetafile(HWND hWnd)
{ 
	HENHMETAFILE currentImage = RefreshMetafileDC(hWnd);
	
	TCHAR buffer[4 * MAX_LOADSTRING];
	OPENFILENAME openFileName = InitializeOpenFileNameStructure(hWnd, OFN_SHOWHELP | OFN_OVERWRITEPROMPT, buffer);

	TCHAR szDescription[MAX_LOADSTRING];
	LoadString(hInst, IDS_DESCRIPTIONSTRING, 
     (LPWSTR)szDescription, sizeof(szDescription)); 

	for (int i = 0; szDescription[i]!='\0'; i++) 
	{
		if (szDescription[i] == '%') 
				szDescription[i] = '\0'; 
	}
 
	GetSaveFileName(&openFileName); 
	GetClientRect(hWnd, &rect);
	HDC windowDC = GetDC(hWnd);
	RECT newRect = GetRect(windowDC);
	HDC newMetafileDC = CreateEnhMetaFile(windowDC, (LPTSTR) openFileName.lpstrFile, &newRect, (LPWSTR)szDescription);
	ReleaseDC(hWnd, windowDC);
	PlayEnhMetaFile(newMetafileDC, currentImage, &rect);
	currentImage = CloseEnhMetaFile(newMetafileDC);
	PlayEnhMetaFile(metafileDC, currentImage, &rect);
	ReleaseDC(hWnd, newMetafileDC);
	DeleteEnhMetaFile(currentImage);
}
Esempio n. 7
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     HDC          hdc ;
     HENHMETAFILE hemf ;
     PAINTSTRUCT  ps ;
     RECT         rect ;
     
     switch (message)
     {
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;
          
          GetClientRect (hwnd, &rect) ;
          
          rect.left   =     rect.right  / 4 ;
          rect.right  = 3 * rect.right  / 4 ;
          rect.top    =     rect.bottom / 4 ;
          rect.bottom = 3 * rect.bottom / 4 ;
          
          hemf = GetEnhMetaFile (TEXT ("..\\emf3\\emf3.emf")) ;
          
          EnumEnhMetaFile (hdc, hemf, EnhMetaFileProc, NULL, &rect) ;
          DeleteEnhMetaFile (hemf) ;
          EndPaint (hwnd, &ps) ;
          return 0 ;
          
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
Esempio n. 8
0
void OpenEnhMetaFile(HWND hWnd)
{
	OPENFILENAME LFile;
	WCHAR FileName[MAX_PATH], FilePath[MAX_PATH];
	FileName[0] = '\0';
 	FilePath[0] = '\0';
	LFile.lStructSize = sizeof(OPENFILENAME);
	LFile.hwndOwner = hWnd;
	LFile.lpstrFilter =L"EMF (*.emf)\0";
	LFile.lpstrCustomFilter = 0;
	LFile.lpstrFile = FilePath;
	LFile.nMaxFile = MAX_PATH * sizeof(WCHAR);
	LFile.lpstrFileTitle = FileName;
	LFile.nMaxFileTitle = MAX_PATH * sizeof(WCHAR);
	LFile.lpstrInitialDir = 0;
	LFile.lpstrDefExt = L"emf\0";
	LFile.lpstrTitle = L"Open file from:";
	LFile.Flags = OFN_PATHMUSTEXIST;
	GetOpenFileName(&LFile);
	HENHMETAFILE enhFile = GetEnhMetaFile(LFile.lpstrFile);
	RECT client;
	GetClientRect(hWnd, &client);
	client.left += scrhor / 3;
	client.top += scrvert / 3;
	client.right += scrhor / 3;
	client.bottom += scrvert / 3;
	PlayEnhMetaFile(hdc1, enhFile, &client);
	PlayEnhMetaFile(hdc2, enhFile, &client);
	DeleteEnhMetaFile(enhFile);
	InvalidateRect(hWnd, NULL, false);
}
Esempio n. 9
0
HENHMETAFILE CxImageWMF::ConvertEmfFiletoEmf(CxFile *pFile, ENHMETAHEADER *pemfh)
{
	HENHMETAFILE	hMeta;
	long iLen = pFile->Size();

	BYTE* pBuff = (BYTE *)malloc(iLen);
	if (!pBuff)	return (FALSE);

	// Read the Enhanced Metafile
	long iLenRead = pFile->Read(pBuff, 1, iLen);
	if (iLenRead != iLen) {
		free(pBuff);
		return (FALSE);
	}

	// Make it a Memory Metafile
	hMeta = SetEnhMetaFileBits(iLen, pBuff);

	free(pBuff);	// finished with this one

	if (!hMeta)	return (FALSE);	// oops.

	// Get the Enhanced Metafile Header
	UINT uRet = GetEnhMetaFileHeader(hMeta,					// handle of enhanced metafile 
								sizeof(ENHMETAHEADER),	// size of buffer, in bytes 
								pemfh); 					// address of buffer to receive data  
  
	if (!uRet) {
		DeleteEnhMetaFile(hMeta);
		return (FALSE);
	}

	return (hMeta);
}
void VPictureData_MacPicture::_DisposeMetaFile()const
{
	if (fMetaFile)
	{
#if VERSIONWIN
		DeleteEnhMetaFile(fMetaFile);
#else
		QDPictRelease(fMetaFile);
#endif
		fMetaFile = NULL;
	}
	if (fTrans)
	{
#if VERSIONWIN
#if ENABLE_D2D
		VWinD2DGraphicContext::ReleaseBitmap(fTrans);
#endif
		delete fTrans;
#elif VERSIONMAC
		CFRelease(fTrans);
#endif
		fTrans = NULL;
	}
#if VERSIONWIN
	if (fGdiplusMetaFile)
		delete fGdiplusMetaFile;
	fGdiplusMetaFile = 0;
#endif
}
void EMFRecordEditorFrame::GetRecordListFromFile()
{
    HENHMETAFILE hMeta = ReadEnhMetaFile(m_file.GetFullPath(), GetHwnd());
    if (!hMeta)
        return;

    // get meta header
    if (GetEnhMetaFileHeader(hMeta, sizeof(g_hMetaHeader), &g_hMetaHeader) != 
        sizeof(ENHMETAHEADER))
        return;

    // init data touched by the callback
    FreeEMFStuff();
    g_pHandleTable = NULL;
    g_nHandles = 0;
    g_pMetaRecords = NULL;
    g_nRecords = 0;
    g_nRecordsMax = 0;
    m_pList->DeleteAllItems();

    // get the list of meta records
    EnumEnhMetaFile( NULL, 
                     hMeta, 
                     (ENHMFENUMPROC)EnumEnhMetafileProc, 
                     (LPVOID)m_pList, 
                     NULL );

    DeleteEnhMetaFile(hMeta);

    // update GUI
    m_pList->SetColumnWidth(0, wxLIST_AUTOSIZE);
    m_pList->SetColumnWidth(1, wxLIST_AUTOSIZE);

    SetStatusText(wxString::Format(wxT("%d records"), g_nRecords), 2);
}
Esempio n. 12
0
void rectdraw0(long *w, long *x, long *y, long lw)
{
  char tmppath[MAX_PATH], fname[MAX_PATH];
  struct plot_eng plotWin32;
  HDC hEmf;
  int bg_r,bg_g,bg_b;

  GetTempPath(sizeof(tmppath), tmppath);
  sprintf(fname, "%s\\gp-ploth-%lx.emf", tmppath, time(NULL)/(24*60*60)*1000+GetTickCount());

  hEmf = CreateEnhMetaFile(GetDC(NULL), fname, NULL, NULL);
  SetMapMode(hEmf, MM_TEXT);
  SelectObject(hEmf, GetStockObject(DEFAULT_GUI_FONT));
  color_to_rgb(gel(GP_DATA->colormap,1), &bg_r, &bg_g, &bg_b);
  SetBkColor(hEmf, RGB(bg_r,bg_g,bg_b));
  SetBkMode(hEmf, OPAQUE);

  plotWin32.sc=&SetForeground;
  plotWin32.pt=&DrawPoint;
  plotWin32.ln=&DrawLine;
  plotWin32.bx=&DrawRectangle;
  plotWin32.mp=&DrawPoints;
  plotWin32.ml=&DrawLines;
  plotWin32.st=&DrawString;
  plotWin32.pl=&pari_plot;
  plotWin32.data=(void*)hEmf;

  gen_rectdraw0(&plotWin32, w, x, y, lw, 1, 1);
  DeleteEnhMetaFile(CloseEnhMetaFile(hEmf));

  ShellExecute(NULL,NULL,fname,NULL,NULL,SW_SHOWDEFAULT);
}
int CMetafileDisplay::CreateFromFile(LPCTSTR fileName)
{
	if (enhMF != NULL)
	{
		DeleteEnhMetaFile(enhMF);
		enhMF = NULL;
	}

	int ret = 0;
	// Open the file, find out how big it is, allocate memory then read it in
	HANDLE hFile = CreateFile(fileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
	if (hFile != (HANDLE)-1)
	{
		LPVOID pBuf = NULL;
		DWORD dwFileHigh = 0;
		DWORD dwFile = GetFileSize(hFile, &dwFileHigh);
		if (dwFileHigh == 0 && (pBuf = LocalAlloc(0, dwFile)) != NULL)
		{
			DWORD dwRead;
			if (ReadFile(hFile, pBuf, dwFile, &dwRead, NULL) && dwRead == dwFile)
				ret = LoadBits((UINT) dwFile, pBuf);
			LocalFree(pBuf);
		}
		else
			ret = -1;
		CloseHandle(hFile);
	}
	else
	{
		ret = -1;
		ATLTRACE(_T("Metafile Load: %d\n"), GetLastError());
	}
	return ret;
}
CMetafileDisplay::~CMetafileDisplay()
{
	if (enhMF != NULL)
	{
		DeleteEnhMetaFile(enhMF);
		enhMF = NULL;
	}
}
Esempio n. 15
0
/**
 * Free the meta file clipboard data if we have one.
 */
void ClipboardData::FreeClipboardEnhmetafile()
{
  if (data)
  {
    DeleteEnhMetaFile((HENHMETAFILE)data);
    data = NULL;
  }
  FreeClipboardName();
}
Esempio n. 16
0
VOID RefreshWindow(HWND hWnd)
{
	HDC windowDC = GetDC(hWnd);
	HENHMETAFILE currentImage = RefreshMetafileDC(hWnd);

	PlayEnhMetaFile(memoryDC, currentImage, &rect);
	PlayEnhMetaFile(metafileDC, currentImage, &rect);
	DeleteEnhMetaFile(currentImage);
	ReleaseDC(hWnd, windowDC);
}
void VPictureData_EMF::_DisposeMetaFile()const
{
	#if VERSIONWIN
	if(fMetaFile)
	{
		DeleteEnhMetaFile(fMetaFile);
		fMetaFile=NULL;
	}
	#endif
}
Esempio n. 18
0
static Any
get_clipboard_data(DisplayObj d, Name type)
{ HGLOBAL mem;
  HENHMETAFILE hmf;
  Any rval = FAIL;

  OpenClipboard(CLIPBOARDWIN);
  if ( type != NAME_winMetafile && (mem = GetClipboardData(CF_UNICODETEXT)) )
  { wchar_t *data = GlobalLock(mem);
    wchar_t *copy, *q;

    q = copy = pceMalloc((wcslen(data)+1)*sizeof(wchar_t));

    for(; *data; data++)
    { if ( *data == '\r' && data[1] == '\n' )
      { data++;
	*q++ = '\n';
      } else
	*q++ = *data;
    }
    *q = EOS;
    rval = WCToString(copy, q-copy);
    pceFree(copy);
    GlobalUnlock(mem);
  } else if ( type != NAME_winMetafile && (mem = GetClipboardData(CF_TEXT)) )
  { char far *data = GlobalLock(mem);
    char *copy, *q;

    q = copy = pceMalloc(strlen(data));

    for(; *data; data++)
    { if ( *data == '\r' && data[1] == '\n' )
      { data++;
	*q++ = '\n';
      } else
	*q++ = *data;
    }
    *q = EOS;
    rval = CtoString(copy);
    pceFree(copy);
    GlobalUnlock(mem);
  } else if ( type != NAME_text && (hmf = GetClipboardData(CF_ENHMETAFILE)) )
  { HENHMETAFILE copy = CopyEnhMetaFile(hmf, NULL);
    if ( !copy )
    { errorPce(d, NAME_winMetafile, CtoName("CopyEnhMetaFile"), APIError());
      fail;
    }

    rval = CtoWinMetafile(copy);
    DeleteEnhMetaFile(hmf);
  }
  CloseClipboard();

  return rval;
}
Esempio n. 19
0
/* width and height are in mm */
metafile newmetafile(const char *name, double width, double height)
{
    metafile obj;
    HDC hDC;
    RECT wr;
    static double cppix=-1, ppix, cppiy, ppiy;

    /*
     * In theory, (cppix=ppix) and (cppiy=ppiy). However, we
     * use the ratio to adjust the 'reference dimension'
     * in case.... ("Importing graph in MsWord" thread)
     */
    if (cppix < 0) {
        cppix = 25.40 * devicewidth(NULL) / devicewidthmm(NULL);
        ppix  = 100 * devicepixelsx(NULL);
        cppiy = 25.40 * deviceheight(NULL) / deviceheightmm(NULL);
        ppiy = 100 * devicepixelsy(NULL);
    }
    /* This is all very peculiar. We would really like to create
       a metafile measured in some sensible units, but it seems
       we get it in units of 0.01mm *on the current screen* with
       horizontal and vertical resolution set for that screen.
       And of course Windows is famous for getting screen sizes wrong.
    */

    wr.left = 0;
    wr.top =  0 ;
    wr.right =  (ppix * width) / cppix ;
    wr.bottom = (ppiy * height) / cppiy ;

    /* Here the size is in 0.01mm units */
    hDC = CreateEnhMetaFile(NULL, strlen(name) ? name : NULL, &wr,
                            "GraphApp\0\0");
    if ( !hDC ) {
        R_ShowMessage(_("Unable to create metafile"));
        return NULL;
    }
    obj = new_object(MetafileObject, (HANDLE) hDC, get_metafile_base());
    if ( !obj ) {
        R_ShowMessage(_("Insufficient memory to create metafile"));
        DeleteEnhMetaFile(CloseEnhMetaFile(hDC));
        return NULL;
    }
    /* In looks like Windows rounds up the width and height, so we
       do too.  1 out is common, but 2 out has been seen.
       This is needed to get complete painting of the background.
    */
    obj->rect = rect(0, 0, 2+(ppix * width)/2540, 2+(ppiy * height)/2540);
    obj->depth = GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES);
    obj->die = private_delmetafile;
    obj->drawstate = copydrawstate();
    obj->drawstate->dest = obj;
    settext(obj, name ? name : "");
    return obj;
}
Esempio n. 20
0
static void private_delmetafile(metafile obj)
{
    HENHMETAFILE hm;

    if (!obj || (obj->kind != MetafileObject)) return;
    hm = (HENHMETAFILE) CloseEnhMetaFile((HDC) obj->handle);
    if (strlen(GA_gettext(obj))) { /* real file*/
        DeleteEnhMetaFile(hm);
        return;
    }
    if (OpenClipboard(NULL) && EmptyClipboard() && /* try to save to the*/
            SetClipboardData(CF_ENHMETAFILE, hm) &&     /*clipboard */
            CloseClipboard())
        return;
    else {
        R_ShowMessage(_("Unable to save metafile to the clipboard"));
        DeleteEnhMetaFile(hm);
        return;
    }
}
Esempio n. 21
0
	void Release() {
		nRefCount--;
		_ASSERTE(nRefCount >= 0);
		if (nRefCount <= 0) {
			DeleteComp();
			if (h) {
				DeleteEnhMetaFile(h); h = NULL;
			}
			FREE(this);
		}
	};
Esempio n. 22
0
File: cdwemf.c Progetto: LuaDist/cd
static void cdkillcanvas (cdCtxCanvas* ctxcanvas)
{
  HENHMETAFILE hmf;
  
  cdwKillCanvas(ctxcanvas);
  
  hmf = CloseEnhMetaFile(ctxcanvas->hDC);
  DeleteEnhMetaFile(hmf);
  
  memset(ctxcanvas, 0, sizeof(cdCtxCanvas));
  free(ctxcanvas);
}
Esempio n. 23
0
VOID OpenImage(HWND hWnd, LPCWSTR fileName)
{
	HDC windowDC = GetDC(hWnd);
	HENHMETAFILE hemf = GetEnhMetaFile(fileName);  
	GetClientRect(hWnd, &rect); 
	ClearWindow(memoryDC);
	RefreshMetafileDC(hWnd);
	PlayEnhMetaFile(memoryDC, hemf, &rect);
	PlayEnhMetaFile(metafileDC, hemf, &rect);
	ReleaseDC(hWnd, windowDC); 
	DeleteEnhMetaFile(hemf);
}
Esempio n. 24
0
void COXMetaFile::CloseFile()
{	
	if(m_hDCMeta)
		m_hEMF=CloseEnhMetaFile(m_hDCMeta);
	if(m_hEMF)
		DeleteEnhMetaFile(m_hEMF);
	m_hDCMeta = NULL;
	m_hEMF = NULL;
	m_rectBounds.SetRectEmpty();
	m_rectNormalized.SetRectEmpty();
	m_metafileType=OXMETAFILE_NOTDEFINED;
}
int CMetafileDisplay::LoadBits(UINT uiBuf, LPVOID pBuf)
{
#pragma pack(2)
typedef struct 
{
	DWORD   key;
	WORD	hmf;
	short	left;
	short	top;
	short	right;
	short	bottom;
	WORD    inch;
	DWORD	reserved;
	WORD    checksum;
} AMETAHEADER;
#pragma pack()

	if (enhMF != NULL)
	{
		DeleteEnhMetaFile(enhMF);
		enhMF = NULL;
	}

	// See if this is an enhanced metafile
	ENHMETAHEADER *emhdr = (ENHMETAHEADER *)pBuf;
	if (uiBuf >= sizeof(ENHMETAHEADER)
	 && emhdr->iType == EMR_HEADER
	 && emhdr->dSignature == ENHMETA_SIGNATURE)
	{
		enhMF = SetEnhMetaFileBits(uiBuf, (CONST BYTE *)pBuf);
	}
	else if (uiBuf >= sizeof(METAHEADER))
	{
		METAFILEPICT mp = {MM_ANISOTROPIC, 1000, 1000, NULL};
		AMETAHEADER *ahdr = (AMETAHEADER *)pBuf;
		METAHEADER *mhdr = (METAHEADER *)pBuf;
		// See if this is a placeable metafile
		if (ahdr->key == 0x9AC6CDD7)
		{
			mp.xExt = ((LONG)(ahdr->right - ahdr->left) * 25401) / (LONG)ahdr->inch;
			mp.yExt = ((LONG)(ahdr->bottom - ahdr->top) * 25401) / (LONG)ahdr->inch;
			mhdr = (METAHEADER *) (ahdr + 1);
		}
		UINT uiSizeMF = (UINT) mhdr->mtSize * 2;
		HDC dcRef = ::GetDC(NULL);
		enhMF = SetWinMetaFileBits(uiSizeMF, (LPBYTE)mhdr, dcRef, &mp);
		::ReleaseDC(NULL, dcRef);
	}

	return (enhMF == NULL) ? -1 : 0;
}
Esempio n. 26
0
/*
 * clipboard_free_data - クリップボード形式毎のメモリの解放
 */
BOOL clipboard_free_data(TCHAR *format_name, HANDLE data)
{
	BOOL ret = FALSE;
	BYTE *mem;

	if (data == NULL) {
		return TRUE;
	}

	switch (clipboard_get_format(0, format_name)) {
	case CF_PALETTE:
		// パレット
		ret = DeleteObject((HGDIOBJ)data);
		break;

	case CF_DSPBITMAP:
	case CF_BITMAP:
		// ビットマップ
		ret = DeleteObject((HGDIOBJ)data);
		break;

	case CF_OWNERDISPLAY:
		break;

	case CF_DSPMETAFILEPICT:
	case CF_METAFILEPICT:
		// メタファイル
		if ((mem = GlobalLock(data)) != NULL) {
			DeleteMetaFile(((METAFILEPICT *)mem)->hMF);
			GlobalUnlock(data);
		}
		if (GlobalFree((HGLOBAL)data) == NULL) {
			ret = TRUE;
		}
		break;

	case CF_DSPENHMETAFILE:
	case CF_ENHMETAFILE:
		// 拡張メタファイル
		ret = DeleteEnhMetaFile((HENHMETAFILE)data);
		break;

	default:
		// その他
		if (GlobalFree((HGLOBAL)data) == NULL) {
			ret = TRUE;
		}
		break;
	}
	return ret;
}
int CMetafileDisplay::CreateFromClipboard( void)
{
	if (enhMF != NULL)
	{
		DeleteEnhMetaFile(enhMF);
		enhMF = NULL;
	}
	OpenClipboard();
	HENHMETAFILE enhMFNew = (HENHMETAFILE) GetClipboardData(CF_ENHMETAFILE);
	CloseClipboard();
	if (enhMFNew != NULL)
		enhMF = CopyEnhMetaFile(enhMFNew, NULL);
	return enhMF == NULL ? -1 : 0;
}
Esempio n. 28
0
INT_PTR CALLBACK WelcomeDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HENHMETAFILE hEmfWatermark;
    static HFONT hTitleFont;

    INT_PTR bReturn;
    if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
        return bReturn;

    switch (message) {
    case WM_INITDIALOG:
    {
        HRSRC hRsrcWatermark = FindResourceA(hInst, MAKEINTRESOURCEA(IDE_WATERMARK), "EMF");
        HGLOBAL hGlobWatermark = LoadResource(hInst, hRsrcWatermark);
        hEmfWatermark = SetEnhMetaFileBits(SizeofResource(hInst, hRsrcWatermark), (PBYTE)LockResource(hGlobWatermark));
    }
    SendDlgItemMessage(hdlg, IDC_WATERMARK, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hEmfWatermark);
    {
        NONCLIENTMETRICS ncm = { 0 };
        ncm.cbSize = sizeof(ncm);
        SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
        LOGFONT TitleLogFont = ncm.lfMessageFont;
        TitleLogFont.lfWeight = FW_BOLD;
        mir_tstrcpy(TitleLogFont.lfFaceName, TEXT("Verdana Bold"));

        HDC hdc = GetDC(NULL);
        INT FontSize = 12;
        TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * FontSize / 72;
        hTitleFont = CreateFontIndirect(&TitleLogFont);
        ReleaseDC(NULL, hdc);
    }
    SendDlgItemMessage(hdlg, IDC_TITLE, WM_SETFONT, (WPARAM)hTitleFont, 0);
    EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE);
    return FALSE;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDOK:
            PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc);
            break;
        }
        break;

    case WM_DESTROY:
        DeleteEnhMetaFile(hEmfWatermark);
        DeleteObject(hTitleFont);
        break;
    }
    return FALSE;
}
Esempio n. 29
0
BOOL CFemmplotDoc::OnSaveDocument(LPCTSTR lpszPathName) 
{
	// TODO: Add your specialized code here and/or call the base class
	BOOL flag=TRUE;

	HENHMETAFILE hMetaCopy=CopyEnhMetaFile(hMetaPlot,lpszPathName);
	if (hMetaCopy==NULL){
		MsgBox("Problem writing file to disk");
		flag=FALSE;
	}
	DeleteEnhMetaFile(hMetaCopy);

	return flag; // CDocument::OnSaveDocument(lpszPathName);
}
Esempio n. 30
0
BOOL CFemmplotDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	
	// clear out any old metafile;
	DeleteEnhMetaFile(hMetaPlot);
	HasBoundingBox=FALSE;
	HENHMETAFILE hMetaPlotFile = GetEnhMetaFile(lpszPathName);
	if (hMetaPlotFile!=NULL){
		DWORD len =(DWORD) GetEnhMetaFileBits(hMetaPlotFile,NULL,NULL);
		unsigned char *buff=(unsigned char *) malloc(len);
		if(GetEnhMetaFileBits(hMetaPlotFile,len,buff)==0)
			MsgBox("MetaFile not copied");
		hMetaPlot=SetEnhMetaFileBits(len,buff);
	}
	else MsgBox("Problem opening specified file");

	DeleteEnhMetaFile(hMetaPlotFile);

	// TODO: Add your specialized creation code here
	
	return TRUE;
}