views:

73

answers:

1

Hi

I have the following problem.

There's a pagecontrol on my form and I want to activate a certain tabsheet and then drag and drop (from explorer) to a scrollbox on the tabsheet. (each tabsheet has a scrollbox) I have code to activate a tab when you mousemove over the pagecontrol. (see code below) The problem is that when I drag a file from explorer the mousemove never fires when I hover/mousemove over the pagecontrol while still dragging. Also tried to set DragAcceptFiles(pagecontrol.Handle,true); but that also doesn't help.

procedure TForm2.PageControlMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var 
  tabindex : Integer;
begin
  tabindex := PageControl.IndexOfTabAt( X, Y );
  PageControl.ActivePageIndex := tabindex;
end;

Any ideas/solutions guys and girls?

Thanks.

SoulBlade

+4  A: 

With DragAcceptFiles() you don't get the necessary information, only when data is finally dropped onto the drop target will a WM_DROPFILES message be sent to the window handle registered with DragAcceptFiles().

If you use OLE drag and drop you will get much more control. The Drag and Drop Component Suite for Delphi by Anders Melander implements everything in an easy to install set of components. Use any of the drop target objects, set its Target property to the pagecontrol on which you want to drop, and use its OnDragOver event to activate the correct tabsheet.

mghie
I'll accept it as an answer. Any other ways without 3rd party components?
SoulBlade
@SoulBlade: Sure, you could implement the `IDropTarget` interface yourself (see http://msdn.microsoft.com/en-us/library/ms679679%28VS.85%29.aspx), but why go to all that trouble?
mghie
Yeah, you are right. Too much shlep to do myself. Anyway I installed the suite and it's working like a bomb. Thanks.
SoulBlade