I've create a DLL for an Image Preview in Windows 7 and it works fine but for the reading of files it uses a serialization because it is implemented with the interface IInitializeWithStream.
I've tried to change the mode with the interface IInitializeWithFile that permits me more control in the manipolation routines but doesn't works.
The problem is that i don't know how i could do, i've copied the initialization for the stream:

virtual HRESULT InitializeDocumentPreview(HWND hWndParent, RECT* prc){
m_pPreviewCtrl = CreatePreviewControl();
CMFCPreviewCtrlImpl* pCtrl = DYNAMIC_DOWNCAST(CMFCPreviewCtrlImpl, (CObject*)m_pPreviewCtrl);
if (pCtrl == NULL){
ATLTRACE2(atlTraceGeneral, 4, L"InitializeDocumentPreview: pointer to preview control is NULL.\n");
return E_POINTER;
}
ASSERT_VALID(pCtrl);
CCreateContext ctx;
ctx.m_pNewViewClass = RUNTIME_CLASS(CPreviewSCNView);
m_pDocument = CreateDocument();
if (m_pDocument == NULL) {
ATLTRACE2(atlTraceGeneral, 4, L"InitializeDocumentPreview: pointer to document is NULL.\n");
return E_POINTER;
}
m_pDocument->AddRef();
ctx.m_pCurrentDoc = DYNAMIC_DOWNCAST(CPreviewSCNDoc, (CObject*) m_pDocument->GetContainer());
if (!pCtrl->Create(hWndParent, prc, &ctx)){
ATLTRACE2(atlTraceGeneral, 4, L"InitializeDocumentPreview: preview control creation failed. Error Code: %d\n", GetLastError());
return E_FAIL;
}
return S_OK;
}

i've tried to implement the mode with filename:

STDMETHOD(Initialize)(LPCWSTR pszFilePath, DWORD grfMode){
......
[same code until ctx.m_pCurrentDoc = ...]
......
HWND hWndParent;
HRESULT res;
res=GetWindow(&hWndParent);
RECT prc;
hWndParent=(HWND)m_pDocument->GetContainer();
GetWindowRect(m_hWndHost,&prc);
if (!pCtrl->Create(hWndParent, &prc,&ctx)){
ATLTRACE2(atlTraceGeneral, 4, L"InitializeDocumentPreview: preview control creation failed. Error Code: %d\n", GetLastError());
return E_FAIL;
}
return S_OK;
}
but i don't have the hWndParent, and prc -> the pCtrl->Create fail.
if i create the pCtrl with
pCtrl->Create(hWndParent, &prc)
he works but i haven't the document and view

any help?
thanks