<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>知识库 &#187; 代码片断</title>
	<atom:link href="http://www.wezu.net/blog/archives/category/%e4%bb%a3%e7%a0%81%e7%89%87%e6%96%ad/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wezu.net/blog</link>
	<description>知识就是力量，知识就是财富！</description>
	<lastBuildDate>Fri, 06 Feb 2009 03:15:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>让你的程序具备XP风格</title>
		<link>http://www.wezu.net/blog/archives/7</link>
		<comments>http://www.wezu.net/blog/archives/7#comments</comments>
		<pubDate>Tue, 25 Dec 2007 09:19:03 +0000</pubDate>
		<dc:creator>snox</dc:creator>
				<category><![CDATA[代码片断]]></category>

		<guid isPermaLink="false">http://www.wezu.net/blog/?p=7</guid>
		<description><![CDATA[  以上说的适用于MFC，如果用win32   sdk的话，还是应该参照MSDN.     只不过MFC7.1把以下这些自动化了。         大意是：（我用xpstyle代表项目名）         1。做一个xml文件：xpstyle.manifest      Your application description here.           2.程序初始化时，运行     InitCommonControls();         3.在resoure.h中加       #define   IDR_MANIFEST CREATEPROCESS_MANIFEST_RESOURCE_ID           4.在xpstyle.rc中加         #ifdef   _UNICODE     IDR_MANIFEST RT_MANIFEST "res\\xpstyle.manifest     #endif         5.最后还是要将项目设为UNICODE字符集编译。         6.另外，如果写dll,或者其他的,参照(MSDN2003-4)             ms-help://MS.MSDNQTR.2003APR.1033/shellcc/platform/commctls/userex/cookbook.htm#no_extensions]]></description>
			<content:encoded><![CDATA[<p>  以上说的适用于MFC，如果用win32   sdk的话，还是应该参照MSDN.  <br />
  只不过MFC7.1把以下这些自动化了。  <br />
   <br />
  大意是：（我用xpstyle代表项目名）  <br />
   <br />
  1。做一个xml文件：xpstyle.manifest     </p>
<pre lang="xml">
<?xml   version="1.0"   encoding="UTF-8"   standalone="yes"?>
  <assembly   xmlns="urn:schemas-microsoft-com:asm.v1"   manifestVersion="1.0">
  <assemblyIdentity
          version="1.0.0.0"
          processorArchitecture="X86"
          name="CompanyName.ProductName.xpstyle"
          type="win32"
  />
  <description>Your   application   description   here.</description>
  <dependency>
          <dependentAssembly>
                  <assemblyIdentity
                          type="win32"
                          name="Microsoft.Windows.Common-Controls"
                          version="6.0.0.0"
                          processorArchitecture="X86"
                          publicKeyToken="6595b64144ccf1df"
                          language="*"
                  />
          </dependentAssembly>
  </dependency>
  </assembly></pre>
<p>   <br />
   <br />
  2.程序初始化时，运行  <br />
 
<pre lang="cpp">InitCommonControls();  </pre>
<p>   <br />
  3.在resoure.h中加  <br />
   
<pre lang="cpp">#define   IDR_MANIFEST CREATEPROCESS_MANIFEST_RESOURCE_ID    </pre>
<p>   <br />
  4.在xpstyle.rc中加  <br />
   <br />
 
<pre lang="cpp">#ifdef   _UNICODE  
  IDR_MANIFEST RT_MANIFEST "res\\xpstyle.manifest  </pre>
<p>  #endif  <br />
   <br />
  5.最后还是要将项目设为UNICODE字符集编译。  <br />
   <br />
  6.另外，如果写dll,或者其他的,参照(MSDN2003-4)  <br />
   <br />
      ms-help://MS.MSDNQTR.2003APR.1033/shellcc/platform/commctls/userex/cookbook.htm#no_extensions</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wezu.net/blog/archives/7/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IExtractImage</title>
		<link>http://www.wezu.net/blog/archives/3</link>
		<comments>http://www.wezu.net/blog/archives/3#comments</comments>
		<pubDate>Thu, 01 Nov 2007 17:30:47 +0000</pubDate>
		<dc:creator>snox</dc:creator>
				<category><![CDATA[代码片断]]></category>

		<guid isPermaLink="false">http://www.wezu.net/blog/?p=3</guid>
		<description><![CDATA[void* CShellListCtrl::GetThumbnailImage(CString &#38;fileName, int longestEdge, int colorDepth) {  // divide the file name into a folder path and file name.  WCHAR wDirName[MAX_PATH];  WCHAR wFileName[MAX_PATH];  CString dir = fileName.Left(fileName.ReverseFind('\\'));  CString file = fileName.Right(fileName.GetLength() - dir.GetLength() - 1);  TCHAR tName[MAX_PATH];  strcpy(tName, dir.GetBuffer());  wcscpy(wDirName, CT2W(tName));    strcpy(tName, file.GetBuffer());  wcscpy(wFileName, CT2W(tName));  IShellFolder* pDesktop = NULL;  IShellFolder* pSub = NULL;  IExtractImage* pIExtract = [...]]]></description>
			<content:encoded><![CDATA[<pre lang="cpp" lineno="1">void* CShellListCtrl::GetThumbnailImage(CString &amp;fileName, int longestEdge, int colorDepth)
{
 // divide the file name into a folder path and file name.
 WCHAR wDirName[MAX_PATH];
 WCHAR wFileName[MAX_PATH];
 CString dir = fileName.Left(fileName.ReverseFind('\\'));
 CString file = fileName.Right(fileName.GetLength() - dir.GetLength() - 1);
 TCHAR tName[MAX_PATH];
 strcpy(tName, dir.GetBuffer());
 wcscpy(wDirName, CT2W(tName));
 
 strcpy(tName, file.GetBuffer());
 wcscpy(wFileName, CT2W(tName));
 IShellFolder* pDesktop = NULL;
 IShellFolder* pSub = NULL;
 IExtractImage* pIExtract = NULL;
 LPITEMIDLIST pList = NULL;
 HBITMAP   hBmp = NULL;

 // get the desktop directory
 if (SUCCEEDED(SHGetDesktopFolder(&amp;pDesktop)))
 {
  // get the pidl for the directory
  HRESULT hr = pDesktop-&gt;ParseDisplayName(NULL, NULL, wDirName, NULL, &amp;pList, NULL);
  if (FAILED(hr))
  { 
   throw new CUserInterfaceException("Failed to parse the directory name");
  }

  // get the directory IShellFolder interface
  hr = pDesktop-&gt;BindToObject(pList, NULL, IID_IShellFolder, (void**)&amp;pSub);
  if (FAILED(hr))
  {
   throw new CUserInterfaceException("Failed to bind to the directory");
  }

  // get the file's pidl
  hr = pSub-&gt;ParseDisplayName(NULL, NULL, wFileName, NULL, &amp;pList, NULL);
  if (FAILED(hr))
  {
   throw new CUserInterfaceException("Failed to parse the file name");
  }

  // get the IExtractImage interface
  LPCITEMIDLIST pidl = pList;
  hr = pSub-&gt;GetUIObjectOf(NULL, 1, &amp;pidl, IID_IExtractImage, NULL, (void**)&amp;pIExtract);
  
  // set our desired image size
  SIZE size;
  size.cx = longestEdge;
  size.cy = longestEdge;     
  
  if(pIExtract == NULL)
  {
   return NULL;
  }        

  // The IEIFLAG_ORIGSIZE flag tells it to use the original aspect
  // ratio for the image size. The IEIFLAG_QUALITY flag tells the
  // interface we want the image to be the best possible quality.
  DWORD dwFlags = IEIFLAG_ORIGSIZE | IEIFLAG_QUALITY;     
  
  OLECHAR pathBuffer[MAX_PATH];
  hr = pIExtract-&gt;GetLocation(pathBuffer, MAX_PATH, NULL, &amp;size, colorDepth, &amp;dwFlags);        
  if (FAILED(hr))
  {
   throw new CUserInterfaceException("The call to GetLocation failed");
  }

  hr = pIExtract-&gt;Extract(&amp;hBmp);  //THIS IS WHERE I GET THE ERROR MESSAGE

  pIExtract-&gt;Release();
 } // if

 // Release the COM objects we have a reference to.
 pDesktop-&gt;Release();
 pSub-&gt;Release();

 return hBmp;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.wezu.net/blog/archives/3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
