Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Document Thumbnail/Preview
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00705305
Message ID:
00705822
Views:
17
>How can I display a small image preview of any document?
>
>I assume there is an API that does this since Windows Explorer provides this feature as you scroll thru documents. In my case, most of the documents will be PDF and WORD, but certainly not all.

Troy,

Windows Explorer uses ThumbCtl ActiveX control. You cannot use it directly in VFP form, but you could place it on HTML page and display this page in WebBrowser control. The DisplayFile method of this control displays thumbnail for selected file:
PUBLIC oForm1
oForm1 = NewObject("thumb")
oForm1.Show
RETURN

DEFINE CLASS thumb AS form
	Height = 277
	Width = 361
	DoCreate = .T.
	AutoCenter = .T.
	Caption = "Thumbnail Preview"
	Name = "Form1"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 240, ;
		Left = 276, ;
		Height = 25, ;
		Width = 73, ;
		Caption = "Select", ;
		Name = "Command1"

	ADD OBJECT olecontrol1 AS olecontrol WITH ;
		Top = 12, ;
		Left = 12, ;
		Height = 252, ;
		Width = 252, ;
		OleClass = "Shell.Explorer.2"
		Name = "Olecontrol1"

	PROCEDURE Init
		ThisForm.olecontrol1.navigate2("d:\thumb.htm")
	ENDPROC

	PROCEDURE command1.Click
		Local lcFile
		lcFile = GetFile("*", "Select", "Preview", 0, "Select a file for preview")
		ThisForm.olecontrol1.document.all.Thumbnail.DisplayFile(lcFile)
	ENDPROC

	PROCEDURE olecontrol1.Refresh
		*** ActiveX Control Method ***
		NoDefault
	ENDPROC

ENDDEFINE
where thumb.htm file looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY>
<OBJECT id=ThumbCtl1 style="LEFT: 0px; TOP: 0px"
classid=clsid:71650000-E8A8-11D2-9652-00C04FC30871 name=Thumbnail></OBJECT>
</BODY></HTML>
Notice that Office documents can be previewed only if they've been saved with an embedded preview picture. (There is a checkbox in the Properties dialog.)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform