Using Win32 functions in Visual FoxPro Image Gallery
Device Context
..msdn
ChangeDisplaySettings
CreateCompatibleDC
CreateDC
DeleteDC
DeleteObject
EnumDisplayDevices
EnumDisplaySettings
GetDC
GetDeviceCaps
GetObject
GetObjectType
ReleaseDC
SelectObject
Code examples:
Bitmap Class for Visual FoxPro application
Configuring DEVMODE structure for a printer
Converting image file to .ICO file
Creating a device context for the specified printer
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Displaying bitmap using the AlphaBlend function
Drawing Windows predefined bitmaps using the LoadBitmap functions
GDI+: printing image file
GDI+: sending image of FoxPro form to printer
How to convert a bitmap file to monochrome format (1 bpp)
How to copy the image of a form to the Clipboard using Bitmap API functions
How to make a VFP form fading out when released (GDI version)
How to print a bitmap file
How to print FoxPro form
How to print FoxPro form -- II
How to print picture stored in enhanced-format metafile (*.emf)
How to put a horizontal text scrolling on the form (a news line)
How to put a vertical text scrolling on the form (a movie cast)
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Printing Image File, programmatically set print page orientation to landscape
Printing text with the Escape function
Retrieving graphic capabilities of default printer
Retrieving Printer Device Context using PrintDlg function
Splash Screen for the VFP application
Storing content of the Clipboard to a bitmap file
Storing screen shot of a form to bitmap file
Subclassing CommandButton control to create BackColor property
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Vertical Label control
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 (184.73.74.47)
4 sec.
7.23 hrs.Function: 'inet_ntoa'
Function group: 'Windows Sockets 2 (Winsock)'
 Function: 'waveOutReset'
Function group: 'Windows Multimedia'
10.24 hrs.Function: 'GetPrivateProfileSectionNames'
11.88 hrs.Example: 'Getting a bit more than the _CLIPTEXT offers'
 Function: 'InternalGetWindowText'
15.89 hrs.Function: 'OpenWaitableTimer'
16.12 hrs.Example: 'How to change the name and the size of the font in the MessageBox dialog'
18.83 hrs.Function: 'GdipInvertMatrix'
Function group: 'GDI+ Matrix'
18.84 hrs.Function: 'CloseDesktop'
Google
Advertise here!