cm_ commands from Delphi to TC using not Command as digits but as a
cm_XXXXXX constants. File totalcmd.inc in the same directory as project
is requeired. Output file - will be looks like this and below is source code.
I do not know how to add this code to wiki. Is is useful enought for wiki?
Usefyl function:
Code: Select all
var
Tc_H : HWND;
begin
TC_H := FindWindow('TTOTAL_CMD', nil);
if TC_H <> 0 then
begin
SendTCCommand(cm_FocusLeft);
SendTCUserCommand('em_openirclogstab');
SetForegroundWindow(TC_H);
end;
end.
Code: Select all
SendTCCommand(cm_FocusLeft);
Code: Select all
unit tc_cm_consts;
interface
const
cm_SrcComments = 300;
// ... cut ...
cm_ContentStopLoadFields = 5514;
implementation
end.
Code: Select all
program tc_inc;
{$APPTYPE GUI}
uses
Windows;
function FileExists(FileName : string) : boolean;
var
Find : THandle;
WFD : TWin32FindData;
begin
Find := Windows.FindFirstFile(PChar(FileName), WFD);
Result := Find <> INVALID_HANDLE_VALUE;
FindClose(Find);
end;
const
Sep1 = '=';
Sep2 = ';';
In_FileName = 'totalcmd.inc';
Out_FileName = 'tc_cm_consts.pas';
AppTitle = 'Creator of Delphi module with cm_ commands variables - by olesio';
var
Line, Output : string;
OldH, AppHandle : HWND;
Sep1Pos, Sep2Pos : Word;
InFile, OutFile : TextFile;
begin
OldH := GetForegroundWindow;
AppHandle := FindWindow('Shell_TrayWnd', nil);
if FileExists(In_FileName) = False then
begin
MessageBox(AppHandle, PChar('Cannot find file: ' + In_FileName +
' - program terminated!'), PChar(AppTitle), MB_OK + MB_ICONERROR);
end
else
begin
Assign(InFile, In_FileName);
{$I-}
Reset(InFile);
{$I+}
if IOResult <> 0 then
begin
MessageBox(AppHandle, PChar('Cannot access file: ' + In_FileName +
' - program terminated!'), PChar(AppTitle), MB_OK + MB_ICONERROR);
end
else
begin
Assign(OutFile, Out_FileName);
{$I-}
Rewrite(OutFile);
{$I+}
if IOResult <> 0 then
begin
MessageBox(AppHandle, PChar('Cannot create file: ' + Out_FileName +
' - program terminated!'), PChar(AppTitle), MB_OK + MB_ICONERROR);
end
else
begin
Writeln(OutFile, 'unit ' + Copy(Out_FileName, 1, Pos('.', Out_FileName) - 1) + ';');
Writeln(OutFile);
Writeln(OutFile, 'interface');
Writeln(OutFile);
Writeln(OutFile, 'const');
while EOF(InFile) = False do
begin
Readln(InFile, Line);
if Pos('cm_', Line) = 1 then
begin
Sep1Pos := Pos(Sep1, Line);
Sep2Pos := Pos(Sep2, Line);
Output := Copy(Line, 1, Sep1Pos - 1) + ' = ' + Copy(Line, Sep1Pos + 1, Sep2Pos - Sep1Pos - 1);
Writeln(OutFile, #32#32 + Output + ';');
end;
end;
Writeln(OutFile);
Writeln(OutFile, 'implementation');
Writeln(OutFile);
Write(OutFile, 'end.');
Close(InFile);
Close(OutFile);
MessageBox(AppHandle, PChar('File: ' + Out_FileName +
' created.'), PChar(AppTitle), MB_OK + MB_ICONINFORMATION);
end;
end;
end;
SetForegroundWindow(OldH);
end.