Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Custom GDI+ class
Obtaining names and positions for shortcuts located on the Windows Desktop
Printing Image File, programmatically set print page orientation to landscape
Pocket PC: custom RAPI class for operating with files and folders on mobile device
GDI+: Implementing image scrolling with inertia
How to play AVI file on the _screen
Displaying icons in the system tray (VFP9)
GDI+: reading and writing metadata in JPEG and TIFF files
How to load a user profile
Browsing Windows Known Folders (Special Folders)
Displaying dimmed window behind VFP top-level form
How to prevent users from accessing the Windows Desktop and from switching to other applications
Compressing and decompressing files with Windows API Runtime Library routines
Placing On-screen Alert on top of all windows
How to ping a remote site using IP Helper API calls
Enumerating devices installed on the local machine
GDI+: Creating thumbnails to preview images in a directory
Reading and setting system access privileges for the current process
Detecting changes in connections to removable drives (VFP9)
Custom HttpRequest class (WinHTTP)
GDI+: creating a gradient
Monitoring clipboard content changes (VFP9)
How to find which fonts Windows uses for drawing captions, menus and message boxes
Moving shortcut to a specified position on the Windows Desktop
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:
      Password:
     
     
      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: 71  
    Listed functions:
    CallWindowProc
    GetWindowLong
    SetLayeredWindowAttributes
    SetWindowLong
    WindowFromDC
    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:
    WM_ENTERMENULOOP
    WM_INITMENU
    WM_MENUSELECT
    WM_INITMENUPOPUP
    WM_DRAWITEM
    WM_UNINITMENUPOPUP
    WM_COMMAND
    WM_EXITMENULOOP
    WM_ENTERIDLE
    WM_SYSCOMMAND

    * * *
    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  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright 2001-2017 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.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.80.10.56)
    8 sec.Function: 'PathIsURL'
    14 sec.Function: 'LockWorkStation'
    19 sec.Function: 'GetNearestColor'
    25 sec.Function: 'SQLSetConfigMode'
    31 sec.Function: 'GdipDeleteMatrix'
    38 sec.Function: 'listen'
    45 sec.Function: 'RegQueryValueEx'
    50 sec.Function: 'SQLFetch'
    1 min.Function: 'SHGetFolderPath'
    1.12 min.Function: 'SetupDiDestroyClassImageList'
    Google
    Advertise here!