اقوم بالعمل على مشروع احتاج فيه ان اعرض صور نوع PNG على الفورم مباشرةً أو في اداة Image بحيث تكون هذه الصور مخزونة في ملف DLL علماً اني قمت بتحميل ملف WAVE و BMP و JPG و GIF حيث قمت بالاجراءات التالية:
*** لانشاء ملف (مكتبة) DLL تحتوي على ملف صوت WAVE
** قم بانشاء مجلد جديد
* انشاء ملف txt. داخل المجلد
اكتب بداخله السطر التالي
WAVE1 WAVE FileName1.wav
WAVE1 : رمز تعريفي نستخدمه داخل البرنامج يعرفنا باستخدام ملف الصوت FileName1.wav
WAVE : يخبرنا بان الملف المضمن في المكتبة من نوع WAVE
FileName1.wav : اسم الملف الصوتي ( يجب وضعه داخل المجلد ) مع ملف txt.
نحفظ الملف ونغلقه ثم نقوم بتغيير امتداد الملف من txt. إلى rc.
* نقوم بانشاء ملف جديد txt. داخل المجلد
نكتب بداخله السطر التالي
brcc32 .rc@ نحفظ الملف ونغلقه ثم نقوم بتغيير امتداد الملف من txt. إلى bat.
ثم نقم بتشغيل الملف bat. ، سنلاحظ انه قام بانشاء ملف جديد res. في نفس المجلد
* نفتح مشروع دلفي جديد من قائمة File --> New --> Other ثم نختار DLL Wizard ثم OK
library Project2;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes;
{$R *.res}
begin
end.
ثم نقوم بتغيير {R *.res$} إلى {R Filename.res$}
ثم نحفظ المشروع project2 ثم من قائمة Project --> Compile Project2
نلاحظ بان ملف project2.dll قد انشئ داخل المجلد
نعمل مشروع دلفي جديد نضع على الفورم زر امر واحد
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,MMSystem, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
H : THandle;
begin
H := LoadLibrary(Project2.DLL');
PlaySound('WAVE1', H, SND_SYNC or SND_RESOURCE)
end;
end.
نفذ المشروع ستسمع الصوت .
السؤال كيف اقوم باستخدام مكتبة DLL تحتوي على صورة ذات الامتداد PNG وعرض الصورة على الفورم . وشكراً...........
المثال السابق في المرفقات