Need Help, Plugin in Pascal ...

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Need Help, Plugin in Pascal ...

Post by *franck8244 »

I'm writing a lister plugin in Pascal.
->It works but I have a few problem: :(

1) Reading the ini file does not work correctly :

Reading the ini file & language file is ok ONLY when the second panel contains the ini file (and the language directory)

What I do :
IniFile:TIniFile.Create('./PluginName.ini');
(or 'PluginName.ini' , I tried both)

In this ini, i'm just supplying language file name:
ini File:
[General]
Language=./lng/French.lng
;Language=C:\temp\lng\English.lng

(to test absolute path or relative)
I'm reading the file in the code with the "IniFile.ReadString" method

then I do the same to open the language file with the string i have read in the ini file....

I don't see what is wrong ....:oops:

2) What is the best way (TMemo, TEdit, ...) to show only text in the lister window ?
->I have problems when I want to activate the scrollBar ...I should specified the 'TMemo' size before but I don't know how to get it (size of the lister window)...

Thanks in advance
TC#88260 -
User avatar
Clo
Moderator
Moderator
Posts: 5731
Joined: 2003-12-02, 19:01 UTC
Location: Bordeaux, France
Contact:

Addons Help...

Post by *Clo »

2franck8244
:) Hello ! Bonsoir,

¤ I can't help you directly, but have you the Ch. Ghisler's Help folder about addons creations?
- You may get it in English AND French here >>> add-lister.zip

- Just my 0.03 € (inflation …)

:mrgreen:  Kind regards,
Claude
Clo
#31505 Traducteur Français de TC French translator Aide en Français Tutoriels Français English Tutorials
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

franck8244,
IniFile:TIniFile.Create('./PluginName.ini');
The problem is probably in a wrong current directory. The current dir isn't the one where your plugin is but some other dir (target panel?).
Try extracting the path to your plugin by using one of these (not sure which one will work):

path := paramstr(0);
path := application.exename;

extract the path and appenf 'pluginname.ini' to it.

There might be better ways, but for now I

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

Hacker wrote:The problem is probably in a wrong current directory. The current dir isn't the one where your plugin is but some other dir
Here you are right.
Try extracting the path to your plugin by using one of these (not sure which one will work):
path := paramstr(0);
path := application.exename;
They both will work, it's the same code. :)

Code: Select all

Forms.pas:
function TApplication.GetExeName: string;
begin
  Result := ParamStr(0);
end;
2Frank:
set at module initialization:
IniName:= ExtractFileDir(ParamStr(0))+'\YourPlugin.ini';
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

They both will work, it's the same code. :)

Code: Select all

Forms.pas:
function TApplication.GetExeName: string;
begin
  Result := ParamStr(0);
end;
LOL, didn't know that. :)

Thanks
Roman
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

I tried both :
path := paramstr(0);
path := application.exename;

But it gives me the totalcmd path ....(more precisely the running tcmd that calls my plugin)

I would like to put my ini in the same dir as my plugin , not in TC directory ....
TC#88260 -
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

franck8244 wrote:I tried both :
But it gives me the totalcmd path ....(more precisely the running tcmd that calls my plugin)
Sorry, I forgot yuo are writing a plugin. :)
For .dll - yes, ParamStr returns path to .exe file. You need to call Windows.GetModuleFileName, for it set hModule you get from TC.
AFAIR, this works:
hModule:= HInstance; //standard Delphi var

(I wrote a plugin for FAR manager, AFAIR it worked).
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

Thanks 2 all,

I solved my 1st problem with:
SetString(path, ModName, Windows.GetModuleFileName(HInstance, ModName, SizeOf(ModName)));

path:=ExtractFilePath(path);

Now the language part of my plugin is working...

For my 2nd Problem (see 1st post) here are 2 screenshots :
it shows the same file :
Pb with ScrollBar and Without ScrollBar
TC#88260 -
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

franck8244 wrote: 2) What is the best way (TMemo, TEdit, ...) to show only text in the lister window ? ->I have problems when I want to activate the scrollBar ...
You want to disable scrollbars?
Set for TMemo in Object Inspector: Scrollbars:= ssNone, they will be disabled...

Regards,
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

2alextp
No I want to show the scrollbar when necessary....

But when I activate the vertical one (or both) I've a "big" problem ->see the 2 above screenshots ....
TC#88260 -
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

franck8244 wrote:2alextp
No I want to show the scrollbar when necessary....
But when I activate the vertical one (or both) I've a "big" problem ->see the 2 above screenshots ....
Ok, I understand. You need to get Lister's window width from Handle (ListLoad: ParentWin).
How to do it, I don't know. :) some Win function...

Regards,
mutex
Junior Member
Junior Member
Posts: 39
Joined: 2004-02-22, 12:47 UTC
Location: Kazakhstan

Post by *mutex »

Try to use the TRichEdit instead of TMemo.

And see below:
http://www.totalcmd.net/plugring/ListSimple.html
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

2All : Thanks

I found what was wrong now all is working correctly (or should I say as I want...)
TC#88260 -
Post Reply