Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MROW() - Toolbar context menu problem
Message
 
 
À
05/03/2003 11:58:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00760807
Message ID:
00761629
Vues:
26
This "trick" gets the bottom left point of a commandbutton, and create a context popup menu from this point.
*& ================================
*&  CommandButton Click Event.
*& ================================

LOCAL lnThisX, lnThisY, lpCurPos, lcLongThisX, lcLongThisY, lnScreenX, lnScreenY, lnRow, lnCol, lpPos
*&
DECLARE short ClientToScreen in win32Api integer hWnd, string @ lpPoint
DECLARE short ScreenToClient in win32Api integer hWnd, string @ lpPoint
DECLARE SetCursorPos in win32API integer X, integer Y
DECLARE GetCursorPos in win32API string @lpPoint
*&
*&  Get the current Cursor Position.
lpCurPos = SPACE(8)
GetCursorPos(@lpCurPos)
*&
*&  This is the POINT where the context popup menu will be defined from.
*&  Change these X,Y value to any point on screen you want.
lnThisX = This.Left
lnThisY = This.Top + This.Height
*&
*&  Decode these Number type values into Long data type.
lcLongThisX = NumToLong(lnThisX)
lcLongThisY = NumToLong(lnThisY)
*&
*&  Construct a POINT structure for ClientToScreen API call.
lpPos = lcLongThisX+lcLongThisY
*&
*&  Convert client coordinates to screen coordinates.
ClientToScreen(Thisform.HWnd, @lpPos)
*&
lnScreenX = LongToNum(LEFT(lpPos, 4))
lnScreenY = LongToNum(RIGHT(lpPos, 4))
*&
*&  "Move" the cursor to the desired X,Y point and get the MROW and MCOL values.
= SetCursorPos(lnScreenX, lnScreenY)
*&
*&  Use these values for DEFINE POPUP statement.
lnRow = MROW()
lnCol = MCOL()
*&
*&  Move the cursor back to where it used to be!!!
lnScreenX = LongToNum(LEFT(lpCurPos, 4))
lnScreenY = LongToNum(RIGHT(lpCurPos, 4))
= SetCursorPos(lnScreenX, lnScreenY)
*&
DEFINE POPUP ShortcutOptions FROM lnRow, lnCol RELATIVE SHORTCUT MARGIN
*&
*&  Continue defining popup as normal.
*&
RETURN


*& ===== Additional supporting functions =====
*& Thanks to Ed Rauh for these functions.
*& ===========================================
FUNCTION NumToLong
LPARAMETER pnNum
DECLARE RtlMoveMemory IN WIN32API AS RtlCopyLong ;
	STRING @pDestString, INTEGER @pVoidSource, INTEGER nLength
LOCAL lcString
lcString = SPACE(4)
= RtlCopyLong(@lcString, BITOR(pnNum,0), 4)
RETURN cString
ENDFUNC

FUNCTION LongToNum
LPARAMETER pcLong
DECLARE RtlMoveMemory IN WIN32API AS RtlCopyLong ;
	INTEGER @ DestNum, STRING @ pVoidSource, INTEGER nLength
LOCAL lnNum
lnNum = 0
= RtlCopyLong(@lnNum, pcLong, 4)
RETURN lnNum
ENDFUNC
>> I have a procedure that determines the ROW and COLUMN values to be used with DEFINE POPUP from a commandbutton
>> I can post the procedure here for the benefits of other as well.
>>
>
>Please do, I'm interested in it.
>
>Thanks
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform