Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving the name and type of all available RAS-capable devices
Starting external program from VFP and waiting for its termination
The window and its ancestors
Writing to INI file
Class library providing access to the System Registry
Obtaining provider name for a specific type of network
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Converting a hexadecimal string to an integer
Creating a unique filename based on existing filename
Displaying dimmed window behind VFP top-level form
How to browse and connect to printers on a network (WinNT)
Reading VFP settings from the Windows Registry
Retrieving file information for the VFP executable running
Retrieving list of available disk drives
Accessing examples contained in this reference from a VFP application
Converting command-line string to a set of Unicode argument strings (WinNT only)
How to download this reference`s archive through WinInet functions using InternetOpenUrl
Listing child windows for the Windows desktop
Obtaining list of tables stored in an ODBC Data Source
Reading header information from AVI file
The DetectAutoProxyUrl function identifies the auto-config script location
Winsock: retrieving the standard host name and IP address for the local machine
How to upload a local file to FTP server using FtpPutFile
Semi-transparent Form
Drawing Windows predefined bitmaps using the LoadBitmap functions

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:

 
DO decl
 
PUBLIC objForm
objForm = CreateObject("Tform")
objForm.Visible = .T.
 
DEFINE CLASS Tform As Form
    Caption = "Drawing Windows predefined bitmaps"
    Width=350
    Height=150
    AutoCenter = .T.
 
    ADD OBJECT cmb AS ComboBox WITH;
    Left=15, Top=15, Width=230, Style=2, ColumnCount=2,;
    BoundColumn=2, ColumnWidths="160,60"
 
    ADD OBJECT lbl1 As Label WITH;
    Left=15, Top=ThisForm.Height-80, Width=250,;
    Height=50, WordWrap=.T., BackStyle=0,;
    Caption="Select predefined bitmap to display it " +;
        "on the main VFP window"
 
PROCEDURE  Init
    WITH THIS.cmb
        .ListIndex = 1
        .InteractiveChange
    ENDWITH
 
PROCEDURE  cmb.InteractiveChange
    LOCAL lnBitmapType, hBitmap
    lnBitmapType = Val(THIS.Value)
 
    hBitmap = LoadBitmap(0, lnBitmapType)
    IF hBitmap <> 0
        = ShowBitmap (hBitmap, 100,200)
        = DeleteObject(hBitmap)
    ENDIF
 
PROCEDURE  cmb.Init
    THIS.NewItem ("OBM_BTNCORNERS",   32758)
    THIS.NewItem ("OBM_BTSIZE",       32761)
    THIS.NewItem ("OBM_CHECK",        32760)
    THIS.NewItem ("OBM_CHECKBOXES",   32759)
    THIS.NewItem ("OBM_CLOSE",        32754)
    THIS.NewItem ("OBM_COMBO",        32738)
    THIS.NewItem ("OBM_DNARROW",      32752)
    THIS.NewItem ("OBM_DNARROWD",     32742)
    THIS.NewItem ("OBM_DNARROWI",     32736)
    THIS.NewItem ("OBM_LFARROW",      32750)
    THIS.NewItem ("OBM_LFARROWD",     32740)
    THIS.NewItem ("OBM_LFARROWI",     32734)
    THIS.NewItem ("OBM_MNARROW",      32739)
    THIS.NewItem ("OBM_OLD_CLOSE",    32767)
    THIS.NewItem ("OBM_OLD_DNARROW",  32764)
    THIS.NewItem ("OBM_OLD_LFARROW",  32762)
    THIS.NewItem ("OBM_OLD_REDUCE",   32757)
    THIS.NewItem ("OBM_OLD_RESTORE",  32755)
    THIS.NewItem ("OBM_OLD_RGARROW",  32763)
    THIS.NewItem ("OBM_OLD_UPARROW",  32765)
    THIS.NewItem ("OBM_OLD_ZOOM",     32756)
    THIS.NewItem ("OBM_REDUCE",       32749)
    THIS.NewItem ("OBM_REDUCED",      32746)
    THIS.NewItem ("OBM_RESTORE",      32747)
    THIS.NewItem ("OBM_RESTORED",     32744)
    THIS.NewItem ("OBM_RGARROW",      32751)
    THIS.NewItem ("OBM_RGARROWD",     32741)
    THIS.NewItem ("OBM_RGARROWI",     32735)
    THIS.NewItem ("OBM_SIZE",         32766)
    THIS.NewItem ("OBM_UPARROW",      32753)
    THIS.NewItem ("OBM_UPARROWD",     32743)
    THIS.NewItem ("OBM_UPARROWI",     32737)
    THIS.NewItem ("OBM_ZOOM",         32748)
    THIS.NewItem ("OBM_ZOOMD",        32745)
 
PROTECTED PROCEDURE cmb.NewItem(lcName, lnValue)
    THIS.AddItem(lcName)
    THIS.List(THIS.ListCount, 2) = STR(lnValue)
 
ENDDEFINE
 
* --------------------------------------------------------------
PROCEDURE  ShowBitmap (hBitmap, lnX, lnY)
#DEFINE SRCCOPY  13369376
 
    * clearing the screen
    ACTI SCREEN
    CLEAR
 
    * a little break needed for the VFP to properly react
    = INKEY(0.1)
 
    LOCAL hWnd, hDC, hMemDC, lnWidth, lnHeight
 
    STORE 0 TO lnWidth, lnHeight
    = GetBitmapSize (hBitmap, @lnWidth, @lnHeight)
 
    hWnd = GetActiveWindow()
    hDC = GetWindowDC (hWnd)
 
    hMemDC = CreateCompatibleDC(hDC)
    = SelectObject (hMemDC, hBitmap)
 
    = BitBlt (hDC, lnX,lnY, lnWidth,lnHeight,;
        hMemDC, 0,0, SRCCOPY)
 
    = DeleteDC(hMemDC)
    = ReleaseDC (hWnd, hDc)
 
FUNCTION  GetBitmapSize (hBitmap, lnWidth, lnHeight)
#DEFINE BITMAP_STRU_SIZE   24
    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)) + ;
    Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
    Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
    Asc(SUBSTR(lcBuffer, 4,1)) * 16777216
 
PROCEDURE  decl
    DECLARE INTEGER LoadBitmap IN user32;
        INTEGER hInstance, INTEGER lpBitmapName
 
    DECLARE INTEGER CreateCompatibleDC IN gdi32 INTEGER hdc
    DECLARE INTEGER DeleteDC IN gdi32 INTEGER hdc
    DECLARE INTEGER ReleaseDC IN user32 INTEGER hwnd, INTEGER dc
    DECLARE INTEGER GetActiveWindow IN user32
    DECLARE INTEGER GetWindowDC IN user32 INTEGER hwnd
    DECLARE INTEGER DeleteObject IN gdi32 INTEGER hObject
    DECLARE INTEGER SelectObject IN gdi32 INTEGER hdc, INTEGER hObject
 
    DECLARE INTEGER GetObject IN gdi32 AS GetObjectA; 
        INTEGER hgdiobj, INTEGER cbBuffer, STRING @lpvObject
 
    DECLARE INTEGER BitBlt IN gdi32;
        INTEGER hDestDC, INTEGER x, INTEGER y,;
        INTEGER nWidth, INTEGER nHeight, INTEGER hSrcDC,;
        INTEGER xSrc, INTEGER ySrc, INTEGER dwRop
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
4407 bytes  
Created: 2002-01-16 21:31:50  
Modified: 2008-12-03 15:26:21  
Visits in 7 days: 141  
Listed functions:
BitBlt
CreateCompatibleDC
DeleteDC
DeleteObject
GetActiveWindow
GetObject
GetWindowDC
LoadBitmap
ReleaseDC
SelectObject
Printer friendly API declarations
My comment:
MSDN: An application can use the LoadBitmap function to access predefined bitmaps. To do so, the application must set the hInstance parameter to NULL and the lpBitmapName parameter to one of the predefined values.

Note that the use of LoadBitmap to load OEM bitmaps is deprecated and is supported only for backwards compatibility. New applications should use DrawFrameControl to draw system elements.
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 (23.20.196.179)
13.58 min.Function: 'ReleaseMutex'
13.68 min.Function: 'EnumPrintProcessorDatatypes'
Function group: 'Printing and Print Spooler'
3.87 hrs.Example: 'Using File Mapping for enumerating files opened by Visual FoxPro'
 Function: 'SHEnumKeyEx'
Function group: 'Registry'
5.33 hrs.Example: 'GDI+: printing image file'
 Example: 'Enumerating data formats currently available on the clipboard'
11.65 hrs.Function: 'CeRapiInitEx'
Function group: 'Remote Application Programming (RAPI)'
 Function: 'GetRgnBox'
18.58 hrs.Example: 'Simple MAPI: how to pick an email recipient from Outlook Express address book'
 Example: 'How to assemble an array of strings and pass it to external function'
Google
Advertise here!