clear IMAGE

clear IMAGE

Postby lucasdebeltran » Thu Jul 18, 2013 8:28 am

Hello,

I want to set a button (ID 102) to clear the Image:

Code: Select all  Expand view
  REDEFINE IMAGE  oBmpFoto1             ID 103 OF oFld:aDialogs[ 3 ] UPDATE ;
                                                FILENAME oData:FOTO  ;
                                                ON CLICK ( oData:FOTO := _CargaFoto (oBmpFoto1, oDlg)  ) ADJUST

   REDEFINE BUTTON                       ID 101 OF oFld:aDialogs[ 3 ] ;
                                                ACTION ( oData:FOTO := _CargaFoto (oBmpFoto1, oDlg)  )

   REDEFINE BUTTON                       ID 102 OF oFld:aDialogs[ 3 ] ;
                                                ACTION ( oData:FOTO := "", alert(odata:foto), oBmpFoto1:Refresh(), oFld:Update(), oFld:Refresh(), oDlg:Refresh()  )
 



But despite I set oData:Foto to "" and I call refresh and update, the previous picture is still there, I need to remove it.

Maybe I miss something or it is a bug.

Thank you.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: clear IMAGE

Postby Gale FORd » Thu Jul 18, 2013 5:08 pm

I had the same problem in my imaging product. I got around it by creating a blank image "blank,jpg" and using it when there is no image wanted.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: clear IMAGE

Postby Rick Lipkin » Thu Jul 18, 2013 5:58 pm

Lucas

Here is a snipit of code I use for Images with some help and advice from our good friend Uwe.

Have a look at how the image is defined with oImage and bPainted then deleted with the function DelImage()

Rick Lipkin
Code: Select all  Expand view

// images

REDEFINE IMAGE oImage ID 701 FILENAME NIL of oUsers ;
         PIXEL  ADJUST BORDER

     oImage:bPainted := { |hDC| DRAW_IMG( oImage, hDC, cImage, cPicFileName ) }

REDEFINE GET oGET var cImage ID 706 of oUsers PICTURE "@!" READONLY // displays the filename only

REDEFINE BTNBMP oButt4 ID 702 of oUsers ;
         RESOURCE "ADD16","DADD16","DADD16" ;
         PROMPT "Import    " LEFT 2007;
         ACTION ( GetImage( @oImage,oRsPet,oUsers,@cImage,oGet,@cPicFileName ),;
                  _ChkButtons( cMode,oRsPet,oButt4,oButt5,oButt6,oButt7))

REDEFINE BTNBMP oButt5 ID 703 of oUsers ;
         RESOURCE "EDIT16","DEDIT16","DEDIT16" ;
         PROMPT "Export    " LEFT 2007;
         ACTION ( ExportImage( oRsPet,0 ) )

REDEFINE BTNBMP oButt6 ID 704 of oUsers ;
         RESOURCE "DELETE16","DDELETE16", "DDELETE16" ;
         PROMPT "Delete    " LEFT 2007;
         ACTION ( DelImage(@oImage,oRsPet,oUsers,oGet,@cImage,@cPicFileName ),;
                  _ChkButtons( cMode,oRsPet,oButt4,oButt5,oButt6,oButt7))

REDEFINE BTNBMP oButt7 ID 705 of oUsers ;
         RESOURCE "VIEW16","DVIEW16","DVIEW16" ;
         PROMPT "Print      " LEFT 2007;
         ACTION ( PrintImage( oRsPet,0 ) )

// end images

//------------- Image-Brush from Uwe ----------
Static FUNC Draw_Img( oImage, hDC, cImage, cPicFileName  )

LOCAL oBrush,cDefa
LOCAL aRect := GETCLIENTRECT( oImage:hWnd )

cDefa  := set(7)

If cPicFileName = " " // ad mode because blank .. cImage passed as is
Else
   cImage := cDefa+"\Pictures\"+alltrim( cImage )
Endif

// added for on paint
SysReFresh()

IF FILE( cImage )
    DEFINE IMAGE oBrush FILENAME cImage
    PalBmpDraw( hDC, 0, 0, oBrush:hBitmap, , aRect[4], aRect[3] )
    oBrush:End()
ENDIF

RETURN( NIL )

//----------------------------------------------------------------------------//
Static Func DelImage( oImage,oRsPet,oDlg,oGet,cImage,cPicFileName )

LOCAL Saying,cFILE,cDefa

cDefa := set(7)
cFile := oRsPet:Fields("
PicFileName"):Value

If cFile = "
" .or. empty( cFile )
   Saying := "
Sorry .. there is no Image to Delete"
   MsgInfo( Saying )
   Return(.f.)
Endif

Saying := "
Are you SURE you want to Delete this Image ?"+chr(10)
Saying += cFile

If MsgNoYes( Saying )

   Ferase(cDefa+"
\Pictures\"+alltrim(cFile))
   cImage := "
"
   oGet:Refresh()
   oImage:Refresh()
   oDlg:ReFresh()
   SysReFresh()

   cPicFileName := space(50)
   oRsPet:Fields("
PicFileName"):Value := cPicFileName
   oRsPet:Update()

   SysReFresh()

Endif

Return(nil)
User avatar
Rick Lipkin
 
Posts: 2633
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: clear IMAGE

Postby nageswaragunupudi » Thu Jul 18, 2013 6:14 pm

Mr Lucas

Let me try to make it simple for you.

#1. If you want to change the image with a new image file :
ACTION ( oData:foto := <newfilename>, oImage:LoadBmp( oData:foto ) )

#2. If you want to clear image
ACTION ( oData:foto := "", ClearImage( oImage ) )

I shall give you a function to ClearImage
Code: Select all  Expand view
function ClearImage( oBmp )

   WITH OBJECT oBmp
      PalBmpFree( :hBitmap, :hPalette )
      :hBitmap := :hPalette  := 0
      :cBmpFile := :cResName := nil
      :Refresh()
   END

return nil
 


We try to provide an appropriate method in the class in the next version.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: clear IMAGE

Postby elvira » Thu Jul 18, 2013 6:15 pm

Lucas;

Try this oBmpFoto1:LoadImage("nada")
elvira
 
Posts: 515
Joined: Fri Jun 29, 2012 12:49 pm

Re: clear IMAGE

Postby nageswaragunupudi » Thu Jul 18, 2013 8:36 pm

elvira wrote:Lucas;

Try this oBmpFoto1:LoadImage("nada")

This also works. Giving a non-empty name, which is not an existing image file also works. This is a work around.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: clear IMAGE

Postby nageswaragunupudi » Sat Aug 03, 2013 2:11 pm

From FWH 13.07, we can use
oImg:Clear()
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 20 guests