Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Creating the Save dialog box to specify the drive, directory, and name of a file to save
How to download a file from HTTP server using URL Monikers functions
The window and its ancestors
Using mailslots to send messages on the network
Using named pipes for interprocess communication
Using the NetMessageBufferSend to send messages on the network
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Enumerating global and local group accounts on a server (WinNT/XP/2K)
Enumerating servers of the specified type (e.g. SQL Server) in the primary domain
GDI+: printing vertical text on VFP reports via generated images (VFP9)
Getting a bit more than the _CLIPTEXT offers
How to view icons stored in executable files (Icon Viewer) - II
Playing WAV sounds simultaneously
Pocket PC: custom RAPI class for operating with files and folders on mobile device
Pocket PC: custom RAPI class for operating with the Object Store Databases
Reading and setting Environment variables
Retrieving file information for the VFP executable running
Retrieving local computer and user names
Retrieving the User Datagram Protocol (UDP) listener table
Using the DrawText function
Accessing examples contained in this reference through Web Services
Creating an Open dialog box to specify the drive, directory, and name of a file to open (Shell32 version)
GDI+: Scrolling through large image using the mouse
How to enumerate logon sessions on local computer
Displaying bitmap using the AlphaBlend function

User rating: 9/10 (1 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 AlphaBlend function displays bitmaps that have transparent or semitransparent pixels.

See also:
  • Bitmap Class for Visual FoxPro application
  • Semi-transparent Form
  • Form Magnifier
  • GDI+: Color Transparency
  • #DEFINE LR_LOADFROMFILE 16
    #DEFINE AC_SRC_OVER 0
    #DEFINE AC_SRC_ALPHA 1
    #DEFINE AC_SRC_NO_ALPHA 2
    #DEFINE IMAGE_BITMAP 0
    #DEFINE SRCCOPY 0xCC0020
    #DEFINE BITMAP_STRU_SIZE 24
    
    DO declare
    
    LOCAL lcBitmap
    *lcBitmap = "C:\WinNT\system32\setup.bmp"
    lcBitmap = "C:\Windows\Forest.bmp"
    = LoadAndShowBitmap(lcBitmap, LR_LOADFROMFILE, 20,100)
    * end of main
    
    PROCEDURE LoadAndShowBitmap(lcBitmap, lnLoadOptions, lnX,lnY)
        LOCAL hBitmap
        hBitmap = LoadImage(0, lcBitmap, IMAGE_BITMAP,;
            0,0, lnLoadOptions)
    
        IF hBitmap <> 0
            = ShowBitmap(hBitmap, lnX,lnY)
            = DeleteObject(hBitmap)
        ELSE
            = MESSAGEBOX(lcBitmap + Chr(13) + Chr(13) +;
                "Check if this is a valid bitmap file.",;
                32, " Unable to load an image from file")
        ENDIF
    
    PROCEDURE ShowBitmap(hBitmap, lnX, lnY)
    *|typedef struct _BLENDFUNCTION {
    *|  BYTE     BlendOp;
    *|  BYTE     BlendFlags;
    *|  BYTE     SourceConstantAlpha;
    *|  BYTE     AlphaFormat;
    *|}BLENDFUNCTION, *PBLENDFUNCTION, *LPBLENDFUNCTION;
    
        LOCAL hWindow, hDC, hMemDC, lnWidth, lnHeight
        STORE 0 TO lnWidth, lnHeight
        = GetBitmapSize(hBitmap, @lnWidth, @lnHeight)
    
        hWindow = GetActiveWindow()
        hDC = GetWindowDC(hWindow)
    
        hMemDC = CreateCompatibleDC(hDC)
        = SelectObject(hMemDC, hBitmap)
    
        LOCAL lnAlphaBlend, lnResult,;
            lnBlendOp, lnBlendFlags, lnSrcConstAlpha, lnAlphaFormat
    
        lnBlendOp = AC_SRC_OVER  && always
        lnBlendFlags = 0         && always
        lnSrcConstAlpha = 48     && intensity, up to 255
        lnAlphaFormat = 0        && try AC_SRC_ALPHA on non-white background
    
        * assembling the BLENDFUNCTION structure 
        lnAlphaBlend = lnBlendOp +;
            BitLShift(lnBlendFlags, 8) +;
            BitLShift(lnSrcConstAlpha, 16) +;
            BitLShift(lnAlphaFormat, 24)
    
        lnResult = AlphaBlend(hDC, lnX,lnY, lnWidth,lnHeight,;
            hMemDC, 0,0, lnWidth,lnHeight,;
            lnAlphaBlend)
    
        IF lnResult = 0
        *  6 = The handle is invalid
        * 87 = The parameter is incorrect
            ? "Error:", GetLastError()
        ENDIF
    
        = DeleteDC(hMemDC)
        = ReleaseDC(hWindow, hDc)
    RETURN .T.
    
    FUNCTION GetBitmapSize(hBitmap, lnWidth, lnHeight)
        LOCAL lcBuffer
        lcBuffer = Repli(Chr(0), BITMAP_STRU_SIZE)
    
        IF GetObjectA(hBitmap, BITMAP_STRU_SIZE, @lcBuffer) <> 0
            lnWidth  = buf2dword(SUBSTR(lcBuffer, 5,4))
            lnHeight = buf2dword(SUBSTR(lcBuffer, 9,4))
           ENDIF
    
    FUNCTION buf2dword(lcBuffer)
    RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
        BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
        BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
        BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
    
    PROCEDURE declare
        DECLARE INTEGER CreateCompatibleDC IN gdi32 INTEGER hdc
        DECLARE INTEGER DeleteDC IN gdi32 INTEGER hdc
        DECLARE INTEGER GetActiveWindow IN user32
        DECLARE INTEGER GetWindowDC IN user32 INTEGER hWindow
        DECLARE INTEGER ReleaseDC IN user32 INTEGER hWindow, INTEGER dc
        DECLARE INTEGER DeleteObject IN gdi32 INTEGER hObject
        DECLARE INTEGER SelectObject IN gdi32 INTEGER hdc, INTEGER hObject
    
        DECLARE INTEGER LoadImage IN user32;
            INTEGER hinst, STRING lpszName, INTEGER uType,;
            INTEGER cxDesired, INTEGER cyDesired, INTEGER fuLoad
    
        DECLARE INTEGER GetObject IN gdi32 AS GetObjectA;
            INTEGER hgdiobj, INTEGER cbBuffer, STRING @lpvObject
    
        DECLARE INTEGER AlphaBlend IN Msimg32;
            INTEGER hDestDC, INTEGER x, INTEGER y,;
            INTEGER nWidth, INTEGER nHeight, INTEGER hSrcDC,;
            INTEGER xSrc, INTEGER ySrc, INTEGER nWidthSrc,;
            INTEGER nHeightSrc, INTEGER blendFunction
    
        DECLARE INTEGER GetLastError IN kernel32
    
    
    

    User rating: 9/10 (1 votes)
    Rate this code sample:
    • ~
    3476 bytes  
    Created: 2002-03-23 10:43:13  
    Modified: 2009-01-17 11:17:30  
    Visits in 7 days: 64  
    Listed functions:
    AlphaBlend
    CreateCompatibleDC
    DeleteDC
    DeleteObject
    GetActiveWindow
    GetLastError
    GetObject
    GetWindowDC
    LoadImage
    ReleaseDC
    SelectObject
    Printer friendly API declarations
    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-2014 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.68), 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.51.165)
    3 sec.Function: 'GlobalAlloc'
    Function group: 'Memory Management'
    10 sec.Function: 'NetShareEnum'
    Google
    Advertise here!