Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving size of a remote file
Retrieving the name of the default printer for the current user on the local computer (Win NT/XP)
Using vendor-neutral SQL constructs
Displaying the drive type value
Enumerating Volumes and Volume Mounting Points (NTFS)
GDI+: Color Transparency
GDI+: printing image file
How to find the application associated with a file name
Reading header information from AVI file
Retrieving information about MS-DOS device names using QueryDosDevice (WinNT only)
Using Change Notification Objects to monitor changes to the printer or print server
Drawing standard Windows icons
Removing FTP directory
Retrieving information specific to the current Time Zone
Retrieving Window Class information for the VFP window
Using FtpCommand
Enumerating sessions established on a server
GDI+: enumerating fonts installed on the system
Retrieving the name and type of all available RAS-capable devices
Scanning the hierarchy of child windows down from the main VFP window
Testing MS Internet Explorer version installed
Using the GetTempFileName
Changing file attributes
Creating a directory on the FTP
Testing Transparent Menu Class with top-level form (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 code creates top-level form with a menu. An instance of the MenuManager class is used to make this menu semi-transparent. The form records menu-related window messages to a cursor and displays them in a listbox.



Before testing the following code, save another code sample, Transparent Menu Class, to MenuManager.prg module.

 
oForm = CREATEOBJECT("Tform")
oForm.Visible=.T.
READ EVENTS
 
DEFINE CLASS Tform As Form
PROTECTED hOrigProc, hWindow
    hOrigProc=0
    hWindow=0
    Width=450
    Height=400
    Autocenter=.T.
    ShowWindow=2
    Caption="Transparent Menu Demo"
    menumanager=0
 
    ADD OBJECT lst As ListBox WITH;
    Left=5, Top=5, Width=440, Height=326,;
    FontName="Courier", FontSize=8
 
    ADD OBJECT chRecord As CheckBox WITH Value=.F.,;
    Left=16, Top=344, Autosize=.T., BackStyle=0,;
    Caption="Record Messages"
 
    ADD OBJECT cmdClearList As CommandButton WITH;
    Left=350, Top=340, Width=80, Height=27, Caption="Clear List"
 
PROCEDURE Init
    THIS.menumanager = NEWOBJECT("MenuManager", "MenuManager.prg")
    THIS.menumanager.SetAlphaOpacity(156)
*!*    *    THIS.menumanager.DisableAlphaOpacity
*!*        THIS.menumanager.EnableTransparentColor(THIS.BackColor)
 
    _screen.Visible=.F.
    THIS.DefineMenu
 
PROCEDURE Destroy
    CLEAR EVENTS
    _screen.Visible=.T.
 
PROCEDURE Activate
    IF THIS.hWindow=0
        THIS.hWindow=THIS.HWnd
        THIS.menumanager.SetHook(THIS.hWindow)
 
        THIS.CreateCursor
        = BINDEVENT(THIS.menumanager, "OnWindowProc",;
            THIS, "OnWindowMessage")
 
        WITH THIS.lst
            .ColumnCount=4
            .ColumnWidths="60,160,100,100"
        ENDWITH
 
        DECLARE INTEGER SetForegroundWindow IN user32 INTEGER hwnd
        SetForegroundWindow(THIS.hWindow)
    ENDIF
 
PROCEDURE OnWindowMessage(hWindow as Integer, nMsgID as Integer,;
    wParam as Integer, lParam as Integer)
#DEFINE WM_DRAWITEM 0x002B
#DEFINE WM_COMMAND 0x0111
#DEFINE WM_MENUSELECT 0x011F
#DEFINE WM_ENTERMENULOOP 0x0211
#DEFINE WM_EXITMENULOOP 0x0212
#DEFINE WM_INITMENU 0x0116
#DEFINE WM_INITMENUPOPUP 0x0117
#DEFINE WM_UNINITMENUPOPUP 0x0125
 
    IF NOT THIS.chRecord.Value
        RETURN
    ENDIF
 
    LOCAL cMsgName, cIdx
 
    DO CASE
    CASE nMsgId=WM_DRAWITEM
        cMsgName="WM_DRAWITEM"
    CASE nMsgId=WM_COMMAND
        cMsgName="WM_COMMAND"
    CASE nMsgId=WM_MENUSELECT
        cMsgName="WM_MENUSELECT"
    CASE nMsgId=WM_ENTERMENULOOP
        cMsgName="WM_ENTERMENULOOP"
    CASE nMsgId=WM_EXITMENULOOP
        cMsgName="WM_EXITMENULOOP"
    CASE nMsgId=WM_INITMENU
        cMsgName="WM_INITMENU"
    CASE nMsgId=WM_INITMENUPOPUP
        cMsgName="WM_INITMENUPOPUP"
    CASE nMsgId=WM_UNINITMENUPOPUP
        cMsgName="WM_UNINITMENUPOPUP"
    OTHERWISE
        cMsgName=TRANSFORM(nMsgId,"@0")
    ENDCASE
 
    INSERT INTO csMessages VALUES (cMsgName,;
        TRANSFORM(m.wParam,"@0"), TRANSFORM(m.lParam,"@0"))
 
    cIdx = PADL(TRANSFORM(RECCOUNT("csMessages")),6,"0")
 
    WITH THIS.lst
        .AddItem(m.cIdx,1)
        .List(1,2)=m.cMsgName
        .List(1,3)=csMessages.wParam
        .List(1,4)=csMessages.lParam
    ENDWITH
 
PROCEDURE cmdClearList.Click
    ThisForm.lst.Clear
    ThisForm.CreateCursor
 
PROCEDURE CreateCursor
    CREATE CURSOR csMessages (msgname C(20),;
        wparam C(12), lparam C(12))
 
PROTECTED PROCEDURE DefineMenu
    DEFINE MENU SampleMenu BAR IN WINDOW (THISFORM.Name)
 
    DEFINE PAD p1 OF SampleMenu PROMPT "\
    DEFINE PAD pp OF SampleMenu PROMPT "\
    DEFINE PAD p2 OF SampleMenu PROMPT "\
    DEFINE PAD p3 OF SampleMenu PROMPT "\
    DEFINE PAD p4 OF SampleMenu PROMPT "\
 
    ON PAD p1 OF SampleMenu ACTIVATE POPUP _MSM_FILE
    ON PAD pp OF SampleMenu ACTIVATE POPUP popupReports
    ON PAD p2 OF SampleMenu ACTIVATE POPUP _MSM_TOOLS
    ON PAD p3 OF SampleMenu ACTIVATE POPUP _MSM_WINDO
    ON PAD p4 OF SampleMenu ACTIVATE POPUP _MSM_SYSTM
 
    DEFINE POPUP popupReports MARGIN RELATIVE SHADOW COLOR SCHEME 4
    DEFINE BAR 1 OF popupReports PROMPT "Production"
    DEFINE BAR 2 OF popupReports PROMPT "Accounting"
    DEFINE BAR 3 OF popupReports PROMPT "HR"
    ON BAR 1 OF popupReports ACTIVATE POPUP popupProduction
    ON BAR 3 OF popupReports ACTIVATE POPUP hr
 
    DEFINE POPUP popupProduction MARGIN RELATIVE SHADOW COLOR SCHEME 4
    DEFINE BAR 1 OF popupProduction PROMPT "Daily"
    DEFINE BAR 2 OF popupProduction PROMPT "Weekly"
    DEFINE BAR 3 OF popupProduction PROMPT "Monthly"
    ON BAR 1 OF popupProduction ACTIVATE POPUP daily
 
    DEFINE POPUP daily MARGIN RELATIVE SHADOW COLOR SCHEME 4
    DEFINE BAR 1 OF daily PROMPT "Orders received"
    DEFINE BAR 2 OF daily PROMPT "Pre-shipping list"
    DEFINE BAR 3 OF daily PROMPT "Orders Shipped"
 
    DEFINE POPUP hr MARGIN RELATIVE SHADOW COLOR SCHEME 4
    DEFINE BAR 1 OF hr PROMPT "Attendance"
    DEFINE BAR 2 OF hr PROMPT "Attendance by departments"
 
    ACTIVATE MENU SampleMenu NOWAIT
 
ENDDEFINE
 
 
 

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

* * *
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 (184.73.7.143)
4 sec.Function: 'SetTextCharacterExtra'
Function group: 'Font and Text'
1.2 hrs.Function: 'bind'
Function group: 'Windows Sockets 2 (Winsock)'
 Function: 'WTSEnumerateProcesses'
 Example: 'Enumerating network interfaces on the local computer'
1.37 hrs.Function: 'OpenInputDesktop'
2.24 hrs.Example: 'Using the RestartDialog function -- restarting Windows'
 Function: 'StretchBlt'
 Example: 'PocketPC: custom RAPI class for executing routines on remote Windows CE device'
2.46 hrs.Function: 'MAPIResolveName'
2.47 hrs.Example: 'Using Video Capture: enumerating installed capture drivers'
Google
Advertise here!