Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Styles    [ Add a report in this area ]  
Report #:  105612   Status: Closed
TrySetStyle() will strip/remove any setting to DragAcceptFiles()
Project:  Delphi Build #:  16.0.4429.46931
Version:    16.4 Submitted By:   Dag Ringdal
Report Type:  Issue Date Reported:  5/15/2012 1:36:10 AM
Severity:    Extreme corner case Last Updated: 5/15/2012 7:24:30 PM
Platform:    All versions Internal Tracking #:  
Resolution: Test Case Error (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
VCL failure:

Any call to TStyleManager.TrySetStyle('Aqua Light Slate');
- or other styles - will remove the working dragdrop functionality. The form will no longer accept drop.

Not possible to re-establish the functionality by a new call to DragAcceptFiles(Handle, true);
Steps to Reproduce:
1. Create a form,

2. Add OnCreate event handler for TForm as below.
--------
uses ShellApi;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DragAcceptFiles(Handle, True);
end;
--------

3. Creating a private procedure to handle drop of files from windows explorer etc as below.
-------
...
  private
    procedure WMDropFiles(var Msg : TWMDROPFILES); message WM_DROPFILES;
...
...
procedure TForm1.WMDropFiles(var Msg: TWMDROPFILES);
begin
  ShowMessage('WMDropFiles');
end;
-------

4. Working as it should

5. however, if I add custom sytles(e.g., Carbon, Aqua Light Slate etc...) and TButton and its OnClick event handler as below
-------
uses ..., Vcl.Themes;

procedure TForm1.Button1Click(Sender: TObject);
begin
  TStyleManager.TrySetStyle('Aqua Light Slate');
end;
-------

any call to TStyleManager.TrySetStyle('Aqua Light Slate');
- or any other style - will remove the dragdrop functionality.
Workarounds
None known
Attachment
None
Comments

Tomohiro Takahashi at 5/15/2012 7:19:26 PM -
> TForm.OnCreate -> DragAcceptFiles(Handle, true);
I think that after changing Style, form has been re-created and the Handle can not be used.
So, you need to call DragAcceptFiles(Handle, True); again at some timing...

Tomohiro Takahashi at 5/15/2012 7:23:51 PM -
Please try to override
    procedure CreateWindowHandle(const Params: TCreateParams); override;
and, call DragAcceptFiles again as below.
------------------
...
type
  TForm1 = class(TForm)
    ...
  protected
    procedure CreateWindowHandle(const Params: TCreateParams); override;
  public
  end;
...
...
procedure TForm1.CreateWindowHandle(const Params: TCreateParams);
begin
  inherited;
  DragAcceptFiles(Handle, True);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  TStyleManager.TrySetStyle('Aqua Light Slate');
end;
------------------

Server Response from: ETNACODE01