PDA

View Full Version : مشکل با کلاس(class)در Dll



mskm100
دوشنبه 17 دی 1386, 22:28 عصر
با سلام
من در حال نوشتن یک dll هستم و تازه کارم رو با Dll شروع کردم ، وقتی از کلاس استفاده نمی کنم مشکلی ندارم ولی وقتی از کلاس استفاده می کنم error می ده کد Dll و پیغام های error رو هم میذارم


library fcustmsgdlg;
{ 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
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
ExtCtrls,
XPMan,
JPEG;
type
Tcustomm=class
font:String;
custbidimode:TBiDiMode;
custalphabelnd:Boolean;
custalphabelendvalue:Byte;
function Custommsgdlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): Integer;
end;
var
custmsgdlg: TForm;
cust:Tcustomm;

{$R *.res}

{ Tcustomm }
function Tcustomm.Custommsgdlg(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons): Integer;
begin
end;
exports Custommsgdlg;
begin
end.


پیغامهای error
[[Warning] fcustmsgdlg.dpr(50): Return value of function 'Tcustomm.Custommsgdlg' might be undefined
[Error] fcustmsgdlg.dpr(51): Undeclared identifier: 'Custommsgdlg']

در ضمن اگر ممکنه منو راهنمایی کنید که چطور می تونم برای توابعم در Dll خواص یا متد تعریف کنم.مثلا با زدن نقطه بعد از تابع لیست خواص مربوط به اون تابع ظاهر بشه.در ضمن خطای dll در هنگام کامپایل خود برنامه مربوط به dll اتفاق میفته .

vcldeveloper
سه شنبه 18 دی 1386, 03:05 صبح
از داخل DLL نمی تونید متدهای یک کلاس را Export کنید. در مثال شما حتی اگر امکان Export متدها هم وجود داشت، کار انجام نمی شد، چون نمونه ایی از کلاس مربوطه ساخته نشده بود که بشه ازش استفاده کرد.


چطور می تونم برای توابعم در Dll خواص یا متد تعریف کنم.برای تابع خواص یا متد تعیین نمی کنند، اصلا متد خودش نوعی تابع متعلق به یک کلاس هست. برای کلاس ها خصوصیت و متد تعریف می کنند.
می تونید به تاپیک زیر مراجعه کنید:
کلاس در dll (http://barnamenevis.org/forum/showthread.php?t=84511)