Can I use center method of Bitmaps to center an image into image area control ?
and how ?
# include "fivewin.ch"
function test()
local odlg,oImage
local oSay[7]
local obtn[1]
DEFINE DIALOG oDlg ; //OF oParent
TITLE "test" ;
SIZE 600, 600
@ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg
activate dialog odlg ;
on init GetImage( oImage )
retur nil
STATIC FUNCTION GetImage( oImage )
local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" + ;
"DIB (*.dib)| *.dib|" + ;
"PCX (*.pcx)| *.pcx|" + ;
"JPEG (*.jpg)| *.jpg|" + ;
"GIF (*.gif)| *.gif|" + ;
"TARGA (*.tga)| *.tga|" + ;
"RLE (*.rle)| *.rle|" + ;
"All Files (*.*)| *.*" ;
,"Please select a image file", 4 )
if ! Empty( gcFile ) .and. File( gcFile )
oImage:LoadBmp( gcFile )
oImage:center()
endif
return nil
Silvio.Falconi wrote:Antonio,
the small sample run ok
- Code: Select all Expand view
# include "fivewin.ch"
function test()
local odlg,oImage
local oSay[7]
local obtn[1]
DEFINE DIALOG oDlg ; //OF oParent
TITLE "test" ;
SIZE 600, 600
@ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg
activate dialog odlg ;
on init GetImage( oImage )
retur nil
STATIC FUNCTION GetImage( oImage )
local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" + ;
"DIB (*.dib)| *.dib|" + ;
"PCX (*.pcx)| *.pcx|" + ;
"JPEG (*.jpg)| *.jpg|" + ;
"GIF (*.gif)| *.gif|" + ;
"TARGA (*.tga)| *.tga|" + ;
"RLE (*.rle)| *.rle|" + ;
"All Files (*.*)| *.*" ;
,"Please select a image file", 4 )
if ! Empty( gcFile ) .and. File( gcFile )
oImage:LoadBmp( gcFile )
oImage:center()
endif
return nil
when I use the same command on my app not run
Antonio, Remember the listview test ?
When I drop a file I insert an image on a control Image , it is on the top of the listview control
as you can see here
if I use oImage:center() it move the" Image area" into center of dialog
but I wish move only the jpg of the file I dropped into center of "image area "
# include "fivewin.ch"
static nLTop
static nLLeft
function test()
local odlg,oImage
local oSay[7]
local obtn[1]
DEFINE DIALOG oDlg ; //OF oParent
TITLE "test" ;
SIZE 600, 600
@ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg
/*
// oAllegati -> oDlg
oAllegati:bResized := {|| nLTop := INT( ( ( oAllegati:nHeight ) / 2 ) - ( oImage:nHeight / 2 ) ), ;
nLLeft := INT( ( ( oAllegati:nWidth - 18 ) / 2 ) - ( oImage:nWidth / 2 ) ), ;
oImage:Move( nLTop, nLLeft, , , .T. ), ;
Rinfresca_oDlgallegati(oList,oAllegati ) }
*/
activate dialog odlg ;
on init GetImage( oImage, oDlg )
retur nil
STATIC FUNCTION GetImage( oImage, oDlg )
local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" + ;
"DIB (*.dib)| *.dib|" + ;
"PCX (*.pcx)| *.pcx|" + ;
"JPEG (*.jpg)| *.jpg|" + ;
"GIF (*.gif)| *.gif|" + ;
"TARGA (*.tga)| *.tga|" + ;
"RLE (*.rle)| *.rle|" + ;
"All Files (*.*)| *.*" ;
,"Please select a image file", 4 )
if ! Empty( gcFile ) .and. File( gcFile )
oImage:LoadBmp( gcFile )
nLTop := INT( ( ( oDlg:nHeight ) / 2 ) - ( oImage:nHeight / 2 ) )
nLLeft := INT( ( ( oDlg:nWidth - 18 ) / 2 ) - ( oImage:nWidth / 2 ) )
oImage:Move( nLTop, nLLeft, , , .T. )
// oImage:center()
endif
return nil
# include "fivewin.ch"
function test()
local odlg,oImage
local oSay[7]
local obtn[1]
Local oPnel
DEFINE DIALOG oDlg ; //OF oParent
TITLE "test" ;
SIZE 600, 600
@ 2, 2 PANEL oPnel SIZE 152, 152 OF oDlg
@ 1, 1 IMAGE oImage SIZE 150, 150 OF oPnel PIXEL //NOBORDER
// @ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg
activate dialog odlg ;
on init GetImage( oImage, oPnel )
retur nil
STATIC FUNCTION GetImage( oImage, oPnel )
Local nLTop
Local nLLeft
local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" + ;
"DIB (*.dib)| *.dib|" + ;
"PCX (*.pcx)| *.pcx|" + ;
"JPEG (*.jpg)| *.jpg|" + ;
"GIF (*.gif)| *.gif|" + ;
"TARGA (*.tga)| *.tga|" + ;
"RLE (*.rle)| *.rle|" + ;
"All Files (*.*)| *.*" ;
,"Please select a image file", 4 )
if ! Empty( gcFile ) .and. File( gcFile )
oImage:LoadBmp( gcFile )
/*
// So it works well
nLTop := INT( ( ( oPnel:nHeight )/ 2 ) - ( nBmpHeight( oImage:hBitmap ) / 2 ) )
nLLeft := INT( ( ( oPnel:nWidth ) / 2 ) - ( nBmpWidth( oImage:hBitmap ) / 2 ) )
oImage:Move( nLTop, nLLeft, , , .T. )
*/
oImage:center()
endif
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 22 guests