mirror of
http://gitlab.expertsoft.com.ua/git/expertcad
synced 2026-01-11 22:45:39 +02:00
108 lines
2.6 KiB
ObjectPascal
108 lines
2.6 KiB
ObjectPascal
library AdjustBitmap;
|
|
|
|
{ A Power Plugin DLL should simply have 3 Procedures.
|
|
1 - Init
|
|
GetVerbs will have a parameter of pointer.The application will call this
|
|
init procedure by passing its instance to it. This is a standart procedure
|
|
and should be implemeted same in all plugins.
|
|
|
|
2 - GetVerbs
|
|
GetVerbs will return a pchar including the name of the Verbs called from the
|
|
application. Note that these verb names will be taken by the application to
|
|
the menu, and each menu click will call the third exported procedure (DoVerb)
|
|
with the verb index which is in fact the index of the verb in the string list.
|
|
|
|
3 - DoVerb
|
|
DoVerb has one parameter. It stands for the index of the verb to be
|
|
called. In this procedure you will do your actions by using the procedure
|
|
and functions that are defined in the interface of the PCPlgLib unit that
|
|
you should include in the uses clause of this dll dpr.
|
|
|
|
}
|
|
|
|
uses
|
|
SysUtils,
|
|
Classes,
|
|
Windows,
|
|
Messages,
|
|
Graphics,
|
|
Controls,
|
|
Forms,
|
|
StdCtrls,
|
|
Buttons,
|
|
Grids,
|
|
Dialogs,
|
|
bmpform in 'bmpform.pas' {formBmp},
|
|
PCPlgLib in '../PCPlgLib.pas';
|
|
|
|
procedure Init(Owner: Integer); stdcall;
|
|
begin
|
|
GetAdresses(Owner);
|
|
// Plugin specific intialization code
|
|
end;
|
|
|
|
Function GetVerbs:PChar;stdcall;
|
|
var res: pchar;
|
|
Begin
|
|
res := 'Adjust Brightness';
|
|
// if you had two verbs then the second one should be
|
|
// added with a return character
|
|
// res := 'Edit Bitmap'+#13+'The Second';
|
|
result := res;
|
|
End;
|
|
|
|
Procedure HandleBmpObject(f:Integer);
|
|
var frm: TformBmp;
|
|
fName: String;
|
|
xBitmap: Tbitmap;
|
|
begin
|
|
fName := 'c:\Abplg.tmp';
|
|
pcFigureSaveBitmapToFile(f,pchar(fName));
|
|
|
|
Sleep(250);
|
|
xBitmap := Tbitmap.Create;
|
|
xBitmap.LoadFromFile(fName);
|
|
frm := TFormBmp.Create(nil);
|
|
if frm.EditBitmap(xBitmap) then
|
|
begin
|
|
xBitmap.SaveToFile(fName);
|
|
pcFigureLoadBitmapFromFile(f,pchar(fName));
|
|
end;
|
|
|
|
frm.free;
|
|
end;
|
|
|
|
Procedure EditBitmap;
|
|
var i,cnt:Integer;
|
|
cName: String;
|
|
fBmp: Integer;
|
|
fHandle: Integer;
|
|
Begin
|
|
cnt := pcGetPropSelectedCount;
|
|
for i := 0 to Cnt -1 do
|
|
begin
|
|
fHandle := pcGetSelectedHandle(i);
|
|
cName := String(pcFigureGetClass(fHandle));
|
|
if Copy(uppercase(cName) ,1,4) = 'TBMP' then
|
|
begin
|
|
HandleBmpObject(fHandle);
|
|
Exit;
|
|
end;
|
|
end;
|
|
MessageDlg('Select a Bitmap Object to adjust first',mtWarning,[mbOk],0);
|
|
End;
|
|
|
|
Procedure DoVerb(VerbIndex: integer);stdcall;
|
|
Begin
|
|
if VerbIndex = 0 then EditBitmap;
|
|
end;
|
|
|
|
exports
|
|
Init name 'Init',
|
|
GetVerbs name 'GetVerbs',
|
|
DoVerb name 'DoVerb';
|
|
|
|
begin
|
|
|
|
end.
|