Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2008 C# VC++
I want to convert following vc++ code to 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 16-Aug-12 19:06pm
Comments
Sergey Alexandrovich Kryukov at 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 at 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)

  Print Answers RSS
0 OriginalGriff 293
1 Sergey Alexandrovich Kryukov 281
2 RyanDev 65
3 nv3 60
4 Mehdi Gholam 45
0 Sergey Alexandrovich Kryukov 6,696
1 OriginalGriff 6,149
2 CPallini 2,473
3 Richard MacCutchan 1,697
4 Abhinav S 1,560


Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 17 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100