🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms
Article #13892

copying metafile to clipboard

#13892
From: Marco Papa
Date: Mon, 08 Jan 1990 03:34
58 lines
2017 bytes
I've been trying to copying metafiles to "disk files" with no problem,
while I had no success with copying a metafile to the Clipboard.  The
clipboard recognizes that it received a Picture, but nothing is shown.
The following is the sample code I use, mainly taken verbatim from
Charles Petzold book "Programming Windows". When SaveClip is false,
the etafile is correctly saved on a disk file.  When SaveClip is
true an "empty" picture shows up in the clipboard. Any ideas?


void SetBarMetafile(HWND hWnd)
{
	HDC hMetaDC;
	HANDLE hMF;
    	HANDLE hDiskMF;
    	GLOBALHANDLE hGMem;
	LPMETAFILEPICT lpMFP;

	if (SaveClip) {
		hMetaDC = CreateMetaFile(NULL);
	} else {
		hMetaDC = CreateMetaFile(szMetaFileName);
	}
	SetWindowExt(hMetaDC, 1024, 780);

	<<< do the GDI graphics using hMetaDC >>>

    	hMF = CloseMetaFile(hMetaDC);
	/* copy memory metafile to disk metafile or Clipboard */
	if (hMF) {
		if (SaveClip) {
			hGMem = GlobalAlloc(GHND,(DWORD)sizeof(METAFILEPICT));
			lpMFP = (LPMETAFILEPICT) GlobalLock(hGMem);

			lpMFP->mm = MM_ANISOTROPIC;
			lpMFP->xExt = 0;
			lpMFP->yExt = 0;

			lpMFP->hMF = hMF;
			GlobalUnlock(hGMem);

			OpenClipboard(hWnd);
			EmptyClipboard();
			SetClipboardData(CF_METAFILEPICT, hGMem);
			CloseClipboard();
		} 
		DeleteMetaFile(hMF);
	} else
		MessageBox(hWnd, "Error creating Picture", szAppName,
			MB_OK | MB_ICONHAND);
    }
}

What am I doing wrong?

-- Marco
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Xerox sues somebody for copying?" -- David Letterman
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID: <22139@usc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!samsung!usc!pollux.usc.edu!papa

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!samsung!usc!pollux.usc.edu!papa
From: papa@pollux.usc.edu (Marco Papa)
Newsgroups: comp.windows.ms
Subject: copying metafile to clipboard
Message-ID: <22139@usc.edu>
Date: 8 Jan 90 03:34:21 GMT
Sender: news@usc.edu
Organization: Felsina Software, Los Angeles, CA
Lines: 58