Paint' : cannot convert parameter 1 from 'struct HDC__ *' to 'long'  
Author Message
Jakein2006





PostPosted: Visual C++ General, Paint' : cannot convert parameter 1 from 'struct HDC__ *' to 'long' Top

Paint function in microsoft visio viewer 2003 is like this:

[id(0x60020035), hidden, helpstring("hidden method Paint")]
HRESULT Paint(
[in] long HDC,
[in] long X,
[in] long Y,
[in] long Width,
[in] long Height,
[in] long SrcX,
[in] long SrcY);

but when I use the following codes to call funcitons:

IViewerPtr m_Viewer( _T("VisioViewer.Viewer") );

CString strFunction("D:\\Program Files\\Microsoft Office\\Visio Viewer\\1033\\SAMP_VDX.VDX");
BSTR b = strFunction.AllocSysString();
_bstr_t b1 = b;
m_Viewer->Load(b1);
SysFreeString(b);

m_Viewer->Paint(pDC->m_hDC ,10,10,200,200,20,20);

there is the following error, please tell me how to solve the error:
Paint' : cannot convert parameter 1 from 'struct HDC__ *' to 'long'

I appreciate your help.




Visual C++12  
 
 
Alex Farber





PostPosted: Visual C++ General, Paint' : cannot convert parameter 1 from 'struct HDC__ *' to 'long' Top

Try to make casting:

m_Viewer->Paint((long)pDC->m_hDC ,10,10,200,200,20,20);


 
 
Harold Jimenez





PostPosted: Visual C++ General, Paint' : cannot convert parameter 1 from 'struct HDC__ *' to 'long' Top

I guess pDC is of type CDC* (or one of its descendants) and not your own type, if so use pDC->GetSafeHdc() instead, to acquire a handle in a safer manner.