Click here to Skip to main content
15,900,477 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: AfxGetModuleState not returning DLL's ModuleState Pin
HENDRIK R18-May-04 1:56
HENDRIK R18-May-04 1:56 
GeneralRe: AfxGetModuleState not returning DLL's ModuleState Pin
ohadp18-May-04 2:04
ohadp18-May-04 2:04 
GeneralRe: AfxGetModuleState not returning DLL's ModuleState Pin
HENDRIK R18-May-04 2:10
HENDRIK R18-May-04 2:10 
GeneralRe: AfxGetModuleState not returning DLL's ModuleState Pin
David Crow18-May-04 2:34
David Crow18-May-04 2:34 
GeneralGeneral C++ tempaltes related Pin
rajandpayal17-May-04 19:42
rajandpayal17-May-04 19:42 
GeneralRe: General C++ tempaltes related Pin
Ryan Roberts17-May-04 20:00
Ryan Roberts17-May-04 20:00 
GeneralRe: General C++ tempaltes related Pin
Paul Ranson18-May-04 5:23
Paul Ranson18-May-04 5:23 
GeneralCOM Container for office file Pin
vishalmore17-May-04 19:24
vishalmore17-May-04 19:24 
Hi, All...

I am writing a COM container using MFC OLE classes. The purpose of the
container is to display and/or print MS Word doc as portion of a bigger
display/plot. For this I am trying to get the Enhance Metafile representation of the word doc file using MSWord as COM Server. I have had limited success in the sense that only first page of the document is visible in the metafile.

Here is what I have tried:

CMyContainerDoc* pDoc = new CMyContainerDoc; //derived from
COleDocument
CMyCtrlItem* pCtrlItem = new CMyCtrlItem(pDoc); //derived from
COleClientItem
pCtrlItem->CreateFromFile("mytestfile.doc"); //path and name of a MS
word file
CSize clientSize;
BOOL bRet = pCtrlItem->GetCachedExtent(&clientSize, DVASPECT CONTENT);
HDC hDC = ::CreateEnhMetaFile(NULL, "c:\\drawtest.emf", 0, NULL);
CDC::FromHandle(hDC)->HIMETRICtoLP(&clientSize);
CRect rect( 0, 0, clientSize.cx, clientSize.cy);
pCtrlItem->Draw(CDC::FromHandle(hDC), &rect, DVASPECT CONTENT);
HENHMETAFILE hMetaFile = CloseEnhMetaFile( hDC );
DeleteEnhMetaFile( hMetaFile);

This results in just the first page of document to be represented in the
metafile.
How could I get the whole document in the metafile?

2. Alternatively, I tried to use GetData function of IDataObject
interface .
It returns success status code, but when I try to use the metafile
handle, returned through STGMEDIUM structure, it still contains only the first page.

Here is the relevant code:

FORMATETC fmtetc;
fmtetc.cfFormat = CF METAFILEPICT;
fmtetc.dwAspect = DVASPECT CONTENT;
fmtetc.ptd = NULL;
fmtetc.tymed = TYMED MFPICT;
fmtetc.lindex = -1;
STGMEDIUM stgMed;
memset(&stgMed, 0, sizeof(stgMed));
LPDATAOBJECT lpDataObject = 0;
pCtrlItem->m lpObject->QueryInterface(IID IDataObject,
(void**)&lpDataObject);
sc = lpDataObject->GetData( &fmtetc, &stgMed );
LPMETAFILEPICT pMF = (LPMETAFILEPICT)GlobalLock(stgMed.hEnhMetaFile);
//Draw the picture.
HDC hDC2 = ::CreateEnhMetaFile(NULL, "c:\\testGetdata.emf", 0, NULL);
BOOL bRetPlay = PlayMetaFile(hDC2, pMF->hMF);
GlobalUnlock(stgMed.hEnhMetaFile);
ReleaseStgMedium(&stgMed);
HENHMETAFILE hMetaFile = CloseEnhMetaFile( hDC2 );
DeleteEnhMetaFile( hMetaFile );

Here again, the metafile testGetData.emf contains just the first page of
the document.

Is there something I am missing here? Or if there is another better way
of achieving the intended results.

any suggestion appriciated !

Thanks in Advance

Vishal
GeneralDrawing text to the Desktop wnd Pin
TigerNinja_17-May-04 17:54
TigerNinja_17-May-04 17:54 
GeneralRe: Drawing text to the Desktop wnd Pin
alex.barylski17-May-04 18:58
alex.barylski17-May-04 18:58 
GeneralRe: Drawing text to the Desktop wnd Pin
TigerNinja_18-May-04 15:45
TigerNinja_18-May-04 15:45 
GeneralRe: Drawing text to the Desktop wnd Pin
alex.barylski18-May-04 17:15
alex.barylski18-May-04 17:15 
GeneralRe: Drawing text to the Desktop wnd Pin
parths17-May-04 20:18
parths17-May-04 20:18 
GeneralRe: Drawing text to the Desktop wnd Pin
Ravi Bhavnani18-May-04 1:46
professionalRavi Bhavnani18-May-04 1:46 
QuestionBinary file reading? Pin
Indrawati17-May-04 17:26
Indrawati17-May-04 17:26 
AnswerRe: Binary file reading? Pin
valikac17-May-04 18:27
valikac17-May-04 18:27 
GeneralRe: Binary file reading? Pin
Indrawati17-May-04 20:05
Indrawati17-May-04 20:05 
GeneralRe: Binary file reading? Pin
valikac17-May-04 20:24
valikac17-May-04 20:24 
GeneralHELP!! - Miniport Dev Guide Pin
vnm617-May-04 17:21
vnm617-May-04 17:21 
GeneralRe: HELP!! - Miniport Dev Guide Pin
Prakash Nadar17-May-04 22:07
Prakash Nadar17-May-04 22:07 
GeneralRe: HELP!! - Miniport Dev Guide Pin
Mike Dimmick18-May-04 1:32
Mike Dimmick18-May-04 1:32 
GeneralRe: HELP!! - Miniport Dev Guide Pin
vnm618-May-04 23:05
vnm618-May-04 23:05 
GeneralTxt file editing Pin
contemptx17-May-04 17:18
contemptx17-May-04 17:18 
GeneralRe: Txt file editing Pin
Christian Graus17-May-04 17:26
protectorChristian Graus17-May-04 17:26 
GeneralUnplug or Eject Hardware APIs Pin
IceBerG7117-May-04 17:09
IceBerG7117-May-04 17:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.