New Foxes on the block

(reuters) - two big-eared foxes are pictured in the zoo of krefeld august 30, 2007. three big-eared foxes were born on may 9, 2007 in the zoo of krefeld. reuters/ina fassbender (germany)


ps: still waiting for alex feldstein's pictures of foxes !

link received from leandro tassinari


Great news for VFPX

bo durban has just posted the latest release of the gdiplusx library.

the most important part of the library has been converted to prg. there are several advantages using prg based classes, such as: enhanced speed and reduced size. here you can find more info about these changes. bo has given more details in his blog and in the codeplex messageboard.

now gdiplusx is beta ! the new 1.00b version can be downloaded from here

visit vfpx site on codeplex to see all great projects for vfp 

from now on, you must change your instantiation of gdiplusx call from:

addproperty(_screen, "system", newobject("xfcsystem","system.vcx"))
_screen.addproperty("system", newobject("xfcsystem","system.vcx"))


do ("system.prg")


btw, i'll try to update all my blog posts with this small change in the class initialization.


today i was really surprised when i read kevin ragsdale's latest blog post, about an eweek's post about the 25 most active projects at codeplex.

there we are ! 14th position !

check it by yourself: http://www.eweek.com/slideshow/0,1206,pg=0&s=25947&a=213883,00.asp


apart from these, there are some really great new projects to come...


have you already seen this video from kevin ragsdale ?



vfpx is a community effort to create open source add-ons for visual foxpro 9.0. sign up, sign in, and get involved today!!!


Convert BMP to Icon - Part 2

here's a code that converts a gdi+ bitmap or image object to an icon .ico file, keeping the same quality as the source image.

in a previous post, i showed the simplest way to convert a bitmap to icon, using the olecreatepictureindirect api function. with very few code we could get .ico files, but unfortunately, the results were always 4bpp (bits per pixel) images, with 16 colors. i suspect that windows didn't provide support for more than 16 colors. in a short research on the web, i found the following tip in foxyclasses tips from cetin basoz, that gives a possible reason for the 16 color icon: "here's the trick when you make your own icons: the images used must be 16 colors only. if you use 256 colors, the fox logo icon will be shown instead of your own! you must also include the correct size images in the icon". this seems to be an old tip, because in my tests vfp forms work nice with icons of more than 16 colors.

fortunately, vfp allows us to use up to 32bpp colors, so we can convert any image to an icon. the limitation is that vfp supports only 16x16 or 32x32 pixel images.

special thanks to sergey karimov

my starting point was a code from sergey karimov, that he posted in ut last year. his original code dealt with physical bmps, converting them to .ico files. but my real need was to do this without additional disk access.

the main source of .ico information that i found on the web was a great article from john hornick, in msdn, "icons in win32". to create my icons, all i had to do was to follow carefully all the instructions provided there, obviously with a great help from anatolyi mogylevetz, in some of his great articles: "retrieving information about the specified icon" and "converting image file to .ico file".

below is my bmp2ico function, that creates high quality .ico physical files. in the first part of the code below you'll find the caller program, that also resizes the image to 32x32 pixels. the caller code is very easy to understand, and you can adapt it to fit your needs. but the main part is much more complicated, because it needs to create many c structures following the instructions from "icons in win32".


requires vfp9 and gdiplusx to run. 
please make sure that you have the latest version!


local lcpict, lciconfile
lcpict =
if empty(lcpict)
lciconfile = "c:\_" + juststem(justfname(lcpict)) + ".ico"

* make sure we have initialized the gdiplusx library
if vartype(_screen.system) <> "o"
   do locfile("system.app")

local lobmp as xfcbitmap
lobmp = _screen.system.drawing.

local loresized as xfcbitmap
loresized = lobmp.getthumbnailimage(32,32)

=bmp2ico(loresized, lciconfile, .t.)
* function: bmp2ico
* parameters: tobmp (xfcimage), tcfilename
* related articles:
* icons in win32 - by john hornick
* retrieving information about the specified icon http://www.news2news.com/vfp/?example=206&function=331
* converting image file to .ico file http://www.news2news.com/vfp/?example=503&function=331
* special thanks:
* sergey karimov, ontario, canada
* anatolyi mogylevetz

function bmp2ico(tobmp as xfcbitmap, tcfilename as character, tlchangepixformat as boolean)

* make sure we have initialized the gdiplusx library
if vartype(_screen.system) <> "o"
   do locfile("system.app")
hicon, lcbuffer, lnwidth, lnheight, lnbitsperpixel
local lhcolorbitmap, lhmaskbitmap
local lobmp as xfcbitmap
lnwidth = tobmp.
lnheight = tobmp.height

if tlchangepixformat
* convert the original bitmap to ensure better quality and compatibility
   lobmp = _screen.system.drawing.bitmap.new(tobmp, lnwidth, lnheight) && this is to transform the bitmap to 32bppargb
   lnbitsperpixel = 32 && 32bpp argb
   lobmp = tobmp
   lnbitsperpixel = loresized.getpixelformatsize(loresized.pixelformat)
* obtain hicon from bitmap
hicon = lobmp.gethicon()
* api declarations needed
declare short destroyicon in user32 integer hicon
declare integer geticoninfo in user32 integer hicon, string @piconinfo
declare integer getdibits in gdi32;
   integer hdc, integer hbmp, integer ustartscan,;
   integer cscanlines, integer lpvbits, string @lpbi, integer uusage

declare integer createcompatibledc in gdi32 integer hdc
declare integer deletedc in gdi32 integer hdc

declare integer releasedc in user32 integer hwnd, integer hdc
declare integer
getwindowdc in user32 integer hwnd
rtlzeromemory in kernel32 as zeromemory integer dest, integer numbytes

declare integer selectobject in gdi32 integer hdc, integer hobject
declare integer deleteobject in gdi32 integer hobject

declare integer globalfree in kernel32 integer hmem
declare integer globalalloc in kernel32 integer wflags, integer dwbytes

* iconinfo structure
*| typedef struct _iconinfo {
*| bool ficon; 0:4
*| dword xhotspot; 4:4
*| dword yhotspot; 8:4
*| hbitmap hbmmask; 12:4
*| hbitmap hbmcolor; 16:4
*| } iconinfo; total bytes = 20

#define iconinfo_size 20
lcbuffer =
replicate(chr(0), iconinfo_size)
= geticoninfo(hicon, @lcbuffer)
lhcolorbitmap =
lhmaskbitmap =
= destroyicon(hicon)
* dib bitmapinfoheader.
* only the following members are used: bisize, biwidth, biheight, biplanes, bibitcount, bisizeimage
*!* typedef struct tagbitmapinfoheader{
*!* dword bisize;
*!* long biwidth;
*!* long biheight;
*!* word biplanes;
*!* word bibitcount;
*!* dword bicompression;
*!* dword bisizeimage;
*!* long bixpelspermeter;
*!* long biypelspermeter;
*!* dword biclrused;
*!* dword biclrimportant;
*!* } bitmapinfoheader, *pbitmapinfoheader

#define dib_rgb_colors 0
define rgbquad_size 4
define bhdr_size 40
define gmem_fixed 0
define bi_rgb 0
local lcbihdr, lcbinfo, lcrgbquad, lnrgbquadsize, lpbitsarray, lnbitssize1, lnbitssize2
local lnbytesperscan
* obtain the xor bitmap
m.lnbytesperscan = int((m.lnwidth * m.lnbitsperpixel)/8)
if mod(m.lnbytesperscan, 4) # 0
   m.lnbytesperscan = m.lnbytesperscan + 4 -
mod(m.lnbytesperscan, 4)

m.lnbitssize1 = m.lnheight * m.lnbytesperscan
m.lcbihdr =
bintoc(bhdr_size ,"4rs") + ; && bisize
   bintoc(m.lnwidth,"4rs") + ; && biwidth
   bintoc(m.lnheight, "4rs") + ; && biheight
   bintoc(1, "2rs") + ; && biplanes 
   bintoc(lnbitsperpixel, "2rs") + ; && bibitcount 
   bintoc(bi_rgb, "4rs") + ; && bicompression
   bintoc(lnbitssize1, "4rs") + ; && bisizeimage
   replicate(chr(0), 16)

if m.lnbitsperpixel <= 8
   m.lnrgbquadsize = (2^m.lnbitsperpixel) * rgbquad_size
   m.lcrgbquad =
replicate(chr(0), m.lnrgbquadsize)
   m.lcrgbquad = ""

m.lcbinfo = m.lcbihdr + m.lcrgbquad
m.lpbitsarray = globalalloc (gmem_fixed, m.lnbitssize1)
= zeromemory (m.lpbitsarray, m.lnbitssize1)
local lhdc, lhmemdc
m.lhdc = getwindowdc(
m.lhmemdc = createcompatibledc(m.lhdc)
= releasedc (
_screen.hwnd, m.lhdc)
= selectobject(lhmemdc, lhcolorbitmap)
= getdibits (m.lhmemdc, m.lhcolorbitmap, 0, m.lnheight, m.lpbitsarray , @lcbinfo, dib_rgb_colors)
local lqcolorbinary, lqmaskbinary
m.lqcolorbinary =
sys(2600, m.lpbitsarray, m.lnbitssize1)
= deleteobject (m.lhcolorbitmap)
= globalfree(m.lpbitsarray)
* obtain the and mask
* the icand member contains the bits for the monochrome and mask.
* the number of bytes in this array is determined by examining the icheader member, and assuming 1bpp.
* the dimensions of this bitmap must be the same as the dimensions of the xor mask.
* the and mask is applied to the destination using the and operation, to preserve or remove destination pixels before applying the xor mask.

local lpbitsarray2, lcbinfo2
m.lnbitssize2 = m.lnheight *
int((m.lnwidth * 1)/8) && 1bpp
m.lpbitsarray2 = globalalloc (gmem_fixed, m.lnbitssize2)
= zeromemory (m.lpbitsarray2, m.lnbitssize2)
= selectobject(lhmemdc, lhmaskbitmap)
m.lcbinfo2 =
bintoc(bhdr_size ,"4rs") + ; && bisize
   bintoc(m.lnwidth,"4rs") + ; && biwidth
   bintoc(m.lnheight, "4rs") + ; && biheight
   bintoc(1, "2rs") + ; && biplanes 
   bintoc(1, "2rs") + ; && chr(int(1/256))) + && bibitcount 
   bintoc(bi_rgb, "4rs") + ; && bicompression
   bintoc(lnbitssize2, "4rs") + ; && bisizeimage
   replicate(chr(0), 16)

= getdibits (m.lhmemdc, m.lhmaskbitmap, 0, m.lnheight, m.lpbitsarray2 , @lcbinfo2, dib_rgb_colors)
m.lqmaskbinary =
sys(2600, m.lpbitsarray2, m.lnbitssize2)
= deleteobject (m.lhmaskbitmap)
= globalfree(m.lpbitsarray2)
= deletedc (m.lhmemdc)
local lcicondir, lnoffset

*!* typedef struct
*!* {
*!* word idreserved; // reserved (must be 0)
*!* word idtype; // resource type (1 for icons)
*!* word idcount; // how many images?
*!* icondirentry identries[1]; // an entry for each image (idcount of 'em)
*!* } icondir, *lpicondir

lcicondir = bintoc(0, "2rs") + ; && 0 reserved
   bintoc(1, "2rs") + ; && 2 type
   bintoc(1, "2rs") && 4 number of icons in this file

lnoffset = len(lcicondir)+16

*!* typedef struct
*!* {
*!* byte bwidth; // width, in pixels, of the image
*!* byte bheight; // height, in pixels, of the image
*!* byte bcolorcount; // number of colors in image (0 if >=8bpp)
*!* byte breserved; // reserved ( must be 0)
*!* word wplanes; // color planes
*!* word wbitcount; // bits per pixel
*!* dword dwbytesinres; // how many bytes in this resource?
*!* dword dwimageoffset; // where in the file is this image?
*!* } icondirentry, *lpicondirentry

local lncolors, lcicondirentry
lncolors =
iif(lnbitsperpixel > 8, 0, 4*2^lnbitsperpixel)
lcicondirentry =
chr(lnwidth) + ; && 0 width of the image, in pixels
   chr(lnheight) + ; && 1 height of image, in pixels (or & and bmps)
   chr(lncolors) + ; && 2 number of colors in image (0 if >=8bpp)
   chr(0) + ; && 3 reserved
   bintoc(1,"2rs") + ; && 4 number of planes
   bintoc(lnbitsperpixel,"2rs") && 6 bits per pixel

lcbinfo = stuff(lcbinfo,9,1,chr(lnheight*2)) && height of img, in pixels (or & and bmps)
&& the biheight member of the icheader structure represents the combined height of the xor and and masks
lcbinfo = stuff(lcbinfo,21,4, bintoc((lnbitssize1 + lnbitssize2), "4rs")) && size of image (or & and bitmaps)

*!* typdef struct
*!* {
*!* bitmapinfoheader icheader; // dib header
*!* rgbquad iccolors[1]; // color table
*!* byte icxor[1]; // dib bits for xor mask
*!* byte icand[1]; // dib bits for and mask
*!* } iconimage, *lpiconimage

lqbinary = lcbinfo + lqcolorbinary + lqmaskbinary
lcicondirentry = lcicondirentry +
bintoc(len(lqbinary),"4rs") + ; && 8 size of img area
   bintoc(lnoffset,"4rs") && 12 offset to image area

* finally, save the icon to the disk

* this still needs some error checking !
local lhfile
if lhfile<1
messagebox("cannot create file " + tcfilename + " !")
   return .f.

=fwrite(lhfile, (lcicondir + lcicondirentry))
fwrite(lhfile, lqbinary)



here are some of the links that i often visit regarding vfp9 sp2 and sedna.

the official microsoft visual foxpro 9.0 service pack 2 and "sedna" - beta download page 

according to microsoft. "this download contains the beta release for microsoft visual foxpro 9.0 sp2 and the "sedna" add-ons. this release has two parts: the sedna beta download contains six components: vistadialogs4com, upsizing wizard, data explorer, net4com, my for vfp and vs 2005 extension for vfp. the vfp 9.0 sp2 beta download contains a patch that can be applied to vfp 9.0 or vfp 9.0 sp1. in addition to fixes to the core product, this patch contains significant enhancements to the reporting features."



neither sp2 ctp nor sp2 beta have uninstallers. so, have in mind that you'll need to reinstall vfp9 when you want to update or go back to sp1 for any reason.

it is not recommended to use this new version in production. it's only for test purposes, and to help ms to develop faster the sp2 and sedna. ms also encourages us to send suggestions and report errors.


before the installation

before you install the beta version, i highly recommend following the great tips that rick schummer offers in his blog, vfp 9 sp2 and sedna ctp (not production) tip . if you follow these rick's tips, you'll be able to revert the sp@ installation without having to uninstall vfp entirely.

some people found some installation problems, and doug hennig brings some tips: "fix for sedna beta installation issue


some new features

  • my namespace - doug hennig, the author of this superb class, wrote a great article for code magazine: "the my namespace in sedna". if you want to play with "my" without installing the sp2-sedna beta, you can download it directly from doug hennig's site, from here.  to better understand how "my" works, i strongly recommend you reading his great article: "favorites for intellisense"




to rotate text in reports all you'll need to do is: select your field, right-click, select properties - advanced tab change the roration angle in the spinner. below, some screenshots from lisa nicholls website showing how to use this feature:


some more information, in craig bailey's blog: http://blog.craigbailey.net/2006/10/vfp-vfp9-sp2-ctp-video-by-lisa-and_28.html

i'm already using in production all the new features of the vfp9 sp2 reporting inovations, following colin nicholls advice. he says that all the modifications regarding reports are finished and almost "bug free". so, i'm using a "hybrid" vfp9 version at this moment, with great success. the report new features prepared by lisa and colin nicholls are already very stable, so i just pasted the 3 report app's responsible for reporting - reportbuilder.app , reportoutput.app and reportpreview.app - to my vfp9sp1 home() folder and am already taking benefits from the new report enhancements. to ease things for you if you don't want to install the beta version but still want to try the new report features, i've uploaded these 3 files, that you can download from here. just unzip and save these 3 files to your home() directory, and have fun !

  • sedna and windows vista: craig boyd, doug hennig and rick strahl seem to be working hard testing vfp under vista. here are some cool links

craig boyd: "visual foxpro: sedna and windows vista"  and  "xaml in visual foxpro"

doug hennig has been helping people to solve some installations problems: it's worth checking these links from foxite threads, if you're experiencing some kinds of problems:  http://www.foxite.com/archives/installation-problem-on-vista-0000129165.htm and  http://www.foxite.com/archives/where-to-put-the-data-on-vista-0000137073.htm


calvin hsia links:

add a manifest to control your application vista uac behavior

foxpro menu items, combo boxes not refreshing selected item under aero in vista

fix your forms to paint borders correctly under vista aero

windows vista aero borderstyle paint problem as non administrator

fun with vista aero using the dwmextendframeintoclientarea

vista aero dwm seems to optimize out gdi paint calls

create your own flip task bar with live thumbnails using vista desktop window manager dwm

what is vista aero?

write fox code in visual studio that interacts with your vb.net code

help->about->system info doesn't work on vista

dll image base addresses are the same in xp, different on vista