Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Creating a file, then moving it to another destination
Enumerating connections made to a shared resource for the local computer (WinNT only)
Initiating Inet connection using a modem
One more way to retrieve environment strings
Opening access to the Microsoft Internet functions for the application
Programmatically removing submenus from VFP main menu
Retrieving the state of your Internet connection
Retrieving various system metrics
Setting the Window Region for a form
How to hide your program from the Close Program dialog (Win9* only)
Simple MAPI: how to resolve a name to unique address list entry
Listing device drivers in the system: load addresses, names
Setting and retrieving the double-click time for the mouse
Winsock: how to retrieve the protocol information corresponding to a protocol name
Another way to go online (it is not about choosing an ISP)
How to retrieve list of system DSNs (Data Source Name) with parameters
Reading current hardware profile
Using the IsWindowEnabled function
The original LoadPicture() function in VFP returns valid handles to bitmaps, icons, cursors, and metafiles
Validating URLs using moniker functions
Copying strings through the global memory block
Current keyboard type
Enumerating MIDI output devices
Retrieving country-specific dialing information from the Windows Telephony list of countries
GDI+: loading image file, drawing on it, saving the result to another file

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:
The example shows how to load an image file, put semi-transparent frame with a text on it, and save the result to another file.

Make sure the source and target file names are valid. The source file can be in any of graphics formats supported by the GDI+: BMP, GIF, JPG, TIF, EMF...

The code is based on custom GDI+ class. Download the class module first and save it in gdiplus.prg file.
SET PROCEDURE TO gdiplus ADDITIVE

PRIVATE gdiplus, src, dst, himage
gdiplus = CREATEOBJECT("gdiplusinit")

src = CREATEOBJECT("gdiimage", "c:\windows\forest.bmp")
dst = CREATEOBJECT("gdiimage", src)

IF dst.imgtype=0 OR VARTYPE(dst.graphics) <> "O"
    ? "Error code:", dst.errorcode
    RETURN
ENDIF

LOCAL gdibrush, gdipen, fnt
STORE 0 TO gdibrush, gdipen

* creating brush, pen and font objects
* note that the alpha channel is defined for the solid brush,
* which creates semi-transparent fill
= GdipCreateSolidFill(ARGB(255,255,255, 128), @gdibrush)
= GdipCreatePen1(ARGB(220,220,255), 2, 2, @gdipen)
fnt = CREATEOBJECT("gdifont", "Arial", 24, 1, ARGB(220,220,255))

* drawing filled semi-transparent rectangle with a border
= GdipFillRectangle(dst.graphics.graphics, gdibrush, 5,5, 160,50)
= GdipDrawRectangle(dst.graphics.graphics, gdipen, 5,5, 160,50)

* printing text
= dst.graphics.DrawText("SAMPLE",;
    fnt, 10,10, dst.imgwidth-10, 0)

* releasing system resources
= GdipDeletePen(gdipen)
= GdipDeleteBrush(gdibrush)

* creating drawing surface based on main VFP window
LOCAL gr
gr = CREATEOBJECT("graphics", _screen.HWnd)

gr.DrawImage(src, 20,20)
gr.DrawImage(dst, 20+src.imgwidth+5,20)

*= dst.SaveToFile("d:\temp\tmp.bmp")

* end of main



User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1294 bytes  
Created: 2004-07-22 12:43:04  
Modified: 2005-10-13 10:33:55  
Visits in 7 days: 191  
Listed functions:
Printer friendly API declarations
My comment:
The transparency is controlled by the alpha-channel value. In this particular example a semi-transparent solid brush is used.

#kwd: sln_gdiplus.
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.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (23.22.136.56)
19 sec.Function: 'LookupPrivilegeDisplayName'
36 sec.Example: 'Disabling mouse and keyboard input for the main VFP window (with the app still running)'
53 sec.Example: 'Opening the Page Setup dialog box to specify the attributes of a printed page'
1.2 min.Function: 'MonitorFromWindow'
1.5 min.Function: 'GetActiveWindow'
1.82 min.Function: 'CeDeleteRecord'
2.15 min.Function: 'FatalAppExit'
2.47 min.Function: 'DrawIcon'
2.77 min.Example: 'How to enumerate terminal servers within the specified Windows domain'
3.13 min.Solution: 'Extended MessageBox Library (assembly) for .NET'
Google
Advertise here!