Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Enumerating data formats currently available on the clipboard
Custom GDI+ class
Mapping and disconnecting network drives
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Winsock: sending email messages (SMTP, port 25)
How to display the Properties dialog box for a file (ShellExecuteEx)
Disk in drive A:
Using Font and Text functions
Detecting changes in connections to removable drives (VFP9)
How to download a file from the FTP server using FtpGetFile
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to play AVI file on the _screen
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Using EnumPrinters function to enumerate locally installed printers
Splash Screen for the VFP application
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Subclassing CommandButton control to create BackColor property
Creating irregularly shaped FoxPro form using transparency color key
Vertical Label control
Converting Unicode data from the Clipboard to a character string using a given code page
Creating a console window for Visual FoxPro application
Enumerating network resources
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: 122  
    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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.234.126.92)
    3 sec.Example: 'Setting the Window Region for a form'
    4.19 hrs.Example: 'Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)'
     Function: 'GdipGetPageScale'
    Function group: 'GDI+ Graphics'
    6.27 hrs.Example: 'Testing if a connection to an Url can be established'
    6.28 hrs.Example: 'Testing Clipboard functions: emptying the clipboard'
     Function: 'EndPath'
    9.91 hrs.Function: 'EndTask'
    Function group: 'Window'
    10.37 hrs.Example: 'Obtaining names of local and global groups for current user (WinNT/XP/2K)'
     Function: 'CreateProcessAsUser'
     Solution: 'ContextMenu ActiveX Control'
    Google
    Advertise here!