Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
Caption:= Edit1.Text
end;
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, CommCtrl,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
function LvGetSelectedItemtext(LvHandle : Thandle) : String;
var Index : Integer;
Written : Cardinal;
cItemInfo : TLVITEM;
pItemInfo : PLVITEM;
pString : PChar;
Buffer : array[0..1023] of Char;
hProcess : THandle;
FPid : Cardinal;
begin
Result := '';
GetWindowThreadProcessID(LvHandle, FPid);
if FPid = 0 then Exit;
Index := SendMessage(LvHandle, LVM_GETITEMCOUNT, 0, 0);
ZeroMemory(@cItemInfo, SizeOf(cItemInfo));
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, FPid);
//Alloc mem in the external process
pItemInfo := VirtualAllocEx(hProcess, nil, SizeOf(cItemInfo), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
pString := VirtualAllocEx(hProcess, nil, 1024, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
try
while Index > 0 do
begin
// first look if there are items selected
Dec(Index);
if SendMessage(LvHandle, LVM_GETITEMSTATE, Index, LVIS_SELECTED) and LVIS_SELECTED <> 0 then
begin
// read selected item
if Assigned(pItemInfo) then
begin
cItemInfo.cchTextMax := 1024;
cItemInfo.pszText := pString;
cItemInfo.iSubItem := 0;
if WriteProcessMemory(hProcess, pItemInfo, @cItemInfo, SizeOf(cItemInfo), Written) then
begin
SendMessage(LvHandle, LVM_GETITEMTEXT, Index, Integer(pItemInfo));
ReadProcessMemory(hProcess, pString, @Buffer, 1024, Written);
Result := Buffer;
end;
end;
end;
end;
finally
if Assigned(pItemInfo) then
VirtualFreeEx(hProcess, pItemInfo, 0, MEM_RELEASE);
if Assigned(pString) then
VirtualFreeEx(hProcess, pString, 0, MEM_RELEASE);
end;
end;
function SameClassNameAndWindowName(Hwnd : THandle; ClassName, WindowName : string) : Boolean;
var Str: array[0..255] of char;
begin
Result := False;
GetClassName(Hwnd, Str, 255);
if AnsiSameText(ClassName, Str) then
begin
GetWindowText(Hwnd, Str, 255);
Result := AnsiSameText(WindowName, Str);
end;
end;
procedure FindExplorerWindows(List : TList);
var hwnd : THandle;
begin
hwnd := FindWindow('ExploreWClass', nil);
while hwnd <> 0 do
begin
List.Add(Pointer(hwnd));
hwnd := FindWindowEx(getDesktopWindow, hwnd, 'ExploreWClass', nil);
end;
end;
function FindChildWindow(ParentHwnd : THandle; ClassName, WindowName : String) : THandle;
var Child : THandle;
begin
// get all child windows from parent hwnd, filter for Classname and windowname
Result := 0;
Child := FindWindowEx(ParentHwnd, 0, nil, nil);
while (Child <> 0) and (Result = 0) do
begin
if SameClassNameAndWindowName(Child, ClassName, WindowName) then
begin
Result := Child;
Break;
end
else
Result := FindChildWindow(Child, ClassName, WindowName);
if Result = 0 then
Child := FindWindowEx(ParentHwnd, Child, nil, nil);
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
var List : TList;
Index : Integer;
Hwnd : THandle;
begin
Memo1.Lines.Clear;
List := TList.Create;
try
FindExplorerWindows(List);
for Index := 0 to List.Count -1 do
begin
Memo1.Lines.Add(Format('Explorer-> 0x%x', [Integer(List[Index])]));
Hwnd := FindChildWindow(THandle(List[Index]), 'SysListView32', 'FolderView');
if Hwnd <> 0 then
begin
Memo1.Lines.Add(Format('Folderview-> 0x%x - %s', [Hwnd, LvGetSelectedItemtext(Hwnd)]));
end;
end;
finally
FreeAndNil(List);
end;
end;
end.
oh, and I'm not a Delphi "geek" or "savant", I'm just a human being [afro]
Cheers,
Daddy
guruca said:What if I click/select the filename and it shows on the form display, just as I want too.
guruca said:I search google and I've found this, but its a c++ and it's a .dll, and I don't like to use dll's.
Could you please make it simple, just as I want too.
And also, I test it on my drive[d]\myfolders and selected a file, and it turns out that I can only see [myfolders] folder name.
guruca said:Daddy your at the peak, your a delphi elite.