I have the following procedure that allows droping files from windows, the dropping works just fine but when I change the style at runtime using (TStyleManager.TrySetStyle(styleName)
), the form accept no more dropping! what is wrong here exactly?
public //public section of the form
...
procedure AcceptFiles( var msg : TMessage ); message WM_DROPFILES;
...
procedure TMainFrm.AcceptFiles(var msg: TMessage);
var
i,
fCount : integer;
aFileName : array [0..255] of char;
begin
// find out how many files the form is accepting
fCount := DragQueryFile( msg.WParam, {uses ShellApi is required...}
$FFFFFFFF,
acFileName,
255 );
for I := 0 to fCount - 1 do
begin
DragQueryFile(msg.WParam, i, aFileName, 255);
if UpperCase(ExtractFileExt(aFileName)) = '.MSG' then //accept only .msg files
begin
if not itemExists(aFileName, ListBox1) then// function checks whether the file was already added to the listbox
begin
ListBox1.Items.Add(aFileName);
end
end;
end;
DragFinish( msg.WParam );
end;
...
procedure TMainFrm.FormCreate(Sender: TObject);
begin
DragAcceptFiles( Handle, True ); //Main form accepts the dropped files
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With