FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Erase an Image loaded into a control Image
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Erase an Image loaded into a control Image
Posted: Sun May 17, 2015 10:48 AM
I have a small problem on a Imag control
before I load the image and the control go ok
then I wish erase th eimage and th eprocedure not refresh the image control

please try this small test

Code (fw): Select all Collapse
#include "Fivewin.ch"
#include "constant.ch"

Function test()
Local oDlg
Local oImage
Local cImage
local oGrp
   Local  nBottom   := 25
   Local  nRight    := 60
   Local  nWidth    :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local  nHeight   := nBottom * DLG_CHARPIX_H
   local   oCursorHand   := TCursor():New(,'HAND')



DEFINE DIALOG oDlg Title "test Image" SIZE nWidth, nHeight   PIXEL  TRUEPIXEL


   oImage := TImage(): New( 1.8, 12, 105, 100, , cImage, .f.,;
                                odlg, , , , .t., oCursorHand,;
                                , .t., , , , ,  )




     oImage:lStretch :=.t.
     oImage:bRClicked := {|nRow,nCol|cImage:= MyMenuImage(nRow,nCol,oImage,@cImage),oImage:Refresh() }
        @ 16, 80   GROUP oGrp  TO  128, 220 LABEL  FwString("Image")  OF  oDlg  PIXEL  //TRANSPARENT


Activate DIALOG oDlg
Return nil



 Function MyMenuImage(nRow,nCol,oControl,cImage)
    local oMenu
    local cFile
      MENU oMenu POPUP
  *  if l2007
         if WndMain() != nil .and. WndMain():oMenu != nil .and. WndMain():oMenu:l2010
            oMenu:l2010    := .t.
         else
            oMenu:l2007    := .t.
         endif
     * endif



    If empty(cImage)
       MENUITEM Fwstring("&Load an image") ACTION (cImage:=Caricafoto(@cImage,oControl))
    endif
    If !empty(cImage)
       MENUITEM FwString("&Erase an Image") ACTION (cImage:=CancellaFoto(@cImage,oControl))
    endif

    ENDMENU

    ACTIVATE POPUP oMenu AT nRow,nCol OF oControl:oWnd


    RETURN cImage

   Static Function  Caricafoto(cImage,oControl)
    local cFoto
    If MsgNoYes( Fwstring("Do you wish load an image"),Fwstring("Please confirm" ))
       cFoto := __BuscaFoto(@cImage,oControl)
    else
       cFoto :=""
    Endif
    Return   lfn2sfn(rtrim(cFoto))


//---------------------------------------------------------------------------//
    Static Function  CancellaFoto(cImage,oControl)
       local cFoto

            If MsgNoYes(Fwstring( "Do you wish erase the image ?"),Fwstring("Please confirm..." ) )
               cFoto :=""
               *oControl:LoadBmp( cFoto )
               oControl:lStretch := .t.
               oControl:Refresh()
            End

            Return    lfn2sfn(rtrim(cFoto))


  //---------------------------------------------------------------------------//


       Static Function __BuscaFoto(cImage,oControl)
     local cFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                              "DIB   (*.dib)| *.dib|" +          ;
                              "PCX   (*.pcx)| *.pcx|"  +         ;
                              "JPEG  (*.jpg)| *.jpg|" +          ;
                              "GIF   (*.gif)| *.gif|"  +         ;
                              "TARGA (*.tga)| *.tga|" +          ;
                              "RLE   (*.rle)| *.rle|" +          ;
                              "Tutti i file (*.*)| *.*"             ;
                              ,Fwstring("Select an Image"), 4,  )


    if ! Empty( cFile ) .and. File( cFile )
       oControl:LoadBmp( cFile )
       oControl:lStretch := .t.
       oControl:Refresh()
       Return cFile
    End

    return ""



lo show the menu you must click on image with left button mouse ( it show an hand cursor)
thanks in advance
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

Continue the discussion