WM_COPYDATA "CD" in right Panel
Moderators: Hacker, petermad, Stefan2, white
-
- Junior Member
- Posts: 33
- Joined: 2007-07-09, 21:03 UTC
- DenisBisson
- New Member
- Posts: 1
- Joined: 2013-11-12, 23:06 UTC
- Location: Drummondville, Québec, Canada
- Contact:
Sample code in Delphi to send message to TC to change folder
Hi!
This post does not answer directly to a question but since it's on the same matter, I place it here anyway. Here is my sample code in Delphi XE3 to send message to Total Commander to have it switch to folder(s) passed in parameter. It might not be very cute, but it's very simple and works fine.
If this helped you, please, let me know!
Dennis.
This post does not answer directly to a question but since it's on the same matter, I place it here anyway. Here is my sample code in Delphi XE3 to send message to Total Commander to have it switch to folder(s) passed in parameter. It might not be very cute, but it's very simple and works fine.
If this helped you, please, let me know!

Dennis.
Code: Select all
procedure TMyForm.TellTotalCommanderToSwitchDir(LeftPanelTargetDir,RightPanelTargetDir:string);
const
MY_UTF8_HEADER:RawByteString=AnsiChar($EF)+AnsiChar($BB)+AnsiChar($BF);
var
tcWnd: THandle;
DataStruct: TCopyDataStruct;
OutputString: RawByteString;
begin
tcWnd := FindWindow('TTOTAL_CMD', nil);
if tcWnd <> 0 then
begin
if LeftPanelTargetDir<>'' then OutputString:=MY_UTF8_HEADER+UTF8Encode(LeftPanelTargetDir+#$0D) else OutputString:=#$0D;
if RightPanelTargetDir<>'' then OutputString:=OutputString+MY_UTF8_HEADER+UTF8Encode(RightPanelTargetDir+#$0D);
DataStruct.dwData := Ord('C') + 256 * Ord('D');
DataStruct.cbData := length(OutputString)+1;
DataStruct.lpData := PAnsiChar(OutputString);
SendMessage(tcWnd, WM_COPYDATA, Self.Handle, Integer(@DataStruct));
end
else
begin
MessageDlg('ERROR: Unable to find Total Commander window...',mtError,[mbOk],0);
end;
end;