Carl
Found the problem! I was creating StringGrids programatically from inside a class I derived from a Scrollbox, and assigning StringGrid OnDragEvents to routines inside the derived Scrollbox class. I couldnt figure out why the BeginDrag call didnt trigger the OnStartdrag handler I had written. Turned out that I was calling the Scrollbox's StartDrag handler, I should have used the StringGrids handler;

procedure tScrollbox.DiaryMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Button = mbLeft)  then
     (Sender as tScrollbox ).BeginDrag(False,10);
end;

Guess I am the victim of my own flawed biology.

Thanks for considering the problem

Leo

Leo Ramakers wrote:

Carl
thanks for you time. I simply wrote an even handler to respond to OnMouseDown,
and in my diary object (which has the TScrollbox) initialisation I assigned
the new procedure to the OnMouseDown event.

I guess I must have influenced the underlying control button set somehow, I
might try a barebones TStringGrid first, as you did. Something is definitely
insetting csLButtonDown.

regards
Leo

Carl Reynolds wrote:

> When you say you've "taken over the OnMouseDown handler", what do you
> mean?  Do you have your own WndProc for your control?  It's in the
> WndProc for TControl that csLButtonDown becomes set, in response to a
> WM_LBUTTONDOWN message.  Check that you're reproducing this default
> behaviour, or passing to the default TControl.WndProc if needed.
>
> As a test, I tried the same thing with a TStringGrid created at runtime.
> For me, csLButtonDown is set (via the call stack, from TControl.WndProc)
> and I get the OnStartDrag.
>
> Cheers,
>
> Carl Reynolds                      Ph: +64-9-4154790
> CJN Technologies Ltd.             Fax: +64-9-4154791
> [EMAIL PROTECTED]                DDI: +64-9-4154795
> PO Box 302-278, North Harbour, Auckland, New Zealand
> 12 Piermark Drive, North Harbour Estate, Auckland, NZ
> Visit our website at http://www.cjntech.co.nz/
>
> > -----Original Message-----
> > From: Leo Ramakers [SMTP:[EMAIL PROTECTED]]
> > Sent: Thursday, October 21, 1999 1:08 PM
> > To:   Multiple recipients of list delphi
> > Subject:      [DUG]:  Drag problem
> >
> > I am trying to implement drag and drop behaviour in a Diary component
> > I am writing. The component is derived from TScrollbox, and contains a
> > number of TStringGrids. I need to be able to drag the contents of a
> > cell in one StringGrid and drop into a cell elsewhere. I have taken
> > over the OnMouseDown handler in the source grid, and call BeginDrag
> > from it.
> >
> > procedure TFormBeds.myMouseDown(Sender: TObject; Button: TMouseButton;
> >
> >   Shift: TShiftState; X, Y: Integer);
> > begin
> >   if Button = mbLeft then
> >     with Sender as TStringGrid do
> >       BeginDrag(False,10);
> > end;
> >
> > I have taken over the OnStartDrag handler, but it doesnt get called
> > for some reason, athough the same OnStartdrag handler does get called
> > for the components I drop on the form manually. Buried inside the
> > 'Controls' code I find that the manually crafted components take a
> > branch in the tControl.BeginDrag handler {if csLButtonDown in
> > ControlState}where my runtime created component fails that branch
> > because the ControlState is an empty set.
> >
> > Does anyone have any clues?
> >
> > I am writing a 'diary' application, where the diary manages bookings
> > for different rooms. Unfortunately the time period for each room is
> > varied, so I cant use a multicolumn stringrid and chose to use a
> > number of single column stringGrids side by side. I need to take over
> > the whole bagage of mouse events to handle clicks, double clicks, and
> > drag/drop, but the event behaviour is not straighforward.
> >
> > best regards
> > Leo
> >
> > ----------------------------------------------------------------------
> > ----- New Zealand Delphi Users group - Delphi List -
> > [EMAIL PROTECTED] Website: http://www.delphi.org.nz
>
>   ------------------------------------------------------------------------
>
>    Part 1.2    Type: application/ms-tnef
>            Encoding: base64

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

--------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz

Reply via email to