Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DEFINE POPUP Problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00689242
Message ID:
00689327
Vues:
18
I have a Container based button class and pops a shortcut menu too, but it's contained on a form instead of Toolbar. And this is the section of the code to get the MROW() and MCOL() of the bottom/left of the container on my form.

HTH. And hopefully someone will give you an easier solution.
Your DisplayMenu() code:
LPARAMETERS oMenuObj

    ** Define variables
    LOCAL nRow, nCol, lnThisX, lnThisY, lpCurPos, lcLongThisX, lcLongThisY, ;
      lpPos, lnScreenX, lnScreenY

    ** My codes to determine the bottom/left of the menu needs to be!
    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

    lnThisX = oMenuObj.Left
    lnThisY = oMenuObj.Top + oMenuObj.Height

    *&  Original Cursor Position!!!!!
    lpCurPos = SPACE(8)
    GetCursorPos(@lpCurPos)
    *&
    *&  Decode thes 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))
    *&
    = SetCursorPos(lnScreenX, lnScreenY)
    *&
    nRow = MROW()
    nCol = 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 the popup at the oMenuObj's bottom/left
    DEFINE POPUP ShortCuts FROM nRow, nCol IN SCREEN SHORTCUT
    ...
    ...
    ...
Supporting functions:
FUNCTION NumToLong
    LPARAMETER tnNum
    DECLARE RtlMoveMemory IN WIN32API AS RtlCopyLong ;
        STRING @pDestString, INTEGER @pVoidSource, INTEGER nLength
    LOCAL cString
    cString = SPACE(4)
    = RtlCopyLong(@cString, BITOR(tnNum,0), 4)
    RETURN cString
ENDFUNC

FUNCTION LongToNum
    LPARAMETER tcLong
    DECLARE RtlMoveMemory IN WIN32API AS RtlCopyLong ;
	INTEGER @ DestNum, ;
	STRING @ pVoidSource, ;
	INTEGER nLength
    LOCAL nNum
    nNum = 0
    = RtlCopyLong(@nNum, tcLong, 4)
    RETURN nNum
ENDFUNC
>I'v create a toolbar button class that pops up a menu just like MS Outlook does.
>
>It all works fine except for one problem; When there is a form open, the menu
>pops up half way off the left side of the screen. What I would really like is
>to have the menu's top & left be aligned with the bottom/left corner of the
>button, regardless of the position of the toolbar. The buttons are actually
>containers set to hot-track when the mouse passes over them.
>
>Menu information is taken from an array property called .aMenuInfo which is
>loaded in the Init of the button:
>
>
>
>.aMenuInfo[1,1] = "Open Client" && Prompt
>.aMenuInfo[1,2] = "Images\Menu\Client.Bmp" && Image
>.aMenuInfo[1,3] = "Opens an existing Client" && Tooltip text
>
>
>
>
>Any ideas?
>
>When the down-arrow container on the class is clicked, this method is run:
>
>
>
>WITH This
>
>  IF .Enabled
>    .DisplayMenu(This)
>  ENDIF
>	
>  ENDWITH
>
>RETURN
>
>
>
>
>
>Here's the DisplayMenu code:
>
>
>
>LPARAMETERS oMenuObj
>
>  ** Define variables
>  LOCAL nBar, cPrompt
>
>  WITH This
>
>    ** Determine top/left of the menu
>    nRow = MROW() + 1
>    nCol = MCOL() - 7.5
>
>    ** Define the popup
>    DEFINE POPUP ShortCuts FROM nRow, nCol IN SCREEN SHORTCUT
>
>    ** Loop once for each menu item in the array
>    FOR nBar = 1 TO ALEN(.aMenuInfo, 1)
>	
>      ** Extract the prompt and the picture
>      cPrompt = .aMenuInfo[nBar, 1]
>      cPicture = .aMenuInfo[nBar, 2]
>	  	
>      ** If the prompt is empty, make it a separator
>      IF EMPTY(cPrompt)
>        DEFINE BAR nBar OF ShortCuts PROMPT "\-"
>      ELSE
>        DEFINE BAR nBar OF ShortCuts PROMPT cPrompt PICTURE cPicture
>      ENDIF
>		
>    ENDFOR
>
>    ** Define selection actions
>    ON SELECTION POPUP ShortCuts oMenuObj.MenuSelect()
>
>    ** Show the popup
>    ACTIVATE POPUP ShortCuts
>
>  ENDWITH
>
>RETURN
>
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform