This is how you sendmessage a string passing it either WParam or LParam.
procedure MySenderFunction;
var
sText: String;
begin
sText := 'This is a test'.
SendMessage(Handle, WM_MYMESSAGE, Integer(@sText), 0) ;
end;
This is how you get the parameter being passed.
procedure MySenderFunction(Msg: TMessage);
var
sText: String;
begin
sText := PString(Msg.WParam)^;
end;
Thursday, September 20, 2012
Thursday, August 9, 2012
Tuesday, July 17, 2012
String grid filter
procedure MyFilter(AFilter: String);
begin
grid.Filter.Clear;
with grid.Filter.Add do
begin
Condition:=AFilter;
Column:=1;
end;
grid.FilterActive:=active;
end;
begin
grid.Filter.Clear;
with grid.Filter.Add do
begin
Condition:=AFilter;
Column:=1;
end;
grid.FilterActive:=active;
end;
Thursday, April 7, 2011
Checking if a folder is empty.
function IsDirectoryEmpty(const ADirectory: String): Boolean;
var
searchRec: TSearchRec;
begin
try
FindClose(searchRec);
end;
end;
var
searchRec: TSearchRec;
begin
try
Result := (FindFirst(ADirectory+'\*.*', faAnyFile, searchRec) = 0) ANDfinally
(FindNext(searchRec) = 0) AND
(FindNext(searchRec) <> 0);
FindClose(searchRec);
end;
end;
Thursday, February 17, 2011
Block Alt-F4 in Delphi
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = VK_F4) and (ssAlt in Shift) then
Key := 0;
end;
begin
if (Key = VK_F4) and (ssAlt in Shift) then
Key := 0;
end;
Wednesday, February 16, 2011
How to Minimize All Windows
uses ComObj;
procedure MinimizeAll;
var
Shell : OleVariant;
begin
try
Shell := CreateOleObject('Shell.Application') ;
Shell.MinimizeAll;
finally
end;
end;
procedure MinimizeAll;
var
Shell : OleVariant;
begin
try
Shell := CreateOleObject('Shell.Application') ;
Shell.MinimizeAll;
finally
end;
end;
Subscribe to:
Posts (Atom)