IF lFileImage
oImagePreview:LoadBmp(cFileImage)
oImagePreview:setpos(0,0)
oImagePreview:nWidth:=oPanelPreview:nWidth
oImagePreview:nHeight:=oPanelPreview:nHeight
oImagePreview:lStretch:= .t.
oImagePreview:nZoom:= 1
oImagePreview:refresh()
else
ico := ICON_EXEREAD( cFile, 4 )
GDIBmpFromHIcon( ico, oImagePreview ,256,256 )
endif
....
Function GDIBmpFromHIcon( hIcon , oImagePreview , nWidth, nHeight )
local ogbmp := GdiBmp():new()
ogbmp:hBmp:= GDIPLUSIMAGEFROMICO( hicon )
ogbmp:resize( nWidth,nHeight)
DeleteObject( oImagePreview:hBitmap )
oImagePreview:hBitmap := oGBmp:GetGDIHbitmap()
oImagePreview:HasAlpha()
oImagePreview:Refresh()
*ogbmp:end()
*GDIPLUSIMAGEDISPOSE( ogdibmp)
Return nil
THE PROBLEM IS :
on your test you use a BTIMAP control
@ 3, 38 BITMAP oimage FILE "" size 220,220 of oWnd
on my application I use a oImage control
@ 0, 0 IMAGE oImagePreview SIZE oPanelPreview:nRight, oPanelPreview:nbottom OF oPanelPreview NOBORDER
on Image control gdi not run ok
I need to use oImage control because I select any files ( image or document file )
Image ==> *.bmp;*.gif;*.jpg;*.png;*.tif
document files == >*.pdf *.doc,*.xls,*.ppt,*.docx,*.xlsx,*.pptx *.odt,*.ods,*.odp, *.sxw, *.sxc,*. sxi
I think it is the problem
I made also a test change your control Bitmap into Image control and gdi not run
the code test
#include "FiveWin.ch"
#include "constant.ch"
Function Main ()
local ownd
local oimage
Local nBottom := 33
Local nRight := 75
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
DEFINE DIALOG oWnd ; //OF oParent
TITLE "test" ;
SIZE nWidth, nHeight TRANSPARENT PIXEL
oWnd:nStyle := nOr( WS_OVERLAPPED,WS_THICKFRAME,WS_SYSMENU,WS_MAXIMIZEBOX, 0 )
@ 20,2 button "crear" size 40,20 pixel Action imagenfromico(oimage )
@ 20 ,130 Button "salir" Action ownd:end() size 40,20 pixel
@ 3, 38 Image oimage FILE "" size 220,220 of oWnd
ACTIVATE dialog 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
when you select the file then not show any image into Image control
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com