The following file is available for download from the Microsoft Download Center:
Release Date: June 26, 2002
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
The PictureDownload.exe file contains the following files:
File name | Size |
---|
_PictureDownloadProj.h | 11 KB |
_PictureDownloadProj.tlb | 3 KB |
_PictureDownloadProj.idl | 2 KB |
dlldata.c | 1 KB |
picture.bmp | 406 bytes |
picture2.bmp | 406 bytes |
picture3.bmp | 406 bytes |
PictureDownload.cpp | 2 KB |
PictureDownload.h | 4 KB |
PictureDownload.htm | 2 KB |
PictureDownloadProj.aps | 4 KB |
PictureDownloadProj.cpp | 1 KB |
PictureDownloadProj.ncb | 2 KB |
PictureDownloadProj.rc | 3 KB |
PictureDownloadProj.rgs | 1 KB |
PictureDownloadProj.sln | 2 KB |
PictureDownloadProj.suo | 9 KB |
PictureDownloadProj.vcproj | 4 KB |
PictureDownloadProjps.def | 1 KB |
PictureDownloadProjPS.vcproj | 4 KB |
Readme.txt | 4 KB |
Resource.h | 1 KB |
stdafx.cpp | 1 KB |
stdafx.h | 2 KB |
PictureDownloadVC6/dlldata.c | 1 KB |
PictureDownloadVC6/dlldatax.c | 2 KB |
PictureDownloadVC6/dlldata.h | 1 KB |
PictureDownloadVC6/pictured.bmp | 407 KB |
PictureDownloadVC6/PictureDownload.cpp | 3 KB |
PictureDownloadVC6/PictureDownload.h | 4 KB |
PictureDownloadVC6/PictureDownload.htm | 2 KB |
PictureDownloadVC6/PictureDownload.rgs | 1 KB |
PictureDownloadVC6/PictureDownloadVC6.aps | 5 KB |
PictureDownloadVC6/PictureDownloadVC6.cpp | 4 KB |
PictureDownloadVC6/PictureDownloadVC6.def | 1 KB |
PictureDownloadVC6/PictureDownloadVC6.dsp | 14 KB |
PictureDownloadVC6/PictureDownloadVC6.dsw | 1 KB |
PictureDownloadVC6/PictureDownloadVC6.h | 8 KB |
PictureDownloadVC6/PictureDownloadVC6.idl | 1 KB |
PictureDownloadVC6/PictureDownloadVC6.plg | 4 KB |
PictureDownloadVC6/PictureDownloadVC6.rc | 4 KB |
PictureDownloadVC6/PictureDownloadVC6.tlb | 2 KB |
PictureDownloadVC6/PictureDownloadVC6_i.c | 2 KB |
PictureDownloadVC6/PictureDownloadVC6_p.c | 2 KB |
PictureDownloadVC6/PictureDownloadVC6ps.def | 1 KB |
PictureDownloadVC6/PictureDownloadVC6ps.mk | 1 KB |
PictureDownloadVC6/resource.h | 1 KB |
PictureDownloadVC6/StdAfx.cpp | 1 KB |
PictureDownloadVC6/StdAfx.h | 1 KB |
NOTE: The main directory of the uncompressed sample is a Microsoft Visual C++ .NET project. The subdirectory PictureDownloadVC6 contains the same code, except in a Visual C++ 6.0 project.
Security Update Q313675 disables a feature that is known as
Inline Data in Internet Explorer. You can use the
Inline Data feature to allow base64-encoded binary data to be assigned to an ActiveX control. However, you may have already written Web pages that use the
TreeView control and the
ImageList control as described in the Microsoft Knowledge Base article Q184975 that is listed in the "References" section of this article.
In this sample, the images of the
ImageList control are loaded by encoding all of the images in base64. Then you can assign the later string to the
DATA attribute of the <OBJECT> tag of the
ImageList. This is the feature that Security Update Q313675 disables. However, you can easily develop a small ActiveX control that fetches .bmp images and then returns the
IDispatch pointer from the
IPictureDisp image, which is the COM/OLE interface that
ImageList requires to add an image. This workaround has two advantages:
- Much of your existing Dynamic Hypertext Markup Language (DHTML) code that uses the TreeView control can be preserved. You can easily add some additional lines to load the ImageList. You can also insert an <OBJECT> tag for the PictureDownload ActiveX control.
- You can load your images if you use URL references. This feature is missing from the ImageList control.
PictureDownload.dll
PictureDownload.dll defines a simple ActiveX control with a single external method,
DownloadPicture, which takes a URL reference to an image and returns an
IDispatch. You can do this if you use the COM function
OleLoadPicturePath as shown in the following sample:
STDMETHODIMP CPictureDownload::DownloadPicture(BSTR url, IDispatch **pictureRet) {
HRESULT hr = S_OK;
IPictureDisp *picDisp = NULL;
// Verify that this is a valid absolute URL.
// !TODO: Allow consumers to specify virtual and relative paths also.
*pictureRet = NULL;
if (S_FALSE == IsValidURL(NULL, url, 0)) {
Error(L"Cannot download picture: The URL specified is not valid, or is not an absolute URL. PictureDownload only accepts absolute URLs as arguments.", __uuidof(IPictureDownload), E_FAIL);
// S_FALSE will not throw a script error.
hr = E_FAIL;
goto cleanup;
}
hr = ::OleLoadPicturePath(url, NULL, 0, 0, IID_IPictureDisp, reinterpret_cast<void **>(&picDisp));
if (FAILED(hr)) {
if (E_NOINTERFACE == hr) {
Error(L"Cannot download picture: URL does not specify a valid picture file. Please reference BMP or ICO files only.", __uuidof(IPictureDownload), E_FAIL);
} else if (FACILITY_INTERNET == HRESULT_FACILITY(hr)) {
Error(L"Cannot download picture: Site cannot be reached, or resource does not exist.", __uuidof(IPictureDownload), E_FAIL);
} else {
Error(L"Cannot download picture: Generic failure.", __uuidof(IPictureDownload), E_FAIL);
}
goto cleanup;
}
hr = picDisp->QueryInterface(IID_IDispatch, reinterpret_cast<void**>(pictureRet));
cleanup:
if (NULL != picDisp) {
picDisp->Release();
}
return hr;
}
PictureDownload.htm
After you compile the component, you must instrument your HTML file to load the
ImageList from the
PictureDownload component instead of from the
DATA attribute of the <OBJECT> tag of the
ImageList. You must first include an <OBJECT> tag for your own component:
<OBJECT ID="PictureDownload" CLASSID="CLSID:A6A7F245-14DF-4050-82E2-C9FD65AC4DD7" style="display:none;">
</OBJECT>
You must use the following code to download the images files from
PictureDownload, one at a time, and then add the images files to the
ImageList:
' Load up images.
set pic = PictureDownload.DownloadPicture("http://localhost/PictureDownloadProj/picture.bmp")
myImageList.ListImages.Add 1, "Pic1", pic
set pic = PictureDownload.DownloadPicture("http://localhost/PictureDownloadProj/picture2.bmp")
myImageList.ListImages.Add 2, "Pic2", pic
set pic = PictureDownload.DownloadPicture("http://localhost/PictureDownloadProj/picture3.bmp")
myImageList.ListImages.Add 3, "Pic3", pic
From there, you can load nodes in your
TreeView and associate images with the nodes:
' Initialize tree.
Set node = TreeView1.Nodes.Add(,,"KEY1", "Test1")
node.expanded=true
node.Image=1
Set node = TreeView1.Nodes.Add("KEY1",4,"KEY2", "Test1-1")
node.expanded=true
node.Image=2
Set node = TreeView1.Nodes.Add("KEY1",4,"KEY3", "Test1-2")
node.expanded=true
node.Image=3
Deploy PictureDownload
To deploy the
PictureDownload method, you must create a cabinet (.cab) file for the Internet Component download. If you use the Microsoft Visual C++ .NET project, you can use the Cabinet Project type under Setup and Deployment Project.
- Start Microsoft Visual Studio .NET.
- On the File menu, point to New, and then click Project.
To use the .cab file on your Web page, visit the following Microsoft Web site:
NOTE: The
DownloadPicture method accepts absolute URL inputs only. If an error occurs you must verify that the URL passed to the function is a valid URL.