Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Custom GDI+ class
Splash Screen for the VFP application
How to put a vertical text scrolling on the form (a movie cast)
Subclassing CommandButton control to create BackColor property
Obtaining names and positions for shortcuts located on the Windows Desktop
Enumerating devices installed on the local machine
Printing text with the Escape function
Displaying dimmed window behind VFP top-level form
How to make a VFP form fading out when released (GDI version)
Moving shortcut to a specified position on the Windows Desktop
System Image List Viewer
How to put a horizontal text scrolling on the form (a news line, marquee)
Storing content of the Clipboard to a bitmap file
Vertical Label control
How to ping a remote site using ICMP API calls
How to play AVI file on the _screen
GDI+: Implementing image scrolling with inertia
Adding a background image to VFP report (VFP9, ReportListener)
Mapping and disconnecting network drives
Custom FTP Class for Visual FoxPro application
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Detecting changes in connections to removable drives (VFP9)
CryptoAPI: Collection of Providers class
Monitoring clipboard content changes (VFP9)
Transparent Menu Class (requires VFP9)

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
The SetLayeredWindowAttributes function sets the opacity and the transparency color key of a layered window. Find an example of using this function in Semi-transparent Form code sample in this reference.

All menu popups are layered windows, which makes this technique applicable to them.

All VFP menus are owner-draw menus. The WM_DRAWITEM message is sent to the parent window of an owner-drawn menu when its visual aspect has changed. Through this message the window procedure obtains a pointer to the DRAWITEMSTRUCT structure.

This structure contains the hDC for a menu popup window. Pass this hDC to the WindowFromDC function to obtain the window handle (HWND) for the menu pop window.

In VFP9, BINDEVENT() function can intercept Windows messages including the WM_DRAWITEM. Thus a VFP application can be notified whenever any menu popup is redrawn. So the application can intervene and make a popup window transparent or semi-transparent.

To test the MenuManager class, copy the code sample to MenuManager.prg and type in the Command Window:

oManager = NEWOBJECT("MenuManager", "MenuManager.prg")
oManager.SetHook(Application.hWnd) && VFP9 required

After that the VFP System Menu will show semi-transparent. Release the MenuManager object to return the menu back to its normal state.

See also:
  • Testing Transparent Menu Class with top-level form
  • How to hot-track menu item selection in top-level form
  • Adding user-defined items to the Control Menu of VFP form
  • Reading structure of a menu attached to the main VFP window
  • Semi-transparent Form
  • How to draw a custom Window Caption on FoxPro form

      Members area. Log in to view this example.
      User name:
      Forgot your password?
      Sign up for
    the Membership

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    4757 bytes  
    Created: 2005-10-08 17:38:05  
    Modified: 2011-04-28 09:49:02  
    Visits in 7 days: 160  
    Listed functions:
    Printer friendly API declarations
    My comment:
    Transparency settings (crKey and bAlpha parameters in SetLayeredWindowAttributes call) should be carefully picked to ensure menu readability.

    Menu related Windows messages:

    * * *
    Recommended reading: OwnerDrawn Menus, an article written by Herman Tan and published in October 2005 issue of UniversalThread Magazine.

    Several third-party Menu Builders -- VFXMenuBuilder, VFEMenuBuilder, VMPMenuBuilder and more probably coming -- all implement object-oriented menus.

    * * *
    ContextMenu Control
       Designed for generating and displaying shortcut menus on VFP forms. A generated menu is object-oriented: menu items are accessible during runtime, can be modified, added and deleted. A menu can be exported to XML string, as well as loaded from a XML string.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.

    Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (
    9 sec.Function: 'GetClipboardData'
    17 sec.Function: 'GetSystemTimeAsFileTime'
    23 sec.Function: 'GetHGlobalFromStream'
    29 sec.Function: 'HeapUnlock'
    35 sec.Function: 'GetCurrentDirectory'
    41 sec.Function: 'ChooseColor'
    46 sec.Example: 'Retrieving the name of the network resource associated with a local device'
    56 sec.Function: 'EndTask'
    59 sec.Example: 'Attaching menu to a top-level form'
    1.15 min.Function: 'AlphaBlend'
    Advertise here!