ico := ICON_EXEREAD( cFile, 4 )
GDIBmpFromHIcon( ico, oImagePreview , oImagePreview:Super:nWidth(), oImagePreview:Super:nHeight() )
Function GDIBmpFromHIcon( hIcon , oImagePreview , nWidth, nHeight )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:resize( nWidth,nHeight)
oImagePreview:SetSource(oGBmp:GetGDIHbitmap() )
oImagePreview:Refresh()
Return nil
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:save( "icono.png") // is posible png,jpg,bmp,tif
oImagePreview:SetSource("icono.png" )
oImagePreview:Refresh()
ferase( "icono.png" )
ogbmb:end()
Function GDIBmpFromHIcon( hIcon , oImagePreview , nWidth, nHeight )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:save( "icono.png") // is posible png,jpg,bmp,tif
oImagePreview:SetSource("icono.png" )
ogbmp:resize( nWidth,nHeight)
oImagePreview:Refresh()
ferase( "icono.png" )
ogbmp:end()
Return ni
Application
===========
Path and name: C:\Work\Prg\test_allegati\Allegati.Exe (32 bits)
Size: 3,786,752 bytes
Compiler version: Harbour 3.2.0dev (r1703231115)
FiveWin version: FWH 17.12
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 01/08/18, 20:50:53
Error description: Error BASE/1004 Message not found: GDIBMP:END
Args:
[ 1] = O GDIBMP
Stack Calls
===========
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => GDIBMP:ERROR( 0 )
Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
Called from: ../../../tobject.prg => GDIBMP:MSGNOTFOUND( 0 )
Called from: ../../../tobject.prg => GDIBMP:END( 0 )
Called from: Source\test.prg => GDIBMPFROMHICON( 649 )
Called from: Source\test.prg => INSERISCIALLEGATI( 241 )
Called from: Source\test.prg => (b)ALLEGATI( 180 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 714 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 906 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 296 )
Called from: Source\test.prg => ALLEGATI( 180 )
Called from: Source\test.prg => TEST( 56 )
Function GDIBmpFromHIcon( hIcon , oImagePreview , nWidth, nHeight )
Local hBmp
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:resize( nWidth,nHeight)
if oImagePreview:cargo == NIL
oImagePreview:cargo = oImagePreview:GetHBitmap()
else
DeleteObject( oImagePreview:GetHBitmap() )
endif
hBmp := oGBmp:GetGDIHbitmap()
oImagePreview:SetSource( hBmp )
oImagePreview:Refresh()
Return nil
#include "fivewin.ch"
//----------------------------------------------------------------------------//
function Main()
local aImages, oWnd, oFont, oBrush, oBrw, oImage
FW_SetUnicode( .t. )
HB_SETCODEPAGE( "UTF8" ) // Harbour (not xHarbour) to display unicode filenames
aImages := ReadFolder()
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
DEFINE BRUSH oBrush FILE "..\bitmaps\backgrnd\stone.bmp"
DEFINE WINDOW oWnd
oWnd:SetFont( oFont )
msginfo( len( aImages ) )
DEFINE BUTTONBAR oWnd:oBar SIZE 100,32 2007
SET MESSAGE OF oWnd TO "" 2007
DEFINE BUTTON OF oWnd:oBar PROMPT "Center" CENTER ACTION ( oImage:Center(), oImage:SetFocus() )
DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Width" CENTER ACTION ( oImage:FitWidth(), oImage:SetFocus() )
DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Height" CENTER ACTION ( oImage:FitHeight(), oImage:SetFocus() )
DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Rect" CENTER ACTION ( oImage:FitRect(), oImage:SetFocus() )
DEFINE BUTTON OF oWnd:oBar PROMPT "Rotate" CENTER ACTION ( oImage:Rotate(), oImage:SetFocus() )
DEFINE BUTTON OF oWnd:oBar PROMPT "Zoom" CENTER ACTION ( MsgInfo( "Zoom/Unzoom with Mouse Wheel" ), oImage:SetFocus() )
DEFINE BUTTON OF oWnd:oBar PROMPT "Pan/Move" CENTER ACTION ( MsgInfo( "Drag with Mouse" ), oImage:SetFocus() )
@ oWnd:oBar:nHeight,0 XBROWSE oBrw SIZE 300,-oWnd:oMsgBar:nHeight ;
PIXEL OF oWnd DATASOURCE aImages COLUMNS 1 ;
CELL LINES NOBORDER
WITH OBJECT oBrw
:nStretchCol := 1
:bChange := { || carga( oBrw:aRow[ 2 ],oImage ) }
//
:CreateFromCode()
END
@ oWnd:oBar:nHeight,300 XIMAGE oImage SIZE 0,-oWnd:oMsgBar:nHeight ;
OF oWnd SOURCE "" //MEMOREAD( oBrw:aRow[ 2 ] )
oImage:SetBrush( oBrush )
WITH OBJECT oWnd
:nWidth := ScreenWidth() * 0.6
:nHeight := ScreenHeight() * 0.6
END
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont
RELEASE BRUSH oBrush
return nil
//----------------------------------------------------------------------------//
static function ReadFolder
local aImages := {}
local c, cPath, aDir
cPath := ".\"
aDir := Directory( cPath + "*.*" )
AEval( aDir, { |a| If( a[ 2 ] > 32000, AAdd( aImages, { a[ 1 ], TrueName( cPath + a[ 1 ] ) } ), nil ) } )
ASort( aImages,,,{ |x,y| Lower( x[ 1 ] ) < Lower( y[ 1 ] ) } )
return aImages
//----------------------------------------------------------------------------//
static function carga( cFile , oImage )
local hicon := ICON_EXEREAD( cFile, 4 )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
oimage:SetSource( ogBmp:GetGDIHbitmap() )
oImage:Refresh()
ogbmp:end()
Return nil
static function carga( cFile , oImage )
local hicon := ICON_EXEREAD( cFile, 4 )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:save( "icono.png")
oimage:SetSource( memoread( "icono.png" ) )
oImage:Refresh()
ferase("icono.png" )
ogbmp:end()
Return nil
static function carga( cFile , oImage )
local hicon := ICON_EXEREAD( cFile, 4 )
local hBmp := HBMPFROMHICON( hIcon )
DestroyIcon( hIcon )
oImage:SetSource( hBmp )
DeleteObject( hBmp )
Return nil
HB_FUNC( GDIPLUSIMAGEFROMICO )
{
HICON hIcon = ( HICON ) fw_parH( 1 ) ;
ICONINFO ii ;
GetIconInfo(hIcon, &ii);
BITMAP bmp;
//GetObject(ii.hbmColor, sizeof(bmp), &bmp);
//GetObject(ii.hbmMask, sizeof(bmp), &bmp);
//Bitmap * temp = new Bitmap(ii.hbmColor, NULL);
Bitmap * temp = new Bitmap(ii.hbmMask, NULL);
DeleteObject(ii.hbmColor);
DeleteObject(ii.hbmMask);
Bitmap* newImage = BitmapFromAlphaBmp( temp ) ;
hb_retptr( newImage );
}
HB_FUNC( GDIPLUSIMAGEFROMICO )
{
HICON hIcon = ( HICON ) fw_parH( 1 ) ;
Bitmap * newImage = new Bitmap( hIcon );
hb_retptr( newImage );
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot], Horizon and 17 guests