Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Custom GDI+ class
GDI+: Implementing image scrolling with inertia
How to change display settings: screen resolution, screen refresh rate
Obtaining names and positions for shortcuts located on the Windows Desktop
Enumerating devices installed on the local machine
How to load a user profile
Displaying icons in the system tray (VFP9)
Displaying dimmed window behind VFP top-level form
Browsing Windows Known Folders (Special Folders)
Printing Image File, programmatically set print page orientation to landscape
How to find which fonts Windows uses for drawing captions, menus and message boxes
Windows Shell Icons displayed and exported to ICO files (Vista)
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Storing content of the Clipboard to a bitmap file
GDI+: reading and writing metadata in JPEG and TIFF files
Moving shortcut to a specified position on the Windows Desktop
How to control Adobe Reader 9.0 (SDI mode) from VFP application
Monitoring clipboard content changes (VFP9)
How to display Windows On-Screen Keyboard
GDI+ fun: roach-infested desktop
Adding a background image to VFP report (VFP9, ReportListener)
How to enable the SE_SHUTDOWN_NAME privilege for the application
Detecting changes in connections to removable drives (VFP9)
How to check whether the system is 32-bit or 64-bit
Reading and setting explicit Application User Model ID for the current process (Win7)

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
Versions:
click to open
Before you begin:
Application User Model IDs (AppUserModelIDs) are used extensively by the taskbar in Windows 7 and later systems to associate processes, files, and windows with a particular application.




See also:
  • Accessing the list of Windows Recent Documents
  • LOCAL oAppUserModel As AppUserModel
    
    oAppUserModel = CREATEOBJECT("AppUserModel")
    ? "[" + oAppUserModel.AppID + "]"
    
    oAppUserModel.AppID = "VFP.MyApplication.MainForm"
    ? "[" + oAppUserModel.AppID + "]"
    
    * end of main
    
    DEFINE CLASS AppUserModel As Custom
    * implements access to Application User Model ID (AppUserModelID) 
    * that identifies the current process to the taskbar
    
        AppID=""
        ErrorCode=0
    
    PROCEDURE Init( cAppID As String )
        IF VAL(OS(3))*10 + VAL(OS(4)) < 61
            WAIT WINDOW "Minimum supported OS: Win7 !" TIMEOUT 10
            RETURN .F.
        ENDIF
    
        THIS.declare
        IF NOT EMPTY(m.cAppID)
            THIS.AppID = m.cAppID
        ENDIF
    
    PROCEDURE AppID_ASSIGN(vValue As Variant)
        LOCAL cAppID
        cAppID = TRANSFORM(m.vValue)
    
        * note: converted to Unicode
        THIS.ErrorCode = API_SetAppID(;
            STRCONV(m.cAppID,5) )
    
        IF THIS.ErrorCode = 0
        * you may need to hide and show
        * VFP main window to refresh its jump list
            THIS.AppID = m.cAppID
        ENDIF
    
    PROCEDURE AppID_ACCESS() As String
        LOCAL hAppID, cAppID, nBufSize
    
        hAppID=0
        THIS.ErrorCode = API_GetAppID( @hAppID )
    
        IF THIS.ErrorCode = 0
            nBufSize = GlobalSize( m.hAppID )
            cAppID = REPLICATE( CHR(0), nBufSize )
            MemToStr( @cAppID, hAppId, nBufSize )
    
            * note: converted from Unicode
            nBufSize = AT(CHR(0)+CHR(0), m.cAppID)
            IF nBufSize > 0
                cAppID = STRCONV(SUBSTR(m.cAppID, 1,;
                    m.nBufSize), 6)
            ENDIF
        ELSE
            cAppID = ""
        ENDIF
    
        IF hAppId <> 0
            = CoTaskMemFree( hAppId )
        ENDIF
    RETURN m.cAppID
    
    PROCEDURE declare
        DECLARE INTEGER GlobalSize IN kernel32 INTEGER hMem
        DECLARE CoTaskMemFree IN Ole32 INTEGER hMem
    
        DECLARE RtlMoveMemory IN kernel32 As MemToStr;
            STRING @, INTEGER, INTEGER
    
        DECLARE SHORT GetCurrentProcessExplicitAppUserModelID IN Shell32;
        AS API_GetAppID;
            INTEGER @AppID
    
        DECLARE SHORT SetCurrentProcessExplicitAppUserModelID IN Shell32;
        AS API_SetAppID;
            STRING AppID
    
    ENDDEFINE
    

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1937 bytes  
    Created: 2001-07-12 12:00:00  
    Modified: 2011-01-17 09:18:05  
    Visits in 7 days: 90  
    Listed functions:
    CoTaskMemFree
    GlobalSize
    Printer friendly API declarations
    My comment:
    Read Application User Model IDs article on MSDN.

    Legacy applications do not declare an explicit AppUserModelID. In that case, the system uses a series of heuristics to assign an internal AppUserModelID. Applications cannot retrieve a system-assigned AppUserModelID.

    If an application uses an explicit AppUserModelID, it must also assign the same AppUserModelID to all running windows or processes, shortcuts, and file associations. It must also use that AppUserModelID when customizing its Jump List through ICustomDestinationList, and in any calls to SHAddToRecentDocs.

    * * *
    An explicit application ID better be created before the main application window shows on. When VFP main window appears on the screen, the system has already assigned a default application ID to this VFP instance.

    After setting an explicit application ID, hide and show again VFP main window. That refreshes the jump list attached to the VFP taskbar icon. That simple:
    _screen.Visible = .F.
    _screen.Visible = .T.

    Another option is using SCREEN=OFF and COMMAND settings in VFP configuration file. The COMMAND should start a program that sets application ID and then turns the main window on.

    * * *
    Setting application ID for an individual VFP top-level form requires access to the IPropertyStore interface. Apparently it can be done only through writing an external library. A fragment of such FLL is shown in C++ section of this code sample.

    * * *
    If a window owns an explicit application ID, calling the GetProp with this window handle and property name "{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3} 5" returns valid data handle (IPropertyStore ?).
    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.36), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.158.253.14)
    11 sec.
    Function group: 'GDI+ Graphics'
    22 sec.Function: 'SearchPath'
    Function group: 'File Management'
    30 sec.Example: 'How to create non-blocking Winsock server'
    Language: 'C++'
    40 sec.Example: 'Testing serial ports'
    51 sec.Function: 'GetUrlCacheEntryInfo'
    Function group: 'Internet Functions (WinInet)'
    1.02 min.Example: 'Reading and setting system access privileges for the current process'
    1.18 min.Function: 'DrawAnimatedRects'
    1.35 min.Example: 'Winsock: retrieving the host information corresponding to a network address'
    1.5 min.Function: 'MAPISendDocuments'
    Function group: 'Simple MAPI'
    1.67 min.Example: 'Displaying bitmap using the AlphaBlend function'
    Google
    Advertise here!