Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mouse Pointer in a grid
Message
De
10/07/2002 03:21:30
 
 
À
09/07/2002 11:55:29
Angela Haws
Seminole County Tax Collector
Debary, Floride, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00676334
Message ID:
00676929
Vues:
24
Hi again,

How did you get on?

Here is a shape class that we use. It is written for VFP7. To use it, you just have to init it and pass in a reference to your grid object.

You can see that the Click and Double Clicks are passed to the Grid Click and Double Click. This was to avoid having to code the click and double click for all of our controls.

To set the mousepointer, you'll just have to add the properties MousePointer and MouseIcon in the declaration.

You'll notice that we have a few properties to do with resizing in there. This is something you'll have to think about if the grid is resized.

Good Luck

Mace

*--------------------------------------------------------------------------------------------------
* Class.............: shpGridPick
*--------------------------------------------------------------------------------------------------
* Author............: Macer Skeels
* Created...........: 12.06.2002 11:34:32
* Copyright.........: (c) Nokia, 2001
*) Description.......: Shape that is created by a Grid. It gives us the opportunity to code the click
*) : and the double click in one place and stops the mousepointer changing
*) : to an I Beam.
*) :
*) :
* Calling Samples...:
* Parameter List....:
* Major change list.:
*--------------------------------------------------------------------------------------------------

DEFINE CLASS shpGridPick AS Shape

BackStyle = 0 && Set to 1 during testing, should be zero
icResizeFlags = "" && Added to be compatible with AutoSize Class

PROTECTED ioTargetGrid

************************************************
PROCEDURE INIT
************************************************
*) Description.......:
*) :
* Calling Samples...:
* Parameter List....:
* :
* Major change list.:
*--------------------------------------------------------------------------------------------------
LPARAMETERS toGrid AS Grid && The grid that instatiated the shape, that it is to be associated with

ASSERT VARTYPE(toGrid) = "O";
MESSAGE "Parameter < toGrid > : Parameter missing or wrong type (Expecting 'O')"

WITH THIS

*-- Size and position the shape to cover the rows
.Top = toGrid.Top + toGrid.HeaderHeight
.Left = toGrid.Left + IIF( toGrid.RecordMark, 10, 0) && Do not cover the recordmark

*-- Compensate for recordmark and verticalscroll bar
.Width = toGrid.Width - ;
IIF( toGrid.ScrollBars > 1, 16, 0)

&& Not needed!!! IIF( toGrid.RecordMark, 10, 0) - ;

*-- compensate for header height and horizontal scroll bar
.Height = toGrid.Height - toGrid.HeaderHeight - ;
IIF( (toGrid.ScrollBars = 1) OR (toGrid.ScrollBars = 3), 16, 0)

*-- Make sure the shape is on top of the grid!!!!
.ZOrder(0)

.ioTargetGrid = toGrid

*-- Make sure the shape has the same resize flags as the grid... if any
IF PEMSTATUS( toGrid, "icResizeFlags", 5)
.icResizeFlags = toGrid.icResizeFlags
ENDIF

ENDWITH

RETURN .T.
*--End of Procedure INIT ------------------------------------------------------------------------------------------------


************************************************
PROCEDURE DESTROY
************************************************
*) Description.......:
*) :
* Calling Samples...:
* Parameter List....:
* :
* Major change list.:
*--------------------------------------------------------------------------------------------------

THIS.ioTargetGrid = NULL

RETURN .T.
*--End of Procedure DESTROY ------------------------------------------------------------------------------------------------


************************************************
PROTECTED PROCEDURE ActivateRow
************************************************
*) Description.......: Activates the Row that the user clicked on
*) :
* Calling Samples...:
* Parameter List....:
* :
* Major change list.:
*--------------------------------------------------------------------------------------------------
LOCAL laClick[1] && The array into which the mouse poistion details are put
LOCAL lnGridComponent AS Number
LOCAL lnRelativeRow AS Number
LOCAL lnRelativeColumn AS Number

*-- Populate laClick with the click info
AMOUSEOBJ( laClick, 1)

WITH THIS.ioTargetGrid

*-- Set the focus on the grid... needed to use relative row etc
.SetFocus()

*-- Find out which row the user wanter to click
.GridHitTest( laClick[3], laClick[4], @lnGridComponent, @lnRelativeRow, @lnRelativeColumn)

*-- Activate the Row
IF lnGridComponent = 3
lnReturn = 1
.ActivateCell( lnRelativeRow, lnRelativeColumn)
ELSE
lnReturn = -1
ENDIF
ENDWITH

RETURN lnReturn
*--End of Procedure ActivateRow ------------------------------------------------------------------------------------------------


************************************************
PROCEDURE Click
************************************************
*) Description.......: Accepts the click, and activates the underlying row in the Grid
*) :
* Calling Samples...:
* Parameter List....:
* :
* Major change list.:
*--------------------------------------------------------------------------------------------------
LOCAL lnReturn AS Number

lnReturn = THIS.ActivateRow()
IF lnReturn > -1
lnReturn = THIS.ioTargetGrid.Click()
ENDIF

RETURN lnReturn
*--End of Procedure Click ------------------------------------------------------------------------------------------------


************************************************
PROCEDURE DBLClick
************************************************
*) Description.......: Accepts the click, and activates the underlying row in the Grid
*) :
* Calling Samples...:
* Parameter List....:
* :
* Major change list.:
*--------------------------------------------------------------------------------------------------

LOCAL lnReturn AS Number

lnReturn = THIS.ActivateRow()
IF lnReturn > -1
lnReturn = THIS.ioTargetGrid.DBLClick()
ENDIF

RETURN lnReturn
*--End of Procedure DBLClick ------------------------------------------------------------------------------------------------

ENDDEFINE



>It is weird huh?!
>
>>>1. You would have to code the MouseOver/MouseMove event and set the MousePOinter and MouseIcon for the Grid, COlumn etc
>
>I think I will try this first.
>
>
>>>2. You could put a transparent shape on the grid to cover the column... but this would be complicated to code especially if the grid is editable.
>
>My grid is not editable. It is only to select a name from.(Like an index)
>
>Text1.click:
>
>
>do form frminquiry with hfmaster.cust_num
>
>
>Would this transparent shape affect the text1.click event?
>What would I code for the shape?
>
>:) Angie
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform