Click here to Skip to main content
16,007,163 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Getting BIOS Information Pin
FlyingDancer4-Sep-03 14:28
FlyingDancer4-Sep-03 14:28 
GeneralRe: Getting BIOS Information Pin
leppie5-Sep-03 6:59
leppie5-Sep-03 6:59 
QuestionHow to convert from .DOC to .PDF, please help me .......... Pin
Atif Bashir16-Aug-03 1:41
Atif Bashir16-Aug-03 1:41 
GeneralThreads with Form updates Pin
MoonWa13-Aug-03 23:44
MoonWa13-Aug-03 23:44 
GeneralRe: Threads with Form updates Pin
edx_fa22-Aug-03 1:12
edx_fa22-Aug-03 1:12 
GeneralDisplaying an image Pin
Tom Archer13-Aug-03 14:45
Tom Archer13-Aug-03 14:45 
GeneralRe: Displaying an image Pin
igor196025-Aug-03 7:47
igor196025-Aug-03 7:47 
GeneralRe: Displaying an image Pin
Tom Archer25-Aug-03 7:51
Tom Archer25-Aug-03 7:51 
Yep. There was that problem and a couple of others. Here's the corrected code for anyone reading this thread in the future:

<br />
void CBLOBDataDlg::DisplayImageFile(Byte pictureData __gc[])<br />
{<br />
#pragma push_macro("new")<br />
#undef new<br />
  // forward declare so we can use them in <br />
  // the __finally statement<br />
  System::IO::MemoryStream* dataStream = NULL;<br />
  Bitmap* image = NULL;<br />
  Graphics* graphics = NULL;<br />
  CClientDC dc(&m_wndPhoto);<br />
<br />
  try<br />
  {<br />
    CWaitCursor wc;<br />
<br />
	  if (NULL != pictureData)<br />
	  {<br />
		  // Wrap the pictureData in a Stream object<br />
		  // this avoids creating a temporary file<br />
		  dataStream = new System::IO::MemoryStream(pictureData);<br />
<br />
		  // Create Image<br />
		  image = new Bitmap(dataStream);<br />
		  graphics = Graphics::FromHdc(dc.GetSafeHdc());<br />
<br />
		  // Draw background<br />
		  RECT clientRect;<br />
		  m_wndPhoto.GetClientRect(&clientRect);<br />
<br />
		  graphics->FillRectangle(SystemBrushes::Control, <br />
			  clientRect.left, clientRect.top,<br />
			  clientRect.right - clientRect.left,<br />
			  clientRect.bottom - clientRect.top);<br />
<br />
		  // Draw image<br />
		  graphics->DrawImage(image, 0, 0, image->Width, image->Height);<br />
	  }<br />
	  else<br />
	  {<br />
		  // Create graphics object <br />
		  // from HDC<br />
		  graphics = Graphics::FromHdc(dc.GetSafeHdc());<br />
<br />
		  // Draw background<br />
		  RECT clientRect;<br />
		  m_wndPhoto.GetClientRect(&clientRect);<br />
<br />
		  graphics->FillRectangle(SystemBrushes::Control, <br />
			  clientRect.left, clientRect.top,<br />
			  clientRect.right - clientRect.left,<br />
			  clientRect.bottom - clientRect.top);<br />
	  }<br />
  }<br />
  catch(Exception* e)<br />
  {<br />
    MessageBox::Show(e->Message, S".NET Exception Thrown", MessageBoxButtons::OK, MessageBoxIcon::Error);<br />
  }<br />
  __finally<br />
  {<br />
	  // Clean up resources<br />
	  if (graphics) graphics->Dispose();<br />
	  if (image) image->Dispose();<br />
	  if (dataStream) dataStream->Dispose();<br />
  }<br />
#pragma pop_macro("new")<br />
}<br />



Cheers,
Tom Archer
Inside C#,
Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
Generalwchar array or String to unsigned char array Pin
Gomac10-Aug-03 8:31
Gomac10-Aug-03 8:31 
GeneralRe: wchar array or String to unsigned char array Pin
edx_fa22-Aug-03 1:01
edx_fa22-Aug-03 1:01 
GeneralRaw Image to Bitmap object Pin
bwells10-Aug-03 4:23
bwells10-Aug-03 4:23 
GeneralRe: Raw Image to Bitmap object Pin
Nick Parker10-Aug-03 4:53
protectorNick Parker10-Aug-03 4:53 
GeneralRe: Raw Image to Bitmap object Pin
bwells11-Aug-03 14:54
bwells11-Aug-03 14:54 
QuestionDebugging -- looking at managed memory? Pin
Jeremy Osner6-Aug-03 4:40
Jeremy Osner6-Aug-03 4:40 
GeneralProcess.StartTime Pin
kurnaziso6-Aug-03 1:52
kurnaziso6-Aug-03 1:52 
General:: Prototyping a Derived Class :: Pin
Anonymous3-Aug-03 18:21
Anonymous3-Aug-03 18:21 
GeneralRe: :: Prototyping a Derived Class :: Pin
leppie4-Aug-03 7:09
leppie4-Aug-03 7:09 
GeneralRe: :: Prototyping a Derived Class :: Pin
Anonymous4-Aug-03 7:33
Anonymous4-Aug-03 7:33 
GeneralRe: :: Prototyping a Derived Class :: Pin
Anonymous4-Aug-03 7:48
Anonymous4-Aug-03 7:48 
GeneralRe: :: Prototyping a Derived Class :: Pin
Jörgen Sigvardsson20-Aug-03 11:39
Jörgen Sigvardsson20-Aug-03 11:39 
Generalwin98 applications with C++.NET Pin
nikoladsp2-Aug-03 19:15
nikoladsp2-Aug-03 19:15 
GeneralRe: win98 applications with C++.NET Pin
J. Dunlap2-Aug-03 19:19
J. Dunlap2-Aug-03 19:19 
GeneralProblems with splitters in Windows Forms Pin
RafMar1-Aug-03 4:44
RafMar1-Aug-03 4:44 
GeneralSkinning library for WinForms Pin
Slaru31-Jul-03 18:00
Slaru31-Jul-03 18:00 
GeneralRe: Skinning library for WinForms Pin
J. Dunlap31-Jul-03 20:53
J. Dunlap31-Jul-03 20:53 

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.