Dica do SistemaEste artigo aplica-se a um sistema operativo diferente do que está a utilizar. Foi desactivado o conteúdo do artigo, que pode não ser relevante para si.
Visual FoxPro Geral campos são frequentemente utilizados para armazenar ficheiros de imagem. Por exemplo, ficheiros .jpg e .bmp são ficheiros de imagem. O tipo de campo Geral contém não apenas informações sobre a imagem que está armazenada, mas também informações sobre o servidor registado que foi utilizado para escrever a imagem para o campo. Por exemplo, se o servidor registado para ficheiros .jpg no computador o Microsoft Photo Editor, informações sobre o Microsoft Photo Editor e sobre o ficheiro .jpg são concatenadas. Em seguida, esta informação é armazenada no campo Geral .
Quando uma tabela do Visual FoxPro que tem um campo Geral é movida para outro computador, as imagens no campo podem não apresentada correctamente devido as informações de adicionais do servidor são armazenadas no campo. Este comportamento poderá ocorrer em formulários ou relatórios. Este comportamento pode ocorrer mesmo quando apenas visualizar a tabela e modificar o campo Geral . O campo não pode apresentar a imagem real. Em vez disso, o utilizador só poderá ver um ícone.
Não pode sempre determinar se um servidor válido é presente em computadores em que tenha as tabelas. Por conseguinte, não poderá utilizar o tipo de campo Geral quando a aplicação utiliza extensivamente imagens que são armazenadas em tabelas. Por exemplo, poderá armazenar imagens num campo Memo (binário) . Em seguida, pode utilizar a função StrToFile para escrever as imagens no disco quando pretender. Também pode utilizar o tipo de campo blob que foi introduzido no Visual FoxPro 9. Ou pode utilizar a propriedade PictureVal do controlo de imagem .
No entanto, se decidir utilizar um método diferente, tem de utilizar as imagens que já tenha armazenado nos campos Geral . Não é fácil obter estas imagens da tabela do Visual FoxPro e colocá-los no disco. No entanto, o processo seguinte no Visual FoxPro 9 pode ajudá-lo resolver esta questão.
Esta secção apresenta dois exemplos de como extrair imagens do campo fotografia a tabela de exemplo do empregado que está incluído no Visual FoxPro 9. Pode fazê-lo utilizando a nova classe base ReportListener . A classe base ReportListener foi introduzida no Visual FoxPro 9.
Nota Estes exemplos apenas funcionam no Visual FoxPro 9.
O primeiro exemplo mostra como criar manualmente um relatório e como executar o relatório para extrair as imagens. O segundo exemplo mostra uma abordagem de programação para o processo. Este segundo exemplo demonstra como criar e como modificar um relatório utilizando o código. Este segundo exemplo também demonstra como substituir o Compor e AfterBand eventos de XMLListener FoxPro Foundation Class (FFC) para optimizar o processo de extracção.
Nota Terá de efectuar este processo num computador onde as imagens no campo gerais são apresentadas correctamente. As imagens não devem ser apresentadas como ícones. Se executar este processo num computador onde visualiza apenas ícones, apenas os ícones serão extraídos no disco.
Exemplo 1: Extrair manualmente imagens de um campo geral utilizando uma classe ReportListener
Certifique-se que Visual FoxPro é configurado para executar assistidas por objecto mapa. Para efectuar este procedimento, execute o seguinte comando na janela de comandos :
SET REPORTBEHAVIOR 90
Abra o Designer de mapas executando o comando CREATE REPORT na janela de comandos .
Reduza a altura das faixas de Página de cabeçalho e Rodapé de página para que sejam 0 polegadas de alta. Estes faixas não são necessários para este exemplo.
Da barra de Controlos de relatório , adicione um controlo Dependente de imagem/OLE para a faixa de detalhe. Redimensione, em seguida, a faixa de detalhe e o controlo de Imagem/OLE dependente para que sejam suficientemente grande para apresentar imagens que estejam na sua área Geral .
Se a caixa de diálogo Propriedades do controlo dependente imagem/OLE não está já abrir, faça duplo clique o controlo de Imagem/OLE dependente para abri-lo e, em seguida, defina as seguintes opções no separador Geral :
Em tipo de origem do controlo , clique em Nome do campo geral .
Na caixa Origem do controlo , escreva fotografia . Este é o nome do campo Geral da tabela ' empregado '.
Clique para seleccionar a caixa de verificação campo geral Centro horizontal numa moldura .
Guarde e feche o relatório. Repare onde guardou o relatório.
Guardar o seguinte exemplo de código para um programa novo e, em seguida, executá-la. Quando lhe for pedido, seleccione o mapa que guardou no passo 6. Quando acabar do código, todas as imagens do campo Geral denominado fotografias serão extraídas para uma pasta. Além disso, o caminho de imagens extraídos é copiado para a área de transferência.
*-----------------------------------
* Microsoft Knowledge Base Article 894819
* EXAMPLE 1
* AUTHOR: Trevor Hancock
* CREATED: February 22, 2005 09:59:32
* ABSTRACT: This code extracts pictures to disk from the
* General field that is named PHOTO in the
* EMPLOYEE sample table.
*-----------------------------------
CLEAR
LOCAL lcTestDir AS STRING, ;
loListener AS REPORTLISTENER
*-- Create a subfolder of the current
*-- Visual FoxPro TEMP folder to hold the extracted pictures.
lcTestDir = ADDBS( SYS( 2023 ) ) + 'GenTst\'
IF !DIRECTORY( lcTestDir, 1 )
MD ( lcTestDir )
ELSE
*-- If DIR is already there, empty it.
LOCAL lcOldSetSafe AS STRING
lcOldSetSafe = SET( 'Safety' )
SET SAFETY OFF
ERASE ( lcTestDir + '*.*' )
SET SAFETY &lcOldSetSafe
ENDIF
*-- Open the EMPLOYEE table. The General field that is named
*-- PHOTO has pictures in it.
USE ADDBS( HOME() ) + 'Samples\Data\Employee.dbf'
*-- Here we run the Report Output Application (ReportOutput.app) in HOME().
*-- We pass it a 5. This means that we want the Report Output Application
*-- to store an object reference to an HTMLListener-type
*-- ReportListener base class to the second parameter that we pass: loListener.
DO HOME() + 'ReportOutput.app' WITH 5, loListener
*-- Tell the HTMLListener to save the output (the .HTM page)
*-- to a specific folder. This folder is the one created earlier.
loListener.TargetFileName = lcTestDir + 'tmp.htm'
*-- Typically, a report that is run by using an HTMLListener
*-- displays wait windows during processing and a
*-- message box at the end. We want to turn this off. Therefore,
*-- we set QuietMode = .T.
*-- Note: This also turns off error reports from the ReportListener.
loListener.QUIETMODE = .T.
*-- Run the report by using the Listener.
REPORT FORM GETFILE('FRX') OBJECT loListener
*-- This command deletes the .html file that is produced.
*-- We do not need it.
ERASE ( loListener.TargetFileName )
*-- Clean up, and then report that the process has finished.
*-- To see the results, use Microsoft Windows Explorer to
*-- view the folder path that is stored in the Windows Clipboard.
CLOSE DATA ALL
_CLIPTEXT = lcTestDir
? 'Pictures have been extracted to ', lcTestDir
? 'This path is in your Clipboard.'
Exemplo 2: Extrair programaticamente utilizando uma classe ReportListener imagens de um campo geral
Guarde este exemplo de código para um novo ficheiro .prg. Em seguida, execute o programa para criar automaticamente um relatório e utilizar o relatório para extrair as fotografias da tabela ' empregado '.
Nota Crie uma pasta na unidade C com o nome TmpTst ou redefinir a variável lcTargetDir para apontar para a pasta da sua escolha.
*-----------------------------------
* Microsoft Knowledge Base Article 894819
* EXAMPLE 2
* AUTHOR: Trevor Hancock
* CREATED: February 22, 2005 09:59:32
* ABSTRACT: This code extracts pictures to disk from the
* General field that is named PHOTO in the
* EMPLOYEE sample table.
*-----------------------------------
*-- This opposite value of the constant will be used to set the QuietMode
*-- property of the ReportListener base class. When the value is .T.,
*-- wait windows that indicate processing appear. At the end, a message box
*-- appears. Any errors in the ReportListener base class also appear.
#DEFINE ShowReportFlow_Errs .F.
LOCAL lcReportName AS STRING, ;
lcGenFldName AS STRING, ;
lnGenFldHeight AS INTEGER, ;
lnGenFldWidth AS INTEGER, ;
lcTargetDir AS STRING, ;
lcFileNameExpr AS STRING, ;
lcGenTable AS STRING
*-- Choose the name of a table to extract one General
*-- field from.
lcGenTable = ADDBS( HOME() ) + 'Samples\Data\employee.dbf'
*-- Set the name of the General field that you want to extract from.
lcGenFldName = 'PHOTO'
*-- Set the height that you want for the General field.
lnGenFldHeight = 8000.00
*-- Set the width that you want for the General field.
lnGenFldWidth = 7000.00
*-- Set the folder into which the General field
*-- pictures will be extracted.
lcTargetDir = 'C:\TmpTst\'
*-- By default, pictures that are rendered to disk by the ReportListener class
*-- use the following file name format: _n.jpg. In this format, n
*-- is a number. If you set this next variable to an expression, you
*-- can override that behavior. In this example, we name
*-- the .jpg files based on the FIRST_NAME and LAST_NAME
*-- fields from the EMPLOYEE table that we are reporting from.
*-- This expression will be wrapped in the EVAL function when it is called.
*-- Therefore, make sure that you specify an expression, a variable, or something else.
*-- Possible choices include the RECNO function and other table field names.
lcFileNameExpr = ;
"ALLT(Employee.First_Name) + '_' + ALLTRIM(Employee.Last_Name)"
*------ START REPORT CREATION
*
CLOSE DATA ALL
IF !DIRECTORY( lcTargetDir, 1 )
MESSAGEBOX( 'Target output folder does not exist. Process stopped.', 48, '' )
RETURN .F.
ENDIF
CD ( lcTargetDir )
*-- Clean up the folder first to prevent any file name conflicts.
LOCAL lcOldSetSafe as String
lcOldSetSafe = SET("Safety")
SET SAFETY OFF
DELETE FILE *.*
SET SAFETY &lcOldSetSafe
*-- Create a temporary cursor to base the report
*-- on, make the report, and then close the cursor.
*-- This temporary cursor is used to set up the report for the first time.
*-- It is not needed after the report is made.
lcReportName = lcTargetDir + 'GenReport'
CREATE CURSOR TEMP ( Fld1 G )
CREATE REPORT ( lcReportName ) FROM TEMP
USE IN TEMP
*-- Open the report file (FRX) as a table.
USE ( FORCEEXT( lcReportName, 'FRX' ) ) IN 0 ALIAS TheReport EXCLUSIVE
SELECT TheReport
*-- This command removes objects that are not required
*-- from the report surface and from the report table itself.
*-- ObjType = 5 or 8: Removes the label and field objects from the footer.
*-- ObjType = 23 & FontStyle = 1: Removes a font resource
*-- that is not needed. The resource belonged to the label that was deleted.
DELETE ALL FOR (ObjType = 23 AND FontStyle = 1) ;
OR INLIST(ObjType, 5, 8) IN TheReport
*-- This command adjusts the layout of the header and footer bands.
*-- ObjType = 9 & ObjCode = 1 means Page Header band.
*-- ObjType = 9 & ObjCode = 7 means Page Footer band.
*- Reduce them because they are not required for this code.
UPDATE TheReport SET Vpos = 0, Hpos = 0, HEIGHT = 0 ;
WHERE ObjType = 9 AND (ObjCode = 1 OR ObjCode = 7)
*-- Increase the height of the Detail band
*-- (ObjType = 9 & ObjCode = 4) to fit the
*-- Picture/OLE Bound control that is inserted by using the next command.
UPDATE TheReport SET Vpos = 0, Hpos = 0, HEIGHT = lnGenFldHeight ;
WHERE ObjType = 9 AND ObjCode = 4
*-- Add a Picture/OLE Bound control to the report by inserting a
*-- record with appropriate values. Using an object that is based on the EMPTY
*-- class here and the GATHER NAME class later to insert the record makes it easier to
*-- see which values line up to which fields when compared to a large
*-- SQL-INSERT command).
LOCAL loNewRecObj AS EMPTY
loNewRecObj = NEWOBJECT('EMPTY')
ADDPROPERTY( loNewRecObj, 'PLATFORM', 'WINDOWS' )
ADDPROPERTY( loNewRecObj, 'Uniqueid', SYS(2015) )
ADDPROPERTY( loNewRecObj, 'ObjType', 17 ) && "Picture/OLE Bound control"
ADDPROPERTY( loNewRecObj, 'NAME', lcGenFldName ) && Name of the General field in the cursor.
ADDPROPERTY( loNewRecObj, 'Vpos', 2083.333) && Put it in the Detail band.
ADDPROPERTY( loNewRecObj, 'HEIGHT', lnGenFldHeight )
ADDPROPERTY( loNewRecObj, 'WIDTH', lnGenFldWidth )
ADDPROPERTY( loNewRecObj, 'DOUBLE', .T. ) && The picture is centered in the Picture/OLE Bound control
ADDPROPERTY( loNewRecObj, 'Supalways', .T. )
*-- For the Picture/OLE Bound control, the contents of the OFFSET field specify whether
*-- File name (0), General field name (1), or Expression (2) is the source.
ADDPROPERTY( loNewRecObj, 'Offset', 1 )
*-- Add the Picture/OLE Bound control record to the report.
APPEND BLANK IN TheReport
GATHER NAME loNewRecObj MEMO
*-- Clean up and then close the report table.
PACK MEMO
USE
*
*------ END REPORT CREATION
*-- Rerun the report by using the Listener subclass
*-- that is defined in later code.
USE ( lcGenTable )
LOCAL loXMLD_Listener AS ;
XMLDISPLAYLISTENER OF ADDBS( HOME( ) ) + 'Ffc\_reportlistener.vcx'
loXMLD_Listener = NEWOBJECT( 'MyListener' )
loXMLD_Listener.TargetFileName = ADDBS( lcTargetDir ) + 'tmp.htm'
loXMLD_Listener.ImgFileNameExpr = lcFileNameExpr
loXMLD_Listener.QUIETMODE = !ShowReportFlow_Errs
WAIT WINDOW 'Rendering pictures.' NOWAIT NOCLEAR
REPORT FORM ( lcReportName ) OBJECT loXMLD_Listener
ERASE (loXMLD_Listener.TargetFileName)
ERASE ( FORCEEXT( lcReportName , '*' ) )
RELEASE loXMLD_Listener
WAIT WINDOW 'Complete!' TIMEOUT 2
RETURN
*----------------------------------
*----------------------------------
DEFINE CLASS MyListener AS XMLDISPLAYLISTENER OF ADDBS(HOME()) + 'Ffc\_reportlistener.vcx'
ImgFileNameExpr = ''
ImgFile = ''
PROCEDURE RENDER(nFRXRecNo, nLeft, nTop, nWidth, nHeight, ;
nObjectContinuationType, cContentsToBeRendered, GDIPlusImage)
NODEFAULT
*-- ImageFileBaseName is an optional prefix to be added
*-- to generated image file names when image files are saved
*-- to disk during the rendering of general fields in a report run.
THIS.ImageFileBaseName = EVAL( THIS.ImgFileNameExpr )
*-- This is the full path and file name of the picture file that will
*-- be rendered to disk when the DODEFAULT function is called. This information is retrieved here
*-- so we can clean it up in the AfterBand event.
THIS.ImgFile = FORCEPATH(THIS.ImageFileBaseName + "_" + ;
TRANSFORM(THIS.ImageFieldInstance + 1) + ".jpg", ;
FULLPATH(THIS.ExternalFileLocation,ADDBS(JUSTPATH(THIS.TargetFileName))))
DODEFAULT(nFRXRecNo,nLeft,nTop,nWidth,nHeight, ;
nObjectContinuationType, cContentsToBeRendered, GDIPlusImage)
ENDPROC
PROCEDURE AFTERBAND(nBandObjCode, nFRXRecNo)
NODEFAULT
IF nBandObjCode = 4 && In Detail Band
*-- Look for the image file on the disk.
*-- If the image file is there, the code inside the IF...ENDIF
*-- construct strips off the _n that is at the end of the file name,
*-- just before the extension. This is added in the Render event by the
*-- XMLDISPLAYLISTENER class. You do not have to clean up the file name. However,
*-- it looks cleaner. For example, "Scott_Rockfeld_1.jpg" would change to
*-- "Scott_Rockfeld.jpg".
IF FILE( THIS.ImgFile )
LOCAL lnLastUnderscorePos AS INTEGER
lnLastUnderscorePos = ATC('_', THIS.ImgFile, OCCURS( '_', THIS.ImgFile ) )
RENAME ( THIS.ImgFile ) TO ;
FORCEEXT( SUBSTR( THIS.ImgFile, 1, lnLastUnderscorePos - 1 ), 'JPG' )
ENDIF
ENDIF
DODEFAULT( nBandObjCode, nFRXRecNo )
ENDPROC
ENDDEFINE
Para mais informações sobre como exportar incorporado imagens de mapa de bits, clique no número de artigo que se segue para visualizar o artigo na base de dados de conhecimento da Microsoft:
161832
(http://support.microsoft.com/kb/161832/
)
Como exportar uma imagem .bmp incorporado num ficheiro
Para obter informações adicionais sobre a estrutura da tabela FRX, consulte o tópico "Tabela de estruturas de ficheiros de tabela (.dbc .frx, .lbx, .mnx, .pjx, .scx, .vcx)" na ajuda do Visual FoxPro.
Para rever a estrutura da tabela Visual FoxPro 9.0 FRX directamente, execute o seguinte comando na janela de comandos :
REPORT FORM HOME() + "\Tools\Filespec\90frx.frx" pré-visualização
Para obter mais informações sobre a classe de base de estilo de visualização ReportListener XML, visite o seguinte Web site da Microsoft Developer Network (MSDN):
IMPORTANTE: Este artigo foi traduzido por um sistema de tradução automática (também designado por Machine translation ou MT), não tendo sido portanto revisto ou traduzido por humanos. A Microsoft tem artigos traduzidos por aplicações (MT) e artigos traduzidos por tradutores profissionais. O objectivo é simples: oferecer em Português a totalidade dos artigos existentes na base de dados do suporte. Sabemos no entanto que a tradução automática não é sempre perfeita. Esta pode conter erros de vocabulário, sintaxe ou gramática? erros semelhantes aos que um estrangeiro realiza ao falar em Português. A Microsoft não é responsável por incoerências, erros ou estragos realizados na sequência da utilização dos artigos MT por parte dos nossos clientes. A Microsoft realiza actualizações frequentes ao software de tradução automática (MT). Obrigado.
Clique aqui para ver a versão em Inglês deste artigo: 894819
(http://support.microsoft.com/kb/894819/en-us/
)
Quanto esforço foi necessário para seguir os procedimentos deste artigo?
Muito baixo
Baixo
Moderado
Alto
Muito alto
O que podemos fazer para melhor estas informações?
Para proteger a sua privacidade, não inclua as informações de contacto nos comentários.
Obrigado! Os seus comentários serão utilizados para nos ajudar a melhorar o conteúdo do suporte. Para obter mais opções de assistência, visite a Home Page da Ajuda e Suporte.