2
0

Main.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. unit Main;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5. Menus, StdCtrls, ExtCtrls, Buttons,
  6. libmng;
  7. {****************************************************************************}
  8. {* For conditions of distribution and use, *}
  9. {* see copyright notice in libmng.pas *}
  10. {****************************************************************************}
  11. {* *}
  12. {* project : libmng *}
  13. {* file : main.pas copyright (c) 2000-2002 G.Juyn *}
  14. {* version : 1.0.5 *}
  15. {* *}
  16. {* purpose : Main form for mngview application *}
  17. {* *}
  18. {* author : G.Juyn *}
  19. {* web : http://www.3-t.com *}
  20. {* email : mailto:[email protected] *}
  21. {* *}
  22. {* comment : this is the heart of the mngview applciation *}
  23. {* *}
  24. {* changes : 0.5.1 - 05/02/2000 - G.Juyn *}
  25. {* - added this version block *}
  26. {* - made the initialization part more robust *}
  27. {* eg. program aborts on initialization errors *}
  28. {* - B002(105797) - added check for existence of default sRGB *}
  29. {* profile (now included in distribution) *}
  30. {* - added mng_cleanup to program exit *}
  31. {* 0.5.1 - 05/08/2000 - G.Juyn *}
  32. {* - changed to stdcall convention *}
  33. {* 0.5.1 - 05/11/2000 - G.Juyn *}
  34. {* - changed callback function declarations *}
  35. {* *}
  36. {* 0.5.3 - 06/16/2000 - G.Juyn *}
  37. {* - removed processmessages call from refresh callback *}
  38. {* 0.5.3 - 06/17/2000 - G.Juyn *}
  39. {* - switched "storechunks" off *}
  40. {* 0.5.3 - 06/26/2000 - G.Juyn *}
  41. {* - changed definition of userdata to mng_ptr *}
  42. {* 0.5.3 - 06/28/2000 - G.Juyn *}
  43. {* - changed the default icon to something more appropriate *}
  44. {* - changed definition of memory alloc size to mng_size_t *}
  45. {* 0.5.3 - 06/29/2000 - G.Juyn *}
  46. {* - changed order of refresh parameters *}
  47. {* *}
  48. {* 0.9.0 - 06/30/2000 - G.Juyn *}
  49. {* - changed refresh parameters to 'x,y,width,height' *}
  50. {* *}
  51. {* 0.9.1 - 07/08/2000 - G.Juyn *}
  52. {* - fixed to use returncode constants *}
  53. {* - changed to accomodate MNG_NEEDTIMERWAIT returncode *}
  54. {* 0.9.1 - 07/10/2000 - G.Juyn *}
  55. {* - changed to use suspension-mode *}
  56. {* *}
  57. {* 0.9.3 - 09/11/2000 - G.Juyn *}
  58. {* - removed some tesst-stuff *}
  59. {* *}
  60. {* 1.0.1 - 05/02/2000 - G.Juyn *}
  61. {* - removed loading default sRGB profile (auto in libmng) *}
  62. {* *}
  63. {* 1.0.5 - 09/16/2002 - G.Juyn *}
  64. {* - added dynamic MNG features *}
  65. {* 1.0.5 - 11/27/2002 - G.Juyn *}
  66. {* - fixed freeze during read-cycle *}
  67. {* *}
  68. {****************************************************************************}
  69. type
  70. TMainForm = class(TForm)
  71. OFMainMenu: TMainMenu;
  72. OFMenuFile: TMenuItem;
  73. OFMenuFileOpen: TMenuItem;
  74. OFMenuFileProfile: TMenuItem;
  75. OFMenuFileN1: TMenuItem;
  76. OFMenuFileExit: TMenuItem;
  77. OFMenuOptions: TMenuItem;
  78. OFMenuOptionsModemSpeed: TMenuItem;
  79. OFMenuOptionsModem28k8: TMenuItem;
  80. OFMenuOptionsModem33k6: TMenuItem;
  81. OFMenuOptionsModem56k: TMenuItem;
  82. OFMenuOptionsModemISDN64: TMenuItem;
  83. OFMenuOptionsModemISDN128: TMenuItem;
  84. OFMenuOptionsModemCable512: TMenuItem;
  85. OFMenuOptionsModemUnlimited: TMenuItem;
  86. OFTimer: TTimer;
  87. OFOpenDialog: TOpenDialog;
  88. OFOpenDialogProfile: TOpenDialog;
  89. OFImage: TImage;
  90. procedure FormCreate(Sender: TObject);
  91. procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  92. procedure FormShow(Sender: TObject);
  93. procedure FormResize(Sender: TObject);
  94. procedure FormKeyDown(Sender: TObject; var Key: Word;
  95. Shift: TShiftState);
  96. procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  97. Y: Integer);
  98. procedure OFImageMouseMove(Sender: TObject; Shift: TShiftState; X,
  99. Y: Integer);
  100. procedure OFImageMouseDown(Sender: TObject; Button: TMouseButton;
  101. Shift: TShiftState; X, Y: Integer);
  102. procedure OFImageMouseUp(Sender: TObject; Button: TMouseButton;
  103. Shift: TShiftState; X, Y: Integer);
  104. procedure OFTimerTimer(Sender: TObject);
  105. procedure OFMenuFileOpenClick(Sender: TObject);
  106. procedure OFMenuFileProfileClick(Sender: TObject);
  107. procedure OFMenuFileExitClick(Sender: TObject);
  108. procedure OFMenuOptionsModemSpeedClick(Sender: TObject);
  109. procedure OFMenuOptionsModemXClick(Sender: TObject);
  110. private
  111. { Private declarations }
  112. SFFileName : string; { filename of the input stream }
  113. OFFile : TFileStream; { input stream }
  114. IFHandle : mng_handle; { the libray handle }
  115. OFBitmap : TBitmap; { drawing canvas }
  116. BFCancelled : boolean; { <esc> or app-exit }
  117. BFHasMouse : boolean; { mouse is/was over image }
  118. IFTicks : cardinal; { used to fake slow connections }
  119. IFBytes : cardinal;
  120. IFBytesPerSec : integer;
  121. procedure MNGerror (SHMsg : string);
  122. public
  123. { Public declarations }
  124. end;
  125. var
  126. MainForm: TMainForm;
  127. {****************************************************************************}
  128. implementation
  129. {$R *.DFM}
  130. {****************************************************************************}
  131. {$F+}
  132. function Memalloc (iLen : mng_uint32) : mng_ptr; stdcall;
  133. {$F-}
  134. begin
  135. getmem (Result, iLen); { get memory from the heap }
  136. fillchar (Result^, iLen, 0); { and initialize it }
  137. end;
  138. {****************************************************************************}
  139. {$F+}
  140. procedure Memfree (iPtr : mng_ptr;
  141. iLen : mng_size_t); stdcall;
  142. {$F-}
  143. begin
  144. freemem (iPtr, iLen); { free the memory }
  145. end;
  146. {****************************************************************************}
  147. {$F+}
  148. function Openstream (hHandle : mng_handle) : mng_bool; stdcall;
  149. {$F-}
  150. var OHForm : TMainForm;
  151. begin { get a fix on our form }
  152. OHForm := TMainForm (mng_get_userdata (hHandle));
  153. with OHFORM do
  154. begin
  155. if OFFile <> nil then { free previous stream (if any) }
  156. OFFile.Free;
  157. { open a new stream }
  158. OFFile := TFileStream.Create (SFFileName, fmOpenRead or fmShareDenyWrite);
  159. end;
  160. Result := MNG_TRUE;
  161. end;
  162. {****************************************************************************}
  163. {$F+}
  164. function Closestream (hHandle : mng_handle) : mng_bool; stdcall;
  165. {$F-}
  166. var OHForm : TMainForm;
  167. begin { get a fix on our form }
  168. OHForm := TMainForm (mng_get_userdata (hHandle));
  169. with OHFORM do
  170. begin
  171. OFFile.Free; { cleanup the stream }
  172. OFFile := nil; { don't use it again ! }
  173. end;
  174. Result := MNG_TRUE;
  175. end;
  176. {****************************************************************************}
  177. {$F+}
  178. function Readdata ( hHandle : mng_handle;
  179. pBuf : mng_ptr;
  180. iBuflen : mng_uint32;
  181. var pRead : mng_uint32) : mng_bool; stdcall;
  182. {$F-}
  183. var OHForm : TMainForm;
  184. IHTicks : cardinal;
  185. IHByte1 : cardinal;
  186. IHByte2 : cardinal;
  187. IHBytesPerSec : cardinal;
  188. begin
  189. { get a fix on our form }
  190. OHForm := TMainForm (mng_get_userdata (hHandle));
  191. with OHForm do
  192. begin { are we at EOF ? }
  193. if OFFile.Position >= OFFile.Size then
  194. begin
  195. pRead := 0; { indicate so }
  196. end
  197. else
  198. begin
  199. IHBytesPerSec := IFBytesPerSec; { fake a slow connection }
  200. if IHBytesPerSec > 0 then
  201. begin
  202. IHTicks := Windows.GetTickCount;
  203. IHByte1 := round (((IHTicks - IFTicks) / 1000) * IHBytesPerSec);
  204. IHByte2 := (IFBytes + iBuflen);
  205. if ((IHByte2 - IHByte1) div IHBytesPerSec) > 10 then
  206. Windows.Sleep ((IHByte2 - IHByte1) div IHBytesPerSec);
  207. end;
  208. { read the requested data }
  209. pRead := OFFile.Read (pBuf^, iBuflen);
  210. IFBytes := IFBytes + pRead;
  211. end;
  212. end;
  213. Result := MNG_TRUE;
  214. end;
  215. {****************************************************************************}
  216. {$F+}
  217. function ProcessHeader (hHandle : mng_handle;
  218. iWidth : mng_uint32;
  219. iHeight : mng_uint32) : mng_bool; stdcall;
  220. {$F-}
  221. var OHForm : TMainForm;
  222. begin { get a fix on our form }
  223. OHForm := TMainForm (mng_get_userdata (hHandle));
  224. with OHForm do
  225. begin
  226. OFBitmap.Width := iWidth; { store the new dimensions }
  227. OFBitmap.Height := iHeight;
  228. OFImage.Left := 0; { adjust the visible component }
  229. OFImage.Top := 0;
  230. OFImage.Width := iWidth;
  231. OFImage.Height := iHeight;
  232. FormResize (OHForm); { force re-centering the image}
  233. { clear the canvas & draw an outline }
  234. OFBitmap.Canvas.Brush.Color := clGray;
  235. OFBitmap.Canvas.Brush.Style := bsSolid;
  236. OFBitmap.Canvas.FillRect (OFBitmap.Canvas.ClipRect);
  237. OFBitmap.Canvas.Brush.Color := clRed;
  238. OFBitmap.Canvas.Brush.Style := bsSolid;
  239. OFBitmap.Canvas.Pen.Color := clRed;
  240. OFBitmap.Canvas.Pen.Style := psSolid;
  241. OFBitmap.Canvas.FrameRect (OFBitmap.Canvas.ClipRect);
  242. OFImage.Picture.Assign (OFBitmap); { make sure it gets out there }
  243. { tell the library we want funny windows-bgr}
  244. if mng_set_canvasstyle (hHandle, MNG_CANVAS_BGRX8) <> 0 then
  245. MNGerror ('libmng reported an error setting the canvas style');
  246. end;
  247. Result := MNG_TRUE;
  248. end;
  249. {****************************************************************************}
  250. {$F+}
  251. function GetCanvasLine (hHandle : mng_handle;
  252. iLinenr : mng_uint32) : mng_ptr; stdcall;
  253. {$F-}
  254. var OHForm : TMainForm;
  255. begin { get a fix on our form }
  256. OHForm := TMainForm (mng_get_userdata (hHandle));
  257. { easy with these bitmap objects ! }
  258. Result := OHForm.OFBitmap.ScanLine [iLinenr];
  259. end;
  260. {****************************************************************************}
  261. {$F+}
  262. function ImageRefresh (hHandle : mng_handle;
  263. iX : mng_uint32;
  264. iY : mng_uint32;
  265. iWidth : mng_uint32;
  266. iHeight : mng_uint32) : mng_bool; stdcall;
  267. {$F-}
  268. var OHForm : TMainForm;
  269. begin { get a fix on our form }
  270. OHForm := TMainForm (mng_get_userdata (hHandle));
  271. { force redraw }
  272. OHForm.OFImage.Picture.Assign (OHForm.OFBitmap);
  273. Result := MNG_TRUE;
  274. end;
  275. {****************************************************************************}
  276. {$F+}
  277. function GetTickCount (hHandle : mng_handle) : mng_uint32; stdcall;
  278. {$F-}
  279. begin
  280. Result := Windows.GetTickCount; { windows knows that }
  281. end;
  282. {****************************************************************************}
  283. {$F+}
  284. function SetTimer (hHandle : mng_handle;
  285. iMsecs : mng_uint32) : mng_bool; stdcall;
  286. {$F-}
  287. var OHForm : TMainForm;
  288. begin { get a fix on our form }
  289. OHForm := TMainForm (mng_get_userdata (hHandle));
  290. OHForm.OFTimer.Interval := iMsecs; { and set the timer }
  291. OHForm.OFTimer.Enabled := true;
  292. Result := MNG_TRUE;
  293. end;
  294. {****************************************************************************}
  295. procedure TMainForm.FormCreate(Sender: TObject);
  296. var IHRed, IHGreen, IHBlue : word;
  297. begin { initialize }
  298. OFBitmap := TBitmap.Create;
  299. IFBytesPerSec := 10000000;
  300. BFHasMouse := false;
  301. OFFile := nil;
  302. OFOpenDialog.Initialdir := '';
  303. OFBitmap.HandleType := bmDIB; { make it a 24-bit DIB }
  304. OFBitmap.PixelFormat := pf32bit;
  305. { now initialize the library }
  306. IFHandle := mng_initialize (mng_ptr(self), Memalloc, Memfree, nil);
  307. if IFHandle = NIL then
  308. begin
  309. MNGerror ('libmng initialization error' + #13#10 +
  310. 'Program aborted');
  311. Windows.Postmessage (handle, WM_Close, 0, 0);
  312. Exit;
  313. end;
  314. { no need to store chunk-info ! }
  315. mng_set_storechunks (IFHandle, MNG_FALSE);
  316. { do not use suspension-buffer }
  317. mng_set_suspensionmode (IFHandle, MNG_FALSE);
  318. { set all the callbacks }
  319. if (mng_setcb_openstream (IFHandle, Openstream ) <> MNG_NOERROR) or
  320. (mng_setcb_closestream (IFHandle, Closestream ) <> MNG_NOERROR) or
  321. (mng_setcb_readdata (IFHandle, Readdata ) <> MNG_NOERROR) or
  322. (mng_setcb_processheader (IFHandle, ProcessHeader) <> MNG_NOERROR) or
  323. (mng_setcb_getcanvasline (IFHandle, GetCanvasLine) <> MNG_NOERROR) or
  324. (mng_setcb_refresh (IFHandle, ImageRefresh ) <> MNG_NOERROR) or
  325. (mng_setcb_gettickcount (IFHandle, GetTickCount ) <> MNG_NOERROR) or
  326. (mng_setcb_settimer (IFHandle, SetTimer ) <> MNG_NOERROR) then
  327. begin
  328. MNGerror ('libmng reported an error setting a callback function!' + #13#10 +
  329. 'Program aborted');
  330. Windows.Postmessage (handle, WM_Close, 0, 0);
  331. Exit;
  332. end;
  333. IHRed := (Color ) and $FF; { supply our own bg-color }
  334. IHGreen := (Color shr 8) and $FF;
  335. IHBlue := (Color shr 16) and $FF;
  336. IHRed := (IHRed shl 8) + IHRed;
  337. IHGreen := (IHGreen shl 8) + IHGreen;
  338. IHBlue := (IHBlue shl 8) + IHBlue;
  339. if mng_set_bgcolor (IFHandle, IHRed, IHGreen, IHBlue) <> MNG_NOERROR then
  340. MNGerror ('libmng reported an error setting the background color!');
  341. end;
  342. {****************************************************************************}
  343. procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  344. begin
  345. OFTimer.Enabled := false;
  346. BFCancelled := true;
  347. { if we're still animating then stop it }
  348. if mng_status_running (IFHandle) and not mng_status_reading (IFHandle) then
  349. if mng_display_freeze (IFHandle) <> MNG_NOERROR then
  350. MNGerror ('libmng reported an error during display_freeze!');
  351. mng_cleanup (IFHandle);
  352. end;
  353. {****************************************************************************}
  354. procedure TMainForm.FormShow(Sender: TObject);
  355. begin
  356. FormResize (self);
  357. end;
  358. {****************************************************************************}
  359. procedure TMainForm.FormResize(Sender: TObject);
  360. begin { center the image in the window }
  361. if ClientWidth < OFImage.Width then
  362. OFImage.Left := 0
  363. else
  364. OFImage.Left := (ClientWidth - OFImage.Width ) div 2;
  365. if ClientHeight < OFImage.Height then
  366. OFImage.Top := 0
  367. else
  368. OFImage.Top := (ClientHeight - OFImage.Height) div 2;
  369. end;
  370. {****************************************************************************}
  371. procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
  372. Shift: TShiftState);
  373. begin
  374. if Key = vk_Escape then { pressing <esc> will freeze an animation }
  375. begin
  376. OFTimer.Enabled := false; { don't let that timer go off then ! }
  377. BFCancelled := true;
  378. if mng_status_running (IFHandle) and not mng_status_reading (IFHandle) then
  379. if mng_display_freeze (IFHandle) <> MNG_NOERROR then
  380. MNGerror ('libmng reported an error during display_freeze!');
  381. end;
  382. end;
  383. {****************************************************************************}
  384. procedure TMainForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  385. Y: Integer);
  386. begin
  387. if mng_status_dynamic (IFHandle) then
  388. begin
  389. if BFHasMouse then { if we had the mouse, it's left ! }
  390. begin
  391. if mng_trapevent (IFHandle, 3, 0, 0) <> MNG_NOERROR then
  392. MNGerror ('libmng reported an error during trapevent!');
  393. BFHasMouse := false;
  394. end;
  395. end;
  396. end;
  397. {****************************************************************************}
  398. procedure TMainForm.OFImageMouseMove(Sender: TObject; Shift: TShiftState;
  399. X, Y: Integer);
  400. begin
  401. if mng_status_dynamic (IFHandle) then
  402. begin
  403. if BFHasMouse then { did we have the mouse already ? }
  404. begin
  405. if mng_trapevent (IFHandle, 2, X, Y) <> MNG_NOERROR then
  406. MNGerror ('libmng reported an error during trapevent!');
  407. end
  408. else
  409. begin { if not, it has entered ! }
  410. if mng_trapevent (IFHandle, 1, X, Y) <> MNG_NOERROR then
  411. MNGerror ('libmng reported an error during trapevent!');
  412. BFHasMouse := true;
  413. end;
  414. end;
  415. end;
  416. {****************************************************************************}
  417. procedure TMainForm.OFImageMouseDown(Sender: TObject; Button: TMouseButton;
  418. Shift: TShiftState; X, Y: Integer);
  419. begin
  420. if mng_status_dynamic (IFHandle) then
  421. if mng_trapevent (IFHandle, 4, X, Y) <> MNG_NOERROR then
  422. MNGerror ('libmng reported an error during trapevent!');
  423. end;
  424. {****************************************************************************}
  425. procedure TMainForm.OFImageMouseUp(Sender: TObject; Button: TMouseButton;
  426. Shift: TShiftState; X, Y: Integer);
  427. begin
  428. if mng_status_dynamic (IFHandle) then
  429. if mng_trapevent (IFHandle, 5, X, Y) <> MNG_NOERROR then
  430. MNGerror ('libmng reported an error during trapevent!');
  431. end;
  432. {****************************************************************************}
  433. procedure TMainForm.OFTimerTimer(Sender: TObject);
  434. var IHRslt : mng_retcode;
  435. begin
  436. OFTimer.Enabled := false; { only once ! }
  437. if not BFCancelled then
  438. begin { and inform the library }
  439. IHRslt := mng_display_resume (IFHandle);
  440. if (IHRslt <> MNG_NOERROR) and (IHRslt <> MNG_NEEDTIMERWAIT) then
  441. MNGerror ('libmng reported an error during display_resume!');
  442. end;
  443. end;
  444. {****************************************************************************}
  445. procedure TMainForm.OFMenuFileOpenClick(Sender: TObject);
  446. var IHRslt : mng_retcode;
  447. begin
  448. OFOpenDialog.InitialDir := '';
  449. OFOpenDialog.FileName := SFFileName;
  450. if OFOpenDialog.Execute then { get the filename }
  451. begin
  452. if OFTimer.Enabled then { if the lib was active; stop it }
  453. begin
  454. OFTimer.Enabled := false;
  455. Application.ProcessMessages; { process any timer requests (for safety) }
  456. { now freeze the animation }
  457. if mng_display_freeze (IFHandle) <> MNG_NOERROR then
  458. MNGerror ('libmng reported an error during display_freeze!');
  459. end;
  460. { save interesting fields }
  461. SFFileName := OFOpenDialog.FileName;
  462. IFTicks := Windows.GetTickCount;
  463. IFBytes := 0;
  464. BFCancelled := false;
  465. { always reset (just in case) }
  466. if mng_reset (IFHandle) <> MNG_NOERROR then
  467. MNGerror ('libmng reported an error during reset!')
  468. else
  469. begin { and let the lib do it's job ! }
  470. IHRslt := mng_readdisplay (IFHandle);
  471. if (IHRslt <> MNG_NOERROR) and (IHRSLT <> MNG_NEEDTIMERWAIT) then
  472. MNGerror ('libmng reported an error reading the input file!');
  473. end;
  474. end;
  475. end;
  476. {****************************************************************************}
  477. procedure TMainForm.OFMenuFileProfileClick(Sender: TObject);
  478. var SHProfileDir : array [0 .. MAX_PATH + 20] of char;
  479. begin
  480. GetSystemDirectory (@SHProfileDir, MAX_PATH);
  481. strcat (@SHProfileDir, '\Color');
  482. OFOpenDialogProfile.InitialDir := strpas (@SHProfileDir);
  483. if OFOpenDialogProfile.Execute then
  484. if mng_set_outputprofile (IFHandle, pchar (OFOpenDialogProfile.FileName)) <> 0 then
  485. MNGerror ('libmng reported an error setting the output-profile!');
  486. end;
  487. {****************************************************************************}
  488. procedure TMainForm.OFMenuFileExitClick(Sender: TObject);
  489. begin
  490. if mng_cleanup (IFHandle) <> MNG_NOERROR then
  491. MNGerror ('libmng cleanup error');
  492. Close;
  493. end;
  494. {****************************************************************************}
  495. procedure TMainForm.OFMenuOptionsModemSpeedClick(Sender: TObject);
  496. begin
  497. OFMenuOptionsModem28k8.Checked := false;
  498. OFMenuOptionsModem33k6.Checked := false;
  499. OFMenuOptionsModem56k.Checked := false;
  500. OFMenuOptionsModemISDN64.Checked := false;
  501. OFMenuOptionsModemISDN128.Checked := false;
  502. OFMenuOptionsModemCable512.Checked := false;
  503. OFMenuOptionsModemUnlimited.Checked := false;
  504. if IFBytesPerSec = OFMenuOptionsModem28k8.Tag div 10 then
  505. OFMenuOptionsModem28k8.Checked := true
  506. else
  507. if IFBytesPerSec = OFMenuOptionsModem33k6.Tag div 10 then
  508. OFMenuOptionsModem33k6.Checked := true
  509. else
  510. if IFBytesPerSec = OFMenuOptionsModem56k.Tag div 10 then
  511. OFMenuOptionsModem56k.Checked := true
  512. else
  513. if IFBytesPerSec = OFMenuOptionsModemISDN64.Tag div 10 then
  514. OFMenuOptionsModemISDN64.Checked := true
  515. else
  516. if IFBytesPerSec = OFMenuOptionsModemISDN128.Tag div 10 then
  517. OFMenuOptionsModemISDN128.Checked := true
  518. else
  519. if IFBytesPerSec = OFMenuOptionsModemUnlimited.Tag div 10 then
  520. OFMenuOptionsModemCable512.Checked := true
  521. else
  522. OFMenuOptionsModemUnlimited.Checked := true;
  523. end;
  524. {****************************************************************************}
  525. procedure TMainForm.OFMenuOptionsModemXClick(Sender: TObject);
  526. begin
  527. IFBytesPerSec := TMenuItem (Sender).Tag div 10;
  528. end;
  529. {****************************************************************************}
  530. procedure TMainForm.MNGerror;
  531. var iErrorcode : mng_uint32;
  532. iSeverity : mng_uint8;
  533. iChunkname : mng_chunkid;
  534. iChunkseq : mng_uint32;
  535. iExtra1 : mng_int32;
  536. iExtra2 : mng_int32;
  537. zErrortext : mng_pchar;
  538. begin { get extended info }
  539. iErrorcode := mng_getlasterror (IFHandle, iSeverity, iChunkname, iChunkseq,
  540. iExtra1, iExtra2, zErrortext);
  541. MessageDlg (SHMsg + #13#10#13#10 + strpas (zErrortext) + #13#10#13#10 +
  542. Format ('Error = %d; Severity = %d; Chunknr = %d; Extra1 = %d',
  543. [iErrorcode, iSeverity, iChunkseq, iExtra1]),
  544. mtError, [mbOK], 0);
  545. end;
  546. {****************************************************************************}
  547. end.