Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

The Mini Shell Extension Framework – Part III

, 18 Sep 2005
Discussion of a small C++ framework to create Windows shell extensions (IShellFolderImpl).
msf091.zip
include
columnprovider.rgs
contextmenu.rgs
contextmenu_sf.rgs
extension.rgs
extractimage_sf.rgs
infotip.rgs
infotip_sf.rgs
propertysheetext.rgs
propertysheetext_sf.rgs
shell32missing.def
shell32missing.lib
shellfolder.rgs
shellfolderwin98.rgs
vvvsample
Copy of sample1.vvv
menuicon.bmp
sample.def
sample.manifest
sample1.vvv
vvv.ico
vvvtest
sample.yyy
sample1.vvv
sample2.vvv
//
// (C) Copyright by Victor Derks <vba64@xs4all.nl>
//
// See README.TXT for the details of the software licence.
//
#include "stdafx.h"
#include "../include/extractimageimpl.h"
#include "extractimageclsid.h"
#include "shellfolderclsid.h"
#include "resource.h"


class ATL_NO_VTABLE CExtractImage :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CExtractImage, &__uuidof(CExtractImage)>,
	public IExtractImageImpl<CExtractImage>
{
public:
	BEGIN_COM_MAP(CExtractImage)
		COM_INTERFACE_ENTRY(IPersistFile)
		COM_INTERFACE_ENTRY(IExtractImage)
		COM_INTERFACE_ENTRY(IExtractImage2)
	END_COM_MAP()

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	static HRESULT WINAPI UpdateRegistry(BOOL bRegister) throw()
	{
		return IExtractImageImpl<CExtractImage>::UpdateRegistry(IDR_EXTRACTIMAGE, bRegister,
			L"Sample ShellExtension ExtractImage", __uuidof(CShellFolder), wszVVVExtension);
	}


	HBITMAP CreateImage(const SIZE& size, DWORD dwRecClrDepth, DWORD /*dwFlags*/)
	{
		// TODO: fix this function
		HBITMAP hbitmap = CreateBitmap(size.cx, size.cy, 1, dwRecClrDepth, NULL);

		HDC hdc = CreateCompatibleDC(NULL);

		HGDIOBJ hgdiobjectOriginal = SelectObject(hdc, hbitmap);

		HBRUSH hbrush = CreateSolidBrush(RGB(0, 0, 255));

		RECT rect = {0, 0, size.cx, size.cx};
		FillRect(hdc, &rect, hbrush);

		DeleteObject(hbrush);
		hgdiobjectOriginal = SelectObject(hdc, hgdiobjectOriginal);
		DeleteDC(hdc);

		return hbitmap;
	}
};

#if 0
HDC dc= CreateCompatibleDC(NULL);
BITMAPINFO i;
ZeroMemory( &i.bmiHeader, sizeof(BITMAPINFOHEADER) );
i.bmiHeader.biWidth=5;     // Set size you need
i.bmiHeader.biHeight=5;    // Set size you need
i.bmiHeader.biPlanes=1;
i.bmiHeader.biBitCount=24; // Can be 8, 16, 32 bpp or
                           // other number
i.bmiHeader.biSizeImage=0;
i.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
i.bmiHeader.biClrUsed= 0;
i.bmiHeader.biClrImportant= 0;
VOID *pvBits;
HBITMAP hbmp= CreateDIBSection( dc,
                                &i,
                                DIB_RGB_COLORS,
                                &pvBits,
                                NULL,
                                0 );

// --------------------------

	HBITMAP Create_DIB_Sec( int cxImage, int cyImage,
        int nBitsPerPixel, void **ppImageBits )
{
    HDC hDC = GetDC( NULL );
 
    BITMAPINFO BitmapInfo;
    ZeroMemory( &BitmapInfo, sizeof(BITMAPINFO) );
    BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    BitmapInfo.bmiHeader.biWidth = cxImage;
    BitmapInfo.bmiHeader.biHeight = cyImage;
    BitmapInfo.bmiHeader.biPlanes = 1;
    BitmapInfo.bmiHeader.biBitCount = nBitsPerPixel;
    BitmapInfo.bmiHeader.biCompression = BI_RGB;
    BitmapInfo.bmiHeader.biSizeImage =
        ( 4 * ((m_cxImage * nBitsPerPixel + 31) / 32) ) * m_cyImage;
 
    HBITMAP hBitmap = CreateDIBSection( hDC,
        &BitmapInfo, DIB_RGB_COLORS,
        ppImageBits, NULL, 0 );
 
    ReleaseDC( NULL, hDC );
 
    return hBitmap;
}

#endif

OBJECT_ENTRY_AUTO(__uuidof(CExtractImage), CExtractImage)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Victor Derks
Software Developer (Senior) Schneider Electric
Netherlands Netherlands
Victor lives in Nijmegen, the oldest city in The Netherlands.
He studied Applied Physics in Delft and now works for GE Healthcare.

| Advertise | Privacy | Mobile
Web04 | 2.8.140718.1 | Last Updated 18 Sep 2005
Article Copyright 2005 by Victor Derks
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid