Silvio , Good news

New code for Icons ...
Change this function in gdiplus.cpp ...
HB_FUNC( GDIPLUSIMAGEFROMICO )
{
HICON hIcon = ( HICON ) hb_parnl( 1 ) ;
ICONINFO ii ;
GetIconInfo(hIcon, &ii);
BITMAP bmp;
GetObject(ii.hbmColor, sizeof(bmp), &bmp);
Bitmap * temp = new Bitmap(ii.hbmColor, NULL);
BitmapData bmpData;
int nWidth = temp->GetWidth() ;
int nHeight = temp->GetHeight() ;
Rect rect(0, 0, nWidth, nHeight);
temp->LockBits(&rect, ImageLockModeRead, temp->GetPixelFormat(), &bmpData );
byte* imgPtr = (byte*)(bmpData.Scan0) ;
int bheight = bmpData.Height;
int bwidth = bmpData.Width;
int bstride = bmpData.Stride;
Bitmap *original = new Bitmap( bwidth, bheight, bstride, PixelFormat32bppARGB, imgPtr );
temp->UnlockBits( &bmpData ) ;
Bitmap* newImage = new Bitmap( nWidth, nHeight, PixelFormat32bppARGB ) ; // original->GetPixelFormat() );
Graphics * graphics = new Graphics( newImage );
graphics->DrawImage( original ,0, 0, nWidth, nHeight);
delete temp ;
delete original ;
hb_retnl( ( HB_LONG ) newImage ) ;
}
Add this code ad end of gdiplius.cpp ... ( is c++ code )
ICON_EXEREAD function has 2 parameters name file , and Size ..
0->LARGE 32x32
1->SMALL 16x16
2->48x48
3-> These images are the size specified by GetSystemMetrics called with SM_CXSMICON and GetSystemMetrics called with SM_CYSMICON.
4-> Windows Vista and later. The image is normally 256x256 pixels.
#include <commctrl.h>
#include <commoncontrols.h>
HB_FUNC( ICON_EXEREAD )
{
HICON hico ;
SHFILEINFO sfi = { 0 };
LPCTSTR pName = ( LPCTSTR ) hb_parc( 1 ) ;
SHGetFileInfo( pName , -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX );
HIMAGELIST* imageList;
HRESULT hResult = SHGetImageList( hb_parni( 2 ) , IID_IImageList2, (void**)&imageList );
if(hResult == S_OK) {
((IImageList*)imageList)->GetIcon(sfi.iIcon,ILD_NORMAL|ILD_TRANSPARENT , &hico);
}
#ifndef _WIN64
hb_retnl( ( LONG ) hico );
#else
hb_retnll( ( LONGLONG ) hico );
#endif
}
And test ...
#include "FiveWin.ch"
Function Main ()
local ownd
local oimage
DEFINE WINDOW oWnd TITLE "Testing GDI+ Class" FROM 5,5 TO 400, 600 PIXEL
@ 20,2 button "crear" size 40,20 pixel Action imagenfromico(oimage )
@ 20 ,130 Button "salir" Action ownd:end() size 40,20 pixel
@ 3, 38 BITMAP oimage FILE "" size 220,220 of oWnd
ACTIVATE WINDOW oWnd
Return (nil)
Function imagenfromico(oImage )
local cFile:= cGetfile("coge","*.*")
local ico := ICON_EXEREAD( cFile, 4 ) // for ico, dll and exe files
GDIBmpFromHIcon( ico, oImage , oImage:Super:nWidth(), oImage:Super:nHeight() )
Return nil
Function GDIBmpFromHIcon( hIcon , oImage , nWidth, nHeight )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:resize( nWidth,nHeight)
DeleteObject( oImage:hBitmap )
oImage:hBitmap := oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oImage:Refresh()
ogbmp:end()
Return nil