Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
I want to convert following vc++ code to c#
C++
typedef Drm::TXValuePtr<Drm::utilities::ClBitmapDisplay> display_type;
display_type m_Display;
BOOL CZF::OnInitDialog()
{
CWnd *pWnd(GetDlgItem(IDC_IMAGE));
	ASSERT(pWnd);
	display_type pDisplay(new ClBitmapDisplay(pWnd));
	// //nofail operations
	m_Display.Swap(pDisplay);
}
calling of Display method is
void CZF::DisplayBMP()
{
 m_Display->Display(*m_pSrcBmpFolder);
}

void abc::RefreshLive(const BYTE* pImg)
{
	try
	{
		HWND wnd=::GetDlgItem(m_hWnd, IDC_IMAGE);
		DRM_EXP_THROW_0(((NULL != wnd) && ::IsWindow(wnd)),Drm::CXSystemSpecificException);
		if(NULL != wnd && ::IsWindow(wnd))
		{
			m_Display->Display(wnd, (BITMAPINFOHEADER*)(pImg));
		}
	}
	catch(const exception& sex)
	{
		stringstream ss;
		/*ss<<"RefreshLive exception: "<<sex.what()<<endl;
		::OutputDebugString(ss.str().c_str());*/
	}
}

void ClBitmapDisplay::Display ( HWND hWnd, BITMAPINFOHEADER	*pBI)
{
	RECT stRect;
	//
	if ( !GetClientRect ( hWnd, &stRect ) )
	{
		throw Drm::CXSystemSpecificException ( );
	}
	//
	HDC hDC = GetDC ( hWnd );
	SetStretchBltMode ( hDC, COLORONCOLOR );
	//
	int nErr =  StretchDIBits ( hDC
				  , stRect.left
				  , stRect.top
				  , stRect.right  - stRect.left
				  , stRect.bottom - stRect.top 
				  ,	0
				  , 0
				  , static_cast < int > ( pBI->biWidth  )
				  , static_cast < int > ( pBI->biHeight )
				  ,	Drm::utilities::ClSimpleBitmap::Pixel ( pBI )
				  , reinterpret_cast < BITMAPINFO* > ( pBI )
				  , DIB_RGB_COLORS
				  , SRCCOPY
				  );
	//
	ReleaseDC ( hWnd, hDC );
	if ( GDI_ERROR == nErr )
	{
		throw Drm::CXSystemSpecificException ( );
	}
}
Posted
Comments
Sergey Alexandrovich Kryukov 17-Aug-12 1:15am    
Why do you think someone will translate everything for you? Do you have a particular problem? Or what kind of help do you need? Are you using C++/CLI or P/Invoke, or what?
--SA
Member 7909353 17-Aug-12 2:36am    
Thanks!
I will try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900