Makale numarası: 895602 - Son Gözden Geçirme: 16 Kasım 2007 Cuma - Gözden geçirme: 1.4

Resim yazdırma ve Visual FoxPro 9.0 kabarcık alanında depolanan resimleri görüntülemek için

Sistem İpucuBu makale, kullandığınızdan farklı bir işletim sistemine yöneliktir. Sizinle ilgili olmayabilecek makale içeriği devre dışı bırakıldı.

Bu Sayfada

Hepsini aç | Hepsini kapa

Özet

Visual FoxPro 9.0 kabarcık veri türünü tanıtır. Kabarcık alanları, resim gibi ikili veri depolamak için kullanabilirsiniz. Bir kabarcık alanda depolanan resimleri raporlara yazdırılır ve olması formlarda görüntülenir. Resim yazdırma ve bir kabarcık alanı. depolanan resimleri görüntülemek bu makalede

Giriş

Visual FoxPro 9.0 kabarcık veri türünü tanıtır. Kabarcık alanları, herhangi bir türdeki ve belirsiz uzunlukta ikili veri depolamak için kullanabilirsiniz. Örneğin, bir kabarcık alanı resim saklayabilirsiniz.

Bir rapordaki bir kabarcık alanı Resim/OLE bağlama denetimini kullanarak depolanan resimleri yazdırabilirsiniz. Bir kabarcık alanda depolanan resimleri yazdırmak için <a0></a0>, bir nesne başvurusu için kullanılan Resim/OLE ilişkili denetimin denetim kaynağı ayarlamanız gerekir. Nesne başvurusu bir Resim denetimi örneği olmalıdır. Bu örnek PictureVal özelliğini resimleri içeren bir kabarcık alanı ayarlanması gerekir.

Bir kabarcık alanı form üzerinde Resim denetiminin kullanılarak saklanan bir resim görüntüleyebilir. Doğrudan form üzerine Resim denetiminin yerleştirmek ve Resim denetiminin <a1>PictureVal</a1> özelliğini ayarlayın. Bu, kabarcık alana Resim denetiminin bağlama gidermektedir. Ancak, ek adımlar kabarcık alanı içeren tablonun kayıt işaretçisini hareket yeniden düzenleme için Resim denetiminin zorlamak için gereklidir.

Daha fazla bilgi

Aşağıdaki kod örnekleri Visual FoxPro 9.0 için tasarlanmıştır. Bu kod örnekleri, resimleri yazdırmak ve kabarcık alanı ikili veri olarak depolanan resimleri görüntülemek göster. Bu örneği sınamak için <a0></a0>, aşağıdaki adımları izleyin:
  1. Visual FoxPro 9. 0'ı başlatın ve iki yeni bir program oluşturun.
  2. Kopyalayın ve sonra <a1>örnek</a1> 1 yeni programlarından birini yapıştırın.
  3. Kopyalayın ve sonra da <a1>örnek</a1> 2 diğer yeni programa yapıştırın.
  4. Kaydetme ve programları çalıştırın.

Örnek 1: bir rapordaki bir kabarcık alanda depolanan resimleri yazdır

Aşağıdaki kod örneği, bir rapordaki bir kabarcık alanı ikili veri olarak depolanan resimleri yazdırmak gösterilmiştir.
*------------ START CODE
*
*-----------------------------------
* AUTHOR:    Trevor Hancock
* CREATED:   03/04/05 01:03:07 P.M.
* ABSTRACT: Code from Microsoft Knowledge Base
*                 article 895602. Visual FoxPro code that shows how
*                 to use pictures that are
*                 stored in a BLOB field in a report.
*                 This is accomplished by using an
*                 object reference to an instance of
*                 an IMAGE class as the control source for
*                 an OLE Bound control on the report. The IMAGE
*                 object has its PictureVal property set to a BLOB
*                 field in a cursor.
*-----------------------------------
LOCAL lcDataDIR AS STRING, ;
	lcThisDir AS STRING, ;
	loRL AS REPORTLISTENER

lcDataDIR = HOME( ) + 'Samples\Tastrade\'
lcThisDir = ADDBS( JUSTPATH( SYS( 16 ) ) )

CD ( lcThisDir )
CLOSE DATA ALL
*-- Create a temp cursor with a few fields, one of which is a
*-- BLOB. Store pictures in this field as raw binary data.
SELECT CAST( ALLTRIM( First_Name ) AS VARCHAR ( 10 ) ) AS 'FNAME', ;
	CAST( ALLTRIM( Last_Name ) AS VARCHAR (10 ) ) AS 'LNAME', ;
	CAST( FILETOSTR( lcDataDIR + Photo_File ) AS BLOB ) AS 'PIC' ;
	FROM ( lcDataDIR + 'data\Employee.dbf' ) ;
	INTO CURSOR ReportTemp

*-- Close the table that you selected from. It is not needed.
USE IN SELECT( 'EMPLOYEE' )

*-- This calls a function that makes a report programmatically.
*-- This is included here just to make sure that this sample can be run
*-- as-is, without asking the developer to manually create a report.
MakeReport()

*-- Create an instance of the PreviewListener
*-- class defined later in this code.
*-- Call its custom InitBLOBImage() method,
*-- which creates an instance of an IMAGE object.
*-- This IMAGE has its PictureVal property set to the BLOB
*-- field ( 'ReportTemp.PIC' ) and its reference ( loRL.oBlobImage )
*-- is used as the control source for the OLE Bound control 
*-- on the report.
loRL = NEWOBJECT( 'PreviewListener' )
loRL.InitBLOBImage( 'ReportTemp.PIC' )

*-- Make sure that the cursor is selected,
*-- and then run the report to preview using
*-- the instance of our Report Listener.
SELECT ReportTemp
REPORT FORM BlobReport OBJECT loRL
CLOSE DATA ALL
RETURN





*--------------------------------
*-- There has to be some way of redrawing the
*-- picture in the IMAGE class as the record pointer
*-- in the report's driving cursor changes; it does not occur
*-- automatically. This could be done by a UDF() in the PrintWhen
*-- of the OLE Bound control on the report, or as is illustrated here,
*-- by a Report Listener BEFOREBAND() Event.
DEFINE CLASS PreviewListener AS REPORTLISTENER
	oBlobImage = NULL
	PicBlobFld = ''
	LISTENERTYPE = 1  && Preview Listener

	PROCEDURE InitBLOBImage(lpcBlobField AS STRING)
		THIS.PicBlobFld = lpcBlobField
		THIS.oBlobImage = NEWOBJECT( 'IMAGE' )
		THIS.oBlobImage.PICTUREVAL = THIS.PicBlobFld
	ENDPROC

	PROCEDURE BEFOREBAND( nBandObjCode, nFRXRecNo )
		*-- Before the DETAIL band is rendered, ;
		*-- just redraw the IMAGE object so that it has
		*-- the correct picture from the BLOB field.
		IF nBandObjCode = 4 && Detail band
			THIS.oBlobImage.PICTUREVAL =;
				EVALUATE( THIS.PicBlobFld )
		ENDIF
	ENDPROC
ENDDEFINE




*--------------------------------
*-- This function programmatically creates a report
*-- with an OLE Bound control and other fields. This is included
*-- only for demonstration purposes so this article code can stand-alone.
*-- Typically, you would create your own report manually by using
*-- the report designer.
FUNCTION MakeReport
	CREATE REPORT BlobReport FROM ReportTemp

	*-- Open the report file (FRX) as a table.
	USE BlobReport.FRX IN 0 ALIAS TheReport EXCLUSIVE
	SELECT TheReport

	*-- Increase the height of the Detail band
	*-- (ObjType = 9 & ObjCode = 4) to fit the
	*-- Picture/OLE Bound control that is inserted later.
	UPDATE TheReport SET Vpos = 0, Hpos = 0, HEIGHT = 23542;
		WHERE ObjType = 9 AND ObjCode = 4

	*-- Since you increased the height of the Detail Band, you need to move
	*-- the items from the footer down so they are back in the footer again.
	UPDATE TheReport SET Vpos = 29479.167 ;
		WHERE ( ObjType = 8 OR ObjType = 5 ) AND ;
		INLIST( EXPR, 'DATE()', '"Page "', '_PAGENO' )

	*-- 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', 'loRL.oBlobImage' ) && The object ref to the IMAGE object.
	ADDPROPERTY( loNewRecObj, 'Hpos', 27500.000) && Place it in DETAIL band.
	ADDPROPERTY( loNewRecObj, 'Vpos', 3854.167)
	ADDPROPERTY( loNewRecObj, 'HEIGHT', 21354.167)
	ADDPROPERTY( loNewRecObj, 'WIDTH', 25104.167)
	ADDPROPERTY( loNewRecObj, 'DOUBLE', .T. ) && 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
	*-- Filename (0), General field name (1), or Expression (2) is the source.
	ADDPROPERTY( loNewRecObj, 'Offset', 2 )

	*-- 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 IN SELECT( 'TheReport' )
ENDFUNC
*
*------------ END CODE

Örnek 2: bir kabarcık alanı form üzerinde depolanan resimleri görüntüler.

Aşağıdaki kod örneği, bir formdaki bir kabarcık alanı ikili veri olarak depolanan resimleri görüntülemek gösterilmiştir.
*------------ START CODE
*
*-----------------------------------
* AUTHOR:    Trevor Hancock
* CREATED:   03/04/05 01:03:07 P.M.
* ABSTRACT: Code from Microsoft Knowledge Base
*                 article 895602. Visual FoxPro code that shows how
*                 to display pictures that are
*                 stored in a BLOB field on a form.
*-----------------------------------
CLOSE DATA ALL

*-- Create a temp cursor with a BLOB field.
*-- Store pictures in this field as raw binary data.
SELECT 	;
	CAST( ;
	FILETOSTR( HOME( ) + 'Samples\Tastrade\' + Photo_File ) ;
	AS BLOB ) AS 'PIC' FROM ;
	HOME( ) + 'Samples\Tastrade\data\Employee.dbf' ;
	INTO CURSOR BlobTemp

*-- Close the table that you selected from. It is not needed.
USE IN SELECT( 'EMPLOYEE' )

*-- Create a form to display the pictures.
PUBLIC goForm
goForm = NEWOBJECT( 'Form' )

WITH goForm AS FORM
	*-- Add an IMAGE class to display the pictures.
	*-- This is done by setting the PICTUREVAL
	*-- property of the IMAGE.
	.ADDOBJECT( 'IMG1', 'Image' )
	.Img1.PICTUREVAL = BlobTemp.PIC

	*-- Add an EditBox to display the raw
	*-- binary data directly out of the BLOB field.
	*-- This is not required, just fun to see the raw data.
	.ADDOBJECT( 'Edt1', 'EditBox' )
	.Edt1.MOVE(.Img1.WIDTH + 5, 0, .Img1.WIDTH, .Img1.HEIGHT)
	.Edt1.CONTROLSOURCE = 'BlobTemp.PIC'

	*-- Add record navigation buttons so that you can
	*-- move records in the cursor. The NAV class
	*-- is defined later in this code.
	.ADDOBJECT( 'NAV', 'NavBtns' )
	.NAV.MOVE( (.WIDTH - .NAV.WIDTH) + 13 , .Edt1.HEIGHT + 2 )

	.WIDTH = .Img1.WIDTH + .Edt1.WIDTH + 7
	*-- Make the form pretty by setting a few anchors
	*-- and setting MinWidth/Height.
	.NAV.ANCHOR = 192
	.Edt1.ANCHOR = 15
	.MINWIDTH = .WIDTH
	.MINHEIGHT = .HEIGHT
	.AUTOCENTER = .T.
	.CAPTION = 'Picture and Raw BLOB Data'
	.SETALL( 'VISIBLE', .T. )
ENDWITH

goForm.SHOW(1)
CLOSE DATA ALL


*--------------------------------
*-- This is just a subclass of the FoxPro Foundation Class
*-- named _DataNavBtns (located in HOME() + '\FFC\_datanav.vcx').
*-- This is where you redraw the BLOB data displayed by the IMAGE
*-- class by resetting the PICTUREVAL property of that class
*-- just before skipping records. Unlike an OLE Bound control populated
*-- by a GENERAL field, the IMAGE does not redraw its BLOB data automatically
*-- as the record pointer moves. This is how you force it.
DEFINE CLASS NavBtns AS _datanavbtns OF HOME() + '\FFC\_datanav.vcx'
	BORDERWIDTH = 0
	PROCEDURE EnableDisableButtons
		THIS.PARENT.Img1.PICTUREVAL = BlobTemp.PIC
		DODEFAULT()
ENDDEFINE
*
*------------ END CODE

Referanslar

PictureVal özelli?i hakk?nda daha fazla bilgi için aşağıdaki Microsoft Web sitesini ziyaret edin:
http://msdn2.microsoft.com/en-us/library/ms953566(vs.80).aspx (http://msdn2.microsoft.com/en-us/library/ms953566(vs.80).aspx)
Daha fazla bilgi için bkz: "Yuvalanabilir Resim Görüntüleyicisi" örnek Visual FoxPro Solution örnekleri uygulamasında Visual FoxPro 9.0 ile birlikte gelir.

Bu makaledeki bilginin uygulandığı durum:
  • Microsoft Visual FoxPro 9.0 Professional Edition
Anahtar Kelimeler: 
kbmt kbhowto kbcodesnippet KB895602 KbMttr
Otomatik TercümeOtomatik Tercüme
ÖNEMLİ: Bu makale, bir kişi tarafından çevrilmek yerine, Microsoft makine-çevirisi yazılımı ile çevrilmiştir. Microsoft size hem kişiler tarafından çevrilmiş, hem de makine-çevrisi ile çevrilmiş makaleler sunar. Böylelikle, bilgi bankamızdaki tüm makalelere, kendi dilinizde ulaşmış olursunuz. Bununla birlikte, makine tarafından çevrilmiş makaleler mükemmel değildir. Bir yabancının sizin dilinizde konuşurken yapabileceği hatalar gibi, makale; kelime dağarcığı, söz dizim kuralları veya dil bilgisi açısından yanlışlar içerebilir. Microsoft, içeriğin yanlış çevrimi veya onun müşteri tarafından kullanımından doğan; kusur, hata veya zarardan sorumlu değildir. Microsoft ayrıca makine çevirisi yazılımını sıkça güncellemektedir.
Makalenin İngilizcesi aşağıdaki gibidir:895602  (http://support.microsoft.com/kb/895602/en-us/ )