Main.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <stdlib.h> // for : malloc & free
  5. #include "Main.h"
  6. /****************************************************************************}
  7. {* For conditions of distribution and use, *}
  8. {* see copyright notice in libmng.pas *}
  9. {****************************************************************************}
  10. {* *}
  11. {* project : libmng *}
  12. {* file : main.pas copyright (c) 2000 G.Juyn *}
  13. {* version : 1.0.1 *}
  14. {* *}
  15. {* purpose : Main form for mngview application *}
  16. {* *}
  17. {* author : G.Juyn *}
  18. {* web : http://www.3-t.com *}
  19. {* email : mailto:[email protected] *}
  20. {* *}
  21. {* comment : this is the heart of the mngview applciation *}
  22. {* *}
  23. {* changes : This project is a converted version of "mngview" - AP *}
  24. {* - AP - 15/9/2000 - revisions ... *}
  25. {* - made the callbacks calling convention explicit *}
  26. (* - Moved the defines from "project options" to "main.h" *}
  27. {* - Added Readme.txt to the project - Please READ IT ! *}
  28. (* *}
  29. {* 0.5.1 - 05/02/2000 - G.Juyn *}
  30. {* - added this version block *}
  31. {* - made the initialization part more robust *}
  32. {* eg. program aborts on initialization errors *}
  33. {* - B002(105797) - added check for existence of default sRGB *}
  34. {* profile (now included in distribution) *}
  35. {* - added mng_cleanup to program exit *}
  36. {* 0.5.1 - 05/08/2000 - G.Juyn *}
  37. {* - changed to stdcall convention *}
  38. {* 0.5.1 - 05/11/2000 - G.Juyn *}
  39. {* - changed callback function declarations *}
  40. {* *}
  41. {* 0.5.3 - 06/16/2000 - G.Juyn *}
  42. {* - removed processmessages call from refresh callback *}
  43. {* 0.5.3 - 06/17/2000 - G.Juyn *}
  44. {* - switched "storechunks" off *}
  45. {* 0.5.3 - 06/26/2000 - G.Juyn *}
  46. {* - changed definition of userdata to mng_ptr *}
  47. {* 0.5.3 - 06/28/2000 - G.Juyn *}
  48. {* - changed the default icon to something more appropriate *}
  49. {* - changed definition of memory alloc size to mng_size_t *}
  50. {* 0.5.3 - 06/29/2000 - G.Juyn *}
  51. {* - changed order of refresh parameters *}
  52. {* *}
  53. {* 0.9.0 - 06/30/2000 - G.Juyn *}
  54. {* - changed refresh parameters to 'x,y,width,height' *}
  55. {* *}
  56. {* 0.9.1 - 07/08/2000 - G.Juyn *}
  57. {* - fixed to use returncode constants *}
  58. {* - changed to accomodate MNG_NEEDTIMERWAIT returncode *}
  59. {* 0.9.1 - 07/10/2000 - G.Juyn *}
  60. {* - changed to use suspension-mode *}
  61. {* *}
  62. {* 1.0.1 - 05/02/2000 - G.Juyn *}
  63. {* - removed loading of default sRGB profile (auto in libmng) *}
  64. {* *}
  65. {****************************************************************************/
  66. //---------------------------------------------------------------------------
  67. #pragma package(smart_init)
  68. #pragma resource "*.dfm"
  69. TMainForm *MainForm;
  70. # define _OR_ |
  71. # define _AND_ &
  72. # define _DIV_ /
  73. # define _NOT_ !
  74. # define _NIL_ 0
  75. # define _SHR_ >>
  76. # define _SHL_ <<
  77. // Prototypes for static functions - the LibMng Callbacks.
  78. static mng_ptr __stdcall Memalloc( mng_uint32 iLen );
  79. static void __stdcall Memfree( mng_ptr iPtr, mng_size_t iLen );
  80. static mng_bool __stdcall Openstream( mng_handle hHandle );
  81. static mng_bool __stdcall Closestream( mng_handle hHandle );
  82. static mng_bool __stdcall Readdata ( mng_handle hHandle, mng_ptr pBuf,
  83. mng_uint32 iBuflen, mng_uint32 *pRead );
  84. static mng_bool __stdcall ProcessHeader ( mng_handle hHandle,
  85. mng_uint32 iWidth, mng_uint32 iHeight );
  86. static mng_ptr __stdcall GetCanvasLine ( mng_handle hHandle,
  87. mng_uint32 iLinenr );
  88. static mng_ptr __stdcall GetAlphaLine( mng_handle hHandle, mng_uint32 iLinenr );
  89. static mng_bool __stdcall ImageRefresh ( mng_handle hHandle,
  90. mng_uint32 iX, mng_uint32 iY, mng_uint32 iWidth, mng_uint32 iHeight );
  91. static mng_uint32 __stdcall GetTickCount( mng_handle hHandle );
  92. static mng_bool __stdcall SetTimer( mng_handle hHandle, mng_uint32 iMsecs );
  93. //---------------------------------------------------------------------------
  94. __fastcall TMainForm::TMainForm(TComponent* Owner)
  95. : TForm(Owner)
  96. {
  97. }
  98. //---------------------------------------------------------------------------
  99. static mng_ptr __stdcall Memalloc( mng_uint32 iLen )
  100. {
  101. mng_ptr pResult =
  102. malloc( iLen ); /* get memory from the heap */
  103. if( pResult ) /* Added - condition */
  104. memset( pResult, 0, iLen );
  105. return pResult;
  106. }
  107. //---------------------------------------------------------------------------
  108. static void __stdcall Memfree( mng_ptr iPtr, mng_size_t iLen )
  109. {
  110. free( iPtr ); /* free the memory */
  111. (void)iLen; // Kill compiler warning
  112. }
  113. //---------------------------------------------------------------------------
  114. static mng_bool __stdcall Openstream( mng_handle hHandle )
  115. {
  116. TMainForm *OHForm;
  117. /* get a fix on our form */
  118. OHForm = (TMainForm *)mng_get_userdata( hHandle );
  119. if( OHForm->OFFile != _NIL_ ) /* free previous stream (if any) */
  120. OHForm->OFFile->Free();
  121. /* open a new stream */
  122. OHForm->OFFile = new TFileStream(
  123. OHForm->SFFileName, fmOpenRead _OR_ fmShareDenyWrite);
  124. OHForm->ProgressBar1->Position = 0; /* Added */
  125. OHForm->ProgressBar1->Min =0; /* Added */
  126. OHForm->ProgressBar1->Max = OHForm->OFFile->Size; /* Added */
  127. return MNG_TRUE;
  128. }
  129. //---------------------------------------------------------------------------
  130. static mng_bool __stdcall Closestream( mng_handle hHandle )
  131. {
  132. TMainForm *OHForm;
  133. /* get a fix on our form */
  134. OHForm = (TMainForm *)mng_get_userdata( hHandle );
  135. OHForm->OFFile->Free(); /* cleanup the stream */
  136. OHForm->OFFile = 0; /* don't use it again ! */
  137. OHForm->ProgressBar1->Position = 0; /* Added */
  138. return MNG_TRUE;
  139. }
  140. //---------------------------------------------------------------------------
  141. static mng_bool __stdcall Readdata ( mng_handle hHandle, mng_ptr pBuf,
  142. mng_uint32 iBuflen, mng_uint32 *pRead )
  143. {
  144. TMainForm *OHForm;
  145. unsigned int IHTicks;
  146. unsigned int IHByte1;
  147. unsigned int IHByte2;
  148. unsigned int IHBytesPerSec ;
  149. /* get a fix on our form */
  150. OHForm = (TMainForm *)mng_get_userdata( hHandle );
  151. /* are we at EOF ? */
  152. if( OHForm->OFFile->Position >= OHForm->OFFile->Size )
  153. {
  154. *pRead = 0; /* indicate so */
  155. }
  156. else
  157. {
  158. IHBytesPerSec = OHForm->IFBytesPerSec; /* fake a slow connection */
  159. if( IHBytesPerSec > 0 )
  160. {
  161. IHTicks = (unsigned int)GetTickCount();
  162. IHByte1 = (IHTicks - OHForm->IFTicks) * IHBytesPerSec;
  163. IHByte2 = (OHForm->IFBytes + iBuflen) * 1000;
  164. if( IHByte2 > IHByte1 ) /* Added - condition */
  165. if( ((IHByte2 - IHByte1) _DIV_ IHBytesPerSec) > 10 )
  166. {
  167. Sleep( (DWORD)((IHByte2 - IHByte1) _DIV_ IHBytesPerSec) );
  168. }
  169. };
  170. /* read the requested data */
  171. *pRead = OHForm->OFFile->Read( pBuf, iBuflen);
  172. OHForm->IFBytes = OHForm->IFBytes + *pRead;
  173. OHForm->ProgressBar1->Position = (int)OHForm->IFBytes; /* Added */
  174. } // end else;
  175. return MNG_TRUE;
  176. }
  177. //---------------------------------------------------------------------------
  178. static mng_bool __stdcall ProcessHeader ( mng_handle hHandle,
  179. mng_uint32 iWidth, mng_uint32 iHeight )
  180. {
  181. TMainForm *OHForm;
  182. /* get a fix on our form */
  183. OHForm = (TMainForm *)mng_get_userdata( hHandle );
  184. /* Added */
  185. OHForm->Caption = ExtractFileName( OHForm->SFFileName ) +
  186. " [" +
  187. String( iWidth ) +
  188. "x" +
  189. String( iHeight ) +
  190. "]";
  191. OHForm->OFBitmap->Width = iWidth; /* store the new dimensions */
  192. OHForm->OFBitmap->Height = iHeight;
  193. OHForm->OFImage->Left = 0; /* adjust the visible component */
  194. OHForm->OFImage->Top = 0;
  195. OHForm->OFImage->Width = iWidth;
  196. OHForm->OFImage->Height = iHeight;
  197. OHForm->FormResize (OHForm); /* force re-centering the image*/
  198. /* clear the canvas & draw an outline */
  199. OHForm->OFBitmap->Canvas->Brush->Color = clGray;
  200. OHForm->OFBitmap->Canvas->Brush->Style = bsSolid;
  201. OHForm->OFBitmap->Canvas->FillRect( OHForm->OFBitmap->Canvas->ClipRect );
  202. OHForm->OFBitmap->Canvas->Brush->Color = clRed;
  203. OHForm->OFBitmap->Canvas->Brush->Style = bsSolid;
  204. OHForm->OFBitmap->Canvas->Pen->Color = clRed;
  205. OHForm->OFBitmap->Canvas->Pen->Style = psSolid;
  206. OHForm->OFBitmap->Canvas->FrameRect( OHForm->OFBitmap->Canvas->ClipRect);
  207. /* make sure it gets out there */
  208. OHForm->OFImage->Picture->Assign( OHForm->OFBitmap );
  209. /* tell the library we want funny windows-bgr*/
  210. if( mng_set_canvasstyle( hHandle, MNG_CANVAS_BGR8 ) )
  211. OHForm->MNGerror( "libmng reported an error setting the canvas style" );
  212. return MNG_TRUE;
  213. }
  214. //---------------------------------------------------------------------------
  215. static mng_ptr __stdcall GetCanvasLine ( mng_handle hHandle,
  216. mng_uint32 iLinenr )
  217. {
  218. TMainForm *OHForm;
  219. /* get a fix on our form */
  220. OHForm = (TMainForm *)mng_get_userdata( hHandle );
  221. /* easy with these bitmap objects ! */
  222. return OHForm->OFBitmap->ScanLine[ iLinenr ];
  223. }
  224. //---------------------------------------------------------------------------
  225. static mng_bool __stdcall ImageRefresh ( mng_handle hHandle,
  226. mng_uint32 iX, mng_uint32 iY, mng_uint32 iWidth, mng_uint32 iHeight )
  227. {
  228. TMainForm *OHForm;
  229. /* get a fix on our form */
  230. OHForm = (TMainForm *)mng_get_userdata( hHandle );
  231. /* force redraw */
  232. OHForm->OFImage->Picture->Assign( OHForm->OFBitmap );
  233. return MNG_TRUE;
  234. }
  235. //---------------------------------------------------------------------------
  236. static mng_uint32 __stdcall GetTickCount( mng_handle hHandle )
  237. {
  238. return GetTickCount(); /* windows knows that */
  239. }
  240. //---------------------------------------------------------------------------
  241. static mng_bool __stdcall SetTimer( mng_handle hHandle, mng_uint32 iMsecs )
  242. {
  243. TMainForm *OHForm;
  244. /* get a fix on our form */
  245. OHForm = (TMainForm *)mng_get_userdata( hHandle );
  246. OHForm->OFTimer->Interval = iMsecs; /* and set the timer */
  247. OHForm->OFTimer->Enabled = true;
  248. return MNG_TRUE;
  249. }
  250. //---------------------------------------------------------------------------
  251. //---------------------------------------------------------------------------
  252. void __fastcall TMainForm::FormCreate(TObject *Sender)
  253. {
  254. String SHProfileName;
  255. mng_uint16 IHRed, IHGreen, IHBlue; /* word */
  256. OFBitmap = new Graphics::TBitmap(); /* initialize */
  257. IFBytesPerSec = 10000000;
  258. OFFile = 0;
  259. OFOpenDialog->InitialDir = "";
  260. OFBitmap->HandleType = bmDIB; /* make it a 24-bit DIB */
  261. OFBitmap->PixelFormat = pf24bit;
  262. /* now initialize the library */
  263. IFHandle = mng_initialize( mng_ptr(this), Memalloc, Memfree, _NIL_ );
  264. if( IFHandle == _NIL_ )
  265. {
  266. MNGerror ("libmng initializiation error"\
  267. "\n"\
  268. "Program aborted"
  269. );
  270. PostMessage( Handle, WM_CLOSE, 0, 0);
  271. return; // was Exit
  272. };
  273. /* no need to store chunk-info ! */
  274. mng_set_storechunks( IFHandle, MNG_FALSE );
  275. /* use suspension-buffer */
  276. mng_set_suspensionmode( IFHandle, MNG_TRUE );
  277. /* set all the callbacks */
  278. if(
  279. (mng_setcb_openstream (IFHandle, Openstream ) != MNG_NOERROR) _OR_
  280. (mng_setcb_closestream (IFHandle, Closestream ) != MNG_NOERROR) _OR_
  281. (mng_setcb_readdata (IFHandle, Readdata ) != MNG_NOERROR) _OR_
  282. (mng_setcb_processheader(IFHandle, ProcessHeader) != MNG_NOERROR) _OR_
  283. (mng_setcb_getcanvasline(IFHandle, GetCanvasLine) != MNG_NOERROR) _OR_
  284. (mng_setcb_refresh (IFHandle, ImageRefresh ) != MNG_NOERROR) _OR_
  285. (mng_setcb_gettickcount (IFHandle, GetTickCount ) != MNG_NOERROR) _OR_
  286. (mng_setcb_settimer (IFHandle, SetTimer ) != MNG_NOERROR)
  287. )
  288. {
  289. MNGerror ("libmng reported an error setting a callback function!"\
  290. "\n"\
  291. "Program aborted"
  292. );
  293. PostMessage( Handle, WM_CLOSE, 0, 0 );
  294. return; // was Exit
  295. };
  296. /* supply our own bg-color */
  297. IHRed = (mng_uint16)((Color ) _AND_ 0xFF);
  298. IHGreen = (mng_uint16)((Color _SHR_ 8) _AND_ 0xFF);
  299. IHBlue = (mng_uint16)((Color _SHR_ 16) _AND_ 0xFF);
  300. IHRed = (mng_uint16)((IHRed _SHL_ 8) + IHRed);
  301. IHGreen = (mng_uint16)((IHGreen _SHL_ 8) + IHGreen);
  302. IHBlue = (mng_uint16)((IHBlue _SHL_ 8) + IHBlue);
  303. if( mng_set_bgcolor (IFHandle, IHRed, IHGreen, IHBlue) != MNG_NOERROR )
  304. MNGerror( "libmng reported an error setting the background color!");
  305. }
  306. //---------------------------------------------------------------------------
  307. void __fastcall TMainForm::FormCloseQuery(TObject *Sender,
  308. bool &CanClose)
  309. {
  310. BFCancelled = true;
  311. /* if we're still animating then stop it */
  312. if( OFTimer->Enabled )
  313. {
  314. if( mng_display_freeze (IFHandle) != MNG_NOERROR )
  315. MNGerror ("libmng reported an error during display_freeze!" );
  316. }
  317. OFTimer->Enabled = false;
  318. mng_cleanup( &IFHandle );
  319. }
  320. //---------------------------------------------------------------------------
  321. void __fastcall TMainForm::FormShow(TObject *Sender)
  322. {
  323. FormResize( this );
  324. }
  325. //---------------------------------------------------------------------------
  326. void __fastcall TMainForm::FormResize(TObject *Sender)
  327. {
  328. /* center the image in the window */
  329. if( ClientWidth < OFImage->Width )
  330. OFImage->Left = 0;
  331. else
  332. OFImage->Left = (ClientWidth - OFImage->Width ) _DIV_ 2;
  333. if( ClientHeight < OFImage->Height )
  334. OFImage->Top = 0;
  335. else
  336. OFImage->Top = (ClientHeight - OFImage->Height) _DIV_ 2;
  337. ProgressBar1->Width = Panel1->Width - 8; /* Added */
  338. }
  339. //---------------------------------------------------------------------------
  340. void __fastcall TMainForm::FormKeyDown(TObject *Sender, WORD &Key,
  341. TShiftState Shift)
  342. {
  343. /* pressing <esc> will freeze an animation */
  344. if( Key == VK_ESCAPE )
  345. {
  346. if( OFTimer->Enabled )
  347. {
  348. if( mng_display_freeze( IFHandle) != MNG_NOERROR )
  349. MNGerror( "libmng reported an error during display_freeze!" );
  350. }
  351. OFTimer->Enabled = false; /* don't let that timer go off then ! */
  352. BFCancelled = true;
  353. }
  354. }
  355. //---------------------------------------------------------------------------
  356. void __fastcall TMainForm::OFTimerTimer(TObject *Sender)
  357. {
  358. mng_retcode IHRslt;
  359. OFTimer->Enabled = false; /* only once ! */
  360. if( _NOT_ BFCancelled )
  361. {
  362. /* and inform the library */
  363. IHRslt = mng_display_resume( IFHandle );
  364. if( (IHRslt != MNG_NOERROR) _AND_ (IHRslt != MNG_NEEDTIMERWAIT) )
  365. MNGerror( "libmng reported an error during display_resume!" );
  366. };
  367. }
  368. //---------------------------------------------------------------------------
  369. void __fastcall TMainForm::OFMenuFileOpenClick(TObject *Sender)
  370. {
  371. mng_retcode IHRslt;
  372. OFOpenDialog->InitialDir = "";
  373. OFOpenDialog->InitialDir = GetCurrentDir(); //@@
  374. OFOpenDialog->FileName = SFFileName;
  375. if( OFOpenDialog->Execute() ) /* get the filename */
  376. {
  377. if( OFTimer->Enabled ) /* if the lib was active; stop it */
  378. {
  379. OFTimer->Enabled = false;
  380. Application->ProcessMessages(); /* process any timer requests (for safety) */
  381. /* now freeze the animation */
  382. if( mng_display_freeze( IFHandle ) != MNG_NOERROR )
  383. MNGerror( "libmng reported an error during display_freeze!" );
  384. };
  385. /* save interesting fields */
  386. SFFileName = OFOpenDialog->FileName;
  387. IFTicks = GetTickCount();
  388. IFBytes = 0;
  389. BFCancelled = false;
  390. /* always reset (just in case) */
  391. if( mng_reset( IFHandle ) != MNG_NOERROR )
  392. {
  393. MNGerror( "libmng reported an error during reset!" );
  394. }
  395. else
  396. {
  397. /* and let the lib do it's job ! */
  398. IHRslt = mng_readdisplay (IFHandle);
  399. if( (IHRslt != MNG_NOERROR) _AND_ (IHRslt != MNG_NEEDTIMERWAIT) )
  400. MNGerror( "libmng reported an error reading the input file!" );
  401. };
  402. };
  403. }
  404. //---------------------------------------------------------------------------
  405. void __fastcall TMainForm::OFMenuFileProfileClick(TObject *Sender)
  406. {
  407. char SHProfileDir[ MAX_PATH ];
  408. GetSystemDirectory( SHProfileDir, MAX_PATH );
  409. strcat( SHProfileDir, "\\Color" );
  410. OFOpenDialogProfile->InitialDir = String( SHProfileDir );
  411. if( OFOpenDialogProfile->Execute() )
  412. {
  413. if( mng_set_outputprofile( IFHandle, OFOpenDialogProfile->FileName.c_str()) != 0 )
  414. MNGerror( "libmng reported an error setting the output-profile!" );
  415. }
  416. }
  417. //---------------------------------------------------------------------------
  418. void __fastcall TMainForm::OFMenuFileExitClick(TObject *Sender)
  419. {
  420. if( mng_cleanup( &IFHandle ) != MNG_NOERROR )
  421. MNGerror( "libmng cleanup error" );
  422. Close();
  423. }
  424. //---------------------------------------------------------------------------
  425. void __fastcall TMainForm::OFMenuOptionsModemSpeedClick(TObject *Sender)
  426. {
  427. OFMenuOptionsModem28k8->Checked = false;
  428. OFMenuOptionsModem33k6->Checked = false;
  429. OFMenuOptionsModem56k->Checked = false;
  430. OFMenuOptionsModemISDN64->Checked = false;
  431. OFMenuOptionsModemISDN128->Checked = false;
  432. OFMenuOptionsModemCable512->Checked = false;
  433. OFMenuOptionsModemUnlimited->Checked = false;
  434. if( IFBytesPerSec == (unsigned int)OFMenuOptionsModem28k8->Tag _DIV_ 10 )
  435. OFMenuOptionsModem28k8->Checked = true;
  436. else
  437. if( IFBytesPerSec == (unsigned int)OFMenuOptionsModem33k6->Tag _DIV_ 10 )
  438. OFMenuOptionsModem33k6->Checked = true;
  439. else
  440. if( IFBytesPerSec == (unsigned int)OFMenuOptionsModem56k->Tag _DIV_ 10 )
  441. OFMenuOptionsModem56k->Checked = true;
  442. else
  443. if( IFBytesPerSec == (unsigned int)OFMenuOptionsModemISDN64->Tag _DIV_ 10 )
  444. OFMenuOptionsModemISDN64->Checked = true;
  445. else
  446. if( IFBytesPerSec == (unsigned int)OFMenuOptionsModemISDN128->Tag _DIV_ 10 )
  447. OFMenuOptionsModemISDN128->Checked = true;
  448. else
  449. /* Added - changedit was the line below ! */
  450. // if( IFBytesPerSec == (unsigned int)OFMenuOptionsModemUnlimited->Tag _DIV_ 10 )
  451. if( IFBytesPerSec == (unsigned int)OFMenuOptionsModemCable512->Tag _DIV_ 10 )
  452. OFMenuOptionsModemCable512->Checked = true;
  453. else
  454. OFMenuOptionsModemUnlimited->Checked = true;
  455. }
  456. //---------------------------------------------------------------------------
  457. void __fastcall TMainForm::OFMenuOptionsModemXClick(TObject *Sender)
  458. {
  459. IFBytesPerSec = ((TMenuItem*)Sender)->Tag _DIV_ 10;
  460. }
  461. //---------------------------------------------------------------------------
  462. void TMainForm::MNGerror( String SHMsg )
  463. {
  464. /* get extended info */
  465. mng_uint32 iErrorcode;
  466. mng_uint8 iSeverity;
  467. mng_chunkid iChunkname;
  468. mng_uint32 iChunkseq;
  469. mng_int32 iExtra1;
  470. mng_int32 iExtra2;
  471. mng_pchar zErrortext;
  472. char szFormatStr[ 256 ];
  473. iErrorcode = mng_getlasterror (IFHandle, &iSeverity,
  474. &iChunkname, &iChunkseq, &iExtra1, &iExtra2,
  475. (mng_pchar*)&zErrortext);
  476. wsprintf( szFormatStr,
  477. "Error = %d; Severity = %d; Chunknr = %d; Extra1 = %d",
  478. (int)iErrorcode, (int)iSeverity, (int)iChunkseq, (int)iExtra1
  479. );
  480. MessageDlg( SHMsg +
  481. "\n\n" +
  482. String(zErrortext) +
  483. "\n\n" +
  484. szFormatStr, /* see wsprintf above */
  485. mtError,
  486. TMsgDlgButtons() << mbOK,
  487. 0
  488. );
  489. }
  490. //---------------------------------------------------------------------------