PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Marco Ruiz on December 10, 2009, 07:55:44 PM

Title: FireImage and filelenght
Post by: Marco Ruiz on December 10, 2009, 07:55:44 PM
I have replaced a control Listview for a control FireImage to visualize a picture of an item. 
 
The system shows the picture selected by the client correctly, but then intent to read the file, but the system returns me as longitude of file zero. 
 
If I replace the control FireImage for the control listview, I can read the file correctly. 
That it can be happening?. 
 
THE CODE

     'pintamos el diálogo para selección de la foto
   Local nResult   As Long      ' determines whether the OpenFiles dialog was cancelled
   Local sFilename As String    ' holds the returned list of selected file(s)
   Local sFilter   As String    ' holds the filter list   
   Local nFlags    As Long      ' flags that describe the OpenFiles dialog behavior
   Local fCount    As Long      ' number of filenames retrieved
   Local sFile     As String    ' name of file retrieved after parsing sFilename   
   Local sPath     As String    ' path for sFile
   Local temp As String
     
   sFilter = "Archivos de Fotos (*.jpg)|*.jpg"
     
   nFlags  = %OFN_EXPLORER Or %OFN_ENABLESIZING Or _
             %OFN_FILEMUSTEXIST Or %OFN_NODEREFERENCELINKS Or %OFN_HIDEREADONLY       
     
   temp = CurDir$
   nResult = FF_OpenFileDialog( hWndForm, "Buscar Foto", sFilename, "", sFilter, "jpg", nFlags, %True)
   ChDir temp
   ' Check to see if the dialog was cancelled
   If nResult = 0 Then Exit Function
   
   sFile = Parse$(sFileName, $Nul, 1)    '

   SendMessage HWND_FRMNUEVOARTICULOTAB1_FIFOTO, %FIREIMAGE_SETIMAGENORMAL, %FIREIMAGE_LOADFILE, StrPtr(sFile)

  ' Perform whatever you need to do with the file here
'  Local lvbi As LVBKIMAGE
'  Local szFile As Asciiz*%MAX_PATH
'
'  szFile = sFile
'  lvbi.ulFlags = %LVBKIF_STYLE_NORMAL Or %LVBKIF_SOURCE_URL
'  lvbi.pszImage = VarPtr(szFile)
'  lvbi.cchImageMax = Len(szFile)
'  Control Send hWndForm, IDC_FRMNUEVOARTICULOTAB1_LVFOTO,  %LVM_SETBKIMAGE, 0, VarPtr(lvbi)
  FF_TextBox_SetText (HWND_FRMNUEVOARTICULOTAB1_TXTFOTO, sFile)

.......
UPDATE ITEM:

   Local cmd As String, lresult As Long, archivo As String, hFile As Long
  Dim sBlob               As Local String
  Dim sBlock              As Local String
  Dim lPointerToBuffer    As Local Long
  Dim lIndicator          As Local Long
  Dim lBlockNumber        As Local Long
  Dim lCounter                As Local Long

    If t.Foto <> "" Then
      archivo = t.foto
      hFile = FreeFile
      Open archivo For Binary As #hFile
      Get$ hFile, Lof(hFile), sBlob
      Close hFile                           
   Else
      sBlob = " "
   End If
 
   msgbox str$(LEN(sBlob))   ' it visualizes zero ¿¿¿¿¿¿¿¿¿ why ????????????  if I replace the code for the listview, it works correctly


   cmd = "UPDATE articulo SET "    & _
         "codigo = '"                & t.codigo               & "'," & _
         "descripcion = '"         & t.descLarga          & "'," & _
         "descCorta = '"           & t.descCorta          & "'," & _
         "observacion = '"         & t.observac            & "',"   & _
         "UniEnt ="                   & Str$(t.codUniAlm)  & ","    & _
         "UniSal ="                   & Str$(t.codUniVta)  & ","    & _
         "Factor ="                   & Str$(t.Factor)       & ","    & _
         "codigo_marca ="           & Str$(t.codMarca)     & ","    & _
         "codigo_modelo ="         & Str$(t.codModelo)  & ","    & _
         "codigo_color ="           & Str$(t.codColor)    & ","    & _
         "codigo_procedencia ="    & Str$(t.codProced)  & ","    & _
         "certificacion ="         & Str$(t.certifica)  & ","    & _
         "mndaPrec = '"              & Format$(t.moneda)  & "'," & _
         "precCom ="                & Str$(t.precCom)     & ","    & _
         "precMay ="                & Str$(t.precMay)     & ","    & _
         "precMin ="                & Str$(t.precMin)     & ","    & _
         "stockMin ="                & Str$(t.stockMin)     & ","    & _
         "stockMax ="                & Str$(t.stockMax)     & ","    & _
         "correla ="                & Str$(t.correla)     & ","    & _
         "codante = '"           & t.codante          & "'," & _
         "codcompra = '"         & t.codcompra        & "'," & _
         "conSerie = "           & Str$(t.tieneSerie) & "," & _
         "foto = ?"              & _
         " WHERE articulo_ID ="    & Str$(t.articulo_ID)

   SQL_Stmt %SQL_STMT_PREPARE, cmd
   
   lPointerToBuffer = 1  'for long data, use the parameter NUMBER instead of a pointer
   
   lIndicator = %SQL_LONG_DATA
   
   lResult = SQL_BindParam(1, _                    'lParameterNumber&
                          %SQL_PARAM_INPUT, _     'lParamType&
                          %SQL_BINARY, _   'BAS_STRING, _          'lBasType&
                          %SQL_LONGVARBINARY, _   'lSQLType&
                          Len(sBlob), _           'lDisplaySize&
                          0, _                    'lDigits&
                          lPointerToBuffer, _     'lPointerToBuffer& (parameter number)
                          Len(sBlob), _           'lBufferLen&
                          lIndicator)             'lIndicator&
   
   'Execute the SQL statement
   SQL_Stmt %SQL_STMT_EXECUTE, ""
   
   'Tell the database that we are about to "fill" a parameter   
   SQL_NextParam
   
   Do
     'Send the long data in 4k chunks (arbitrary size; can be larger or smaller)
     Incr lBlockNumber
     sBlock = Mid$(sBlob,((lBlockNumber-1)*4096)+1, 4096)
     If Len(sBlock) > 0 Then
       'Send the block of data to the database
       SQL_LongParam sBlock, Len(sBlock)
     Else
       'We have sent all of the data so tell the database that we are done.
       SQL_NextParam
       'Exit from the loop...
       Exit Loop
     End If
   Loop
   
   If SQL_ErrorPending Then
      lResult& = SQL_MsgBox(sql_errorQuickAll, %MSGBOX_OK)
      mensaje_sql cmd
   ElseIf SQL_ResRowCount = 0 Then
      MsgBox "No se pudo Actualizar el Artículo", %MB_ICONERROR Or %MB_TASKMODAL,FuncName$
   Else               
      Function = %TRUE
   End If   



 
 
Title: Re: FireImage and filelenght
Post by: Paul Squires on December 11, 2009, 12:19:20 PM
It is my understanding that the GDI+ functions to read and display a picture will lock the physical disk file. The FireImage control uses GDI+ for displaying the pictures - that's why you may not be able to access the disk file or copy over the file. It remains locked while the image is displayed.
Title: Re: FireImage and filelenght
Post by: Marco Ruiz on December 11, 2009, 03:46:54 PM
Thank you Paul for your response, now I deal.

To solve the problem, now I copy the photo that is visualized to another location and read it from there.