FileView: Text-File Viewer Sample

Click to open or copy the files for the FileView sample.

The Fileview sample demonstrates the basic steps to implement a simple text-based file viewer. This sample is a viewer for text files, those with the TXT extension, as well as any compound file with the CLSID of CLSID_SampleTextFile, defined as 0x00021116-0000-C000-000000000046. The files Flattext.txt and Comptext.txt are two such files.

If you build the sample viewer and register it via the Fvtext.reg file, you will be able to use the sample viewer. Note that the system has a TXT file viewer installed by default. To disable the default viewer, rename the Vsasc8.dll file in the system\viewers subdirectory or edit Fvtext.reg and change the TXT extension to another extension not supported by QuickView, like XXX, and then use text files with the XXX extension.

You can build the sample using Microsoft NMAKE. Be aware that building the sample produces a DLL. Once this DLL is registered, clicking with the right mouse button on one of the TXT (XXX) files will display a context menu. Within this context menu, you will see the QuickView option. If you click on this menu item, the sample file viewer will be invoked.

Building SDK Samples

This sample uses the following keywords:

_lclose; _llseek; _lread; aboutproc; addref; alloc; appendmenu; beginpaint; cfileviewer; cfvclassfactory; checkmenuitem; childrenresize; choosefont; cimpifileviewer; cimpipersistfile; clienttoscreen; cogetmalloc; coinitialize; commdlgextendederror; copymemory; createfont; createfontindirect; createinstance; createpopupmenu; createstatuswindow; createtoolbarex; createwindow; createwindowex; cstatushelper; cstringtable; define_guid; defwindowproc; deleteobject; destroymenu; destroywindow; dialogbox; dispatchmessage; dllcanunloadnow; dllgetclassobject; dllmain; dragacceptfiles; dragfinish; dragqueryfile; drawtext; dropfiles; enddialog; endpaint; failed; fileload; fileshow; fileshowinit; fileviewerframeproc; findresource; finit; finitframecontrols; fontchange; fopenas; free; freeresource; getclassid; getclientrect; getcurfile; getdc; getdevicecaps; getmenu; getmenuitemcount; getmenuitemid; getmenustring; getmessage; getobject; getpinnedwindow; getscrollinfo; getsubmenu; getsyscolor; getwindowlong; getwindowrect; globalalloc; globalfree; globallock; globalunlock; idfromhmenu; interface; invalidaterect; isdirty; isequalclsid; isequaliid; istringfromid; iswindow; load; loadaccelerators; loadcursor; loadicon; loadmenu; loadresource; loadstring; localalloc; localfree; lockresource; lockserver; lstrcpy; lstrlen; makeintresource; malloc; max; mbstowcs; memalloc; memfree; memset; menuselect; messagebox; messagedisplay; messagemap; min; muldiv; objectdestroyed; ods; odslu; odssz; odsszlu; odsszu; odsu; offsetrect; oleinitialize; oncommand; openfile; openstream; outputdebugstring; postmessage; postquitmessage; printto; psztooltip; punkrel; queryinterface; registerclass; release; releasedc; replacewindowmodechange; resultfromscode; save; savecompleted; scrollwindow; selectobject; setbkcolor; setforegroundwindow; setpinnedwindow; setrect; setscrollinfo; setscrollpos; settextcolor; setwindowlong; setwindowpos; setwindowtext; shellexecuteex; show; showinitialize; showwindow; sizeofresource; sort; stat; stdmethodimp_; stgisstoragefile; stgopenstorage; string; succeeded; trackpopupmenu; translateaccelerator; translatemessage; unlockresource; unregisterclass; updatewindow; viewportresize; viewportscrollset; viewportwndproc; wcstombs; wsprintf