Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating Menus
Message
De
04/05/2001 04:11:44
 
 
À
02/05/2001 19:02:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Divers
Thread ID:
00501072
Message ID:
00503368
Vues:
21
Hi Michael,

Do not forget to release all handles you created in your code (lhMenuHandle, lnImageHandle) by using DestroyMenu and DeleteObject functions respectively. And also, you do not need to use DrawMenuBar at all if you create a simple popup menu, it is necessary and must be called only if you create and/or change your own menu bar (not popup).

>Sure here :)
>
>
>DECLARE INTEGER CreatePopupMenu IN WIN32API
>DECLARE INTEGER InsertMenu IN WIN32API INTEGER, INTEGER, INTEGER, INTEGER, STRING
>DECLARE INTEGER TrackPopupMenu IN WIN32API INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER
>DECLARE INTEGER DrawMenuBar IN WIN32API INTEGER
>DECLARE INTEGER GetActiveWindow IN WIN32API
>**** These are only required if you want to add an image to the item
>DECLARE INTEGER LoadImage IN win32api INTEGER,STRING,INTEGER,INTEGER,INTEGER,LONG
>DECLARE INTEGER SetMenuItemBitmaps IN win32api INTEGER,INTEGER,INTEGER,INTEGER,INTEGER
>
>**** Need to get the window handle of the window
>lhWindowHandle = GetActiveWindow()
>
>**** Create the new popup menu and get the handle
>lhMenuHandle = CreatePopupMenu()
>
>lnItemCount = 1
>lnSuccess = InsertMenu(lhMenuHandle, lnItemCount, 1024, ;
>	lnItemCount, "Text One")
>**** Must redraw the menu each time we add a new item to the list
>lnSuccess = DrawMenuBar(lhWindowHandle)
>
>**** Set a picture image for the selected item
>lcBitmap = "D:\SHE Client Server\GRAPHICS\Shortcut Menu Graphics\Company.bmp"
>lnImageHandle = LoadImage(0, lcBitmap, 0, 12, 12, 48)
>SetMenuItemBitmaps(lhMenuHandle, lnItemCount -1, 1024, lnImageHandle, lnImageHandle)
>
>lnItemCount = lnItemCount + 1
>**** Add a separator to the menu
>lnSuccess = InsertMenu(lhMenuHandle, lnItemCount, 2048, ;
>	lnItemCount, "")
>
>**** set the position of where to show the menu
>lnX = 0
>lnY = 0
>lnSuccess = TrackPopupMenu(lhMenuHandle, 256, lnX, lnY,0, lhWindowHandle, 0)
>
>CLEAR DLLS
>
>
>There is a whole bunch of other options to go with all those functions, but I haven't really looked into them yet.
Alex
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform