IEShellComboBox.cpp
上传用户:yatsl7111
上传日期:2007-01-08
资源大小:1433k
文件大小:16k
源码类别:

图形图象

开发平台:

Visual C++

  1. //*******************************************************************************
  2. // COPYRIGHT NOTES
  3. // ---------------
  4. // You may use this source code, compile or redistribute it as part of your application 
  5. // for free. You cannot redistribute it as a part of a software development 
  6. // library without the agreement of the author. If the sources are 
  7. // distributed along with the application, you should leave the original 
  8. // copyright notes in the source code without any changes.
  9. // This code can be used WITHOUT ANY WARRANTIES at your own risk.
  10. // 
  11. // For the latest updates to this code, check this site:
  12. // http://www.masmex.com 
  13. // after Sept 2000
  14. // 
  15. // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
  16. //*******************************************************************************
  17. // IEShellComboBox.cpp : implementation file
  18. //
  19. #include "stdafx.h"
  20. #include "UIMessages.h"
  21. #include "IEShellComboBox.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. const CString strURLKey(_T("Software\Microsoft\Internet Explorer\TypedURLs"));
  28. const CString strIEKey(_T("\CLSID\{0002DF01-0000-0000-C000-000000000046}\LocalServer32"));
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CIEShellComboBox
  31. CIEShellComboBox::CIEShellComboBox()
  32. {
  33. m_pidlMyComputer = NULL;
  34. m_pidlMyDocuments = NULL;
  35. m_pidlInternet = NULL;
  36. m_hImageList = NULL;
  37. m_hTreeWnd = NULL;
  38. m_hIcon = NULL;
  39. SHGetMalloc(&m_pMalloc);
  40. m_bInternet = false;
  41. }
  42. CIEShellComboBox::~CIEShellComboBox()
  43. {
  44. DeleteAllItemData();
  45. CShCMSort *pItem=NULL;
  46. STL_FOR_ITERATOR(vecCMSort,m_vItems)
  47. {
  48. pItem = STL_GET_CURRENT(m_vItems);
  49. DeleteItemData((LPTVITEMDATA)pItem->GetItemData());
  50. delete pItem;
  51. }
  52. if (m_pMalloc)
  53. {
  54. if (m_pidlInternet)
  55. m_pMalloc->Free(m_pidlInternet);
  56. if (m_pidlMyComputer)
  57. m_pMalloc->Free(m_pidlMyComputer);
  58. if (m_pidlMyDocuments)
  59. m_pMalloc->Free(m_pidlMyDocuments);
  60. m_pMalloc->Release();
  61. }
  62. if (m_hIcon)
  63. ::DestroyIcon(m_hIcon);
  64. }
  65. void CIEShellComboBox::DeleteAllItemData()
  66. {
  67. for(vecItemData::iterator it=m_vecItemData.begin();it != m_vecItemData.end();it++)
  68. {
  69. DeleteItemData(*it);
  70. }
  71. m_vecItemData.erase(m_vecItemData.begin(),m_vecItemData.end());
  72. }
  73. void CIEShellComboBox::DeleteItemData(LPTVITEMDATA pItemData)
  74. {
  75. if (pItemData == NULL)
  76. return;
  77. if (pItemData->lpsfParent)
  78. pItemData->lpsfParent->Release();
  79. if (pItemData->lpi)
  80. m_pMalloc->Free(pItemData->lpi);  
  81. if (pItemData->lpifq)
  82. m_pMalloc->Free(pItemData->lpifq);  
  83. m_pMalloc->Free(pItemData);
  84. }
  85. LPITEMIDLIST CIEShellComboBox::GetSelectedPidl()
  86. {
  87. int nCurSel = GetCurSel();
  88. if (nCurSel == -1)
  89. return NULL;
  90. LPTVITEMDATA lptvid = (LPTVITEMDATA)GetItemData(nCurSel);
  91. if (lptvid == NULL)
  92. return NULL;
  93. return GetShellPidl().CopyItemIDList(lptvid->lpifq);
  94. }
  95. BEGIN_MESSAGE_MAP(CIEShellComboBox, CComboBoxEx)
  96. //{{AFX_MSG_MAP(CIEShellComboBox)
  97. ON_MESSAGE(WM_APP_CB_IE_HIT_ENTER,OnAppCbIeHitEnter)
  98. ON_WM_CREATE()
  99. ON_WM_DESTROY()
  100. ON_WM_SETFOCUS()
  101. ON_WM_KILLFOCUS()
  102. ON_CONTROL_REFLECT(CBN_DROPDOWN, OnDropDown)
  103. ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelChange)
  104. //}}AFX_MSG_MAP
  105. ON_MESSAGE(WM_APP_CB_IE_POPULATE,OnCBIEPopulate)
  106. END_MESSAGE_MAP()
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CIEShellComboBox message handlers
  109. void CIEShellComboBox::Populate(LPITEMIDLIST pidlAbsSel)
  110. {
  111. if (m_hImageList == NULL)
  112. SetShellImageList();
  113. if (STL_EMPTY(m_vItems))
  114. InitItems(pidlAbsSel);
  115. if (GetShellPidl().ComparePidls(NULL,pidlAbsSel,m_pidlInternet))
  116. LoadURLPrevList();
  117. else
  118. LoadItems(pidlAbsSel);
  119. }
  120. void CIEShellComboBox::LoadURLPrevList()
  121. {
  122. if (m_ImageList.m_hImageList)
  123. ::SendMessage(GetSafeHwnd(), CBEM_SETIMAGELIST, 0, (LPARAM)m_ImageList.m_hImageList);
  124. ResetContent();
  125. HKEY hKey;
  126. if (RegOpenKeyEx(HKEY_CURRENT_USER,strURLKey,0,KEY_READ,&hKey) != ERROR_SUCCESS)
  127. return;
  128. TCHAR szValueName[_MAX_PATH];
  129. BYTE pData[_MAX_PATH];
  130. DWORD dwSizeValueName = sizeof(szValueName)-1;
  131. DWORD dwSizeData = sizeof(pData)-1;
  132. DWORD dwType=0;
  133. COMBOBOXEXITEM item;
  134. ZeroMemory(&item,sizeof(item));
  135. item.mask |= (CBEIF_IMAGE | CBEIF_TEXT | CBEIF_SELECTEDIMAGE);
  136. item.iItem = -1;
  137. item.iImage = 0;
  138. for(DWORD dwIndex=0;RegEnumValue(hKey,
  139.   dwIndex, 
  140.   szValueName, 
  141.   &dwSizeValueName,
  142.   NULL,
  143.   &dwType,
  144.   pData,
  145.   &dwSizeData) == ERROR_SUCCESS;dwIndex++)
  146. {
  147. item.pszText = (LPTSTR)(LPCTSTR)pData;
  148. item.cchTextMax = lstrlen(item.pszText);
  149. InsertItem(&item);
  150. dwSizeValueName = sizeof(szValueName)-1;
  151. dwSizeData = sizeof(pData)-1;
  152. }
  153. RegCloseKey(hKey);
  154. m_bInternet = true;
  155. }
  156. void CIEShellComboBox::InitItems(LPITEMIDLIST pidlAbsSel)
  157. {
  158. LPSHELLFOLDER psfDesktop=NULL;
  159. LPITEMIDLIST pidlDesktop=NULL;
  160. HRESULT hr = SHGetDesktopFolder(&psfDesktop);
  161. SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidlDesktop);
  162.     SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &m_pidlMyComputer); 
  163.     SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &m_pidlMyDocuments); 
  164. SHGetSpecialFolderLocation(NULL, CSIDL_INTERNET, &m_pidlInternet);
  165. int nImage=0, nSelImage=0;
  166. SHFILEINFO fileInfo;
  167. SHGetFileInfo((LPCTSTR)pidlDesktop, NULL, &fileInfo, sizeof(fileInfo), SHGFI_PIDL|SHGFI_ATTRIBUTES|SHGFI_DISPLAYNAME);
  168. m_ShellPidl.GetNormalAndSelectedIcons(pidlDesktop, nImage, nSelImage);
  169. CShCMSort *pItem = new CShCMSort;
  170. pItem->SetText(fileInfo.szDisplayName);
  171. pItem->SetImage(nImage);
  172. pItem->SetSelImage(nSelImage);
  173. LPTVITEMDATA lptvid = (LPTVITEMDATA)m_pMalloc->Alloc(sizeof(TVITEMDATA));
  174. lptvid->lpi = GetShellPidl().CopyItemID(pidlDesktop);
  175. lptvid->lpifq = GetShellPidl().CopyItemIDList(pidlDesktop);
  176. lptvid->lpsfParent = NULL;
  177. STL_ADD_ITEM(m_vItems,pItem);
  178. BuildFolderList(psfDesktop,pidlDesktop,pidlAbsSel,1);
  179. if (m_pMalloc)
  180. {
  181. if (pidlDesktop)
  182. m_pMalloc->Free(pidlDesktop);
  183. }
  184. psfDesktop->Release();
  185. }
  186. void CIEShellComboBox::BuildFolderList(LPSHELLFOLDER pFolder,LPITEMIDLIST pidl,LPITEMIDLIST pidlAbsSel, int nIndent)
  187. {
  188. vecCMSort vItems;
  189. AddItems(vItems,pFolder,pidl,nIndent);
  190. // Sort the this node based on pidls
  191. STL_SORT(vItems,pFolder,STL_SORT_FUNC);
  192. CShCMSort *pItem=NULL;
  193. STL_FOR_ITERATOR(vecCMSort,vItems)
  194. {
  195. pItem = STL_GET_CURRENT(vItems);
  196. STL_ADD_ITEM(m_vItems,pItem);
  197. if (GetShellPidl().ComparePidls(pFolder,pItem->GetPidl(),m_pidlMyComputer))
  198. {
  199. LPSHELLFOLDER pSubFolder=NULL;
  200. HRESULT hr = pFolder->BindToObject(pItem->GetPidl(), 0, IID_IShellFolder,(LPVOID*)&pSubFolder);
  201. if (SUCCEEDED(hr))
  202. {
  203. BuildFolderList(pSubFolder,pItem->GetPidl(),pidlAbsSel,nIndent+1);
  204. pSubFolder->Release();
  205. }
  206. }
  207. }
  208. }
  209. void CIEShellComboBox::LoadItems(LPITEMIDLIST pidlAbsSel)
  210. {
  211. if (m_hImageList)
  212. ::SendMessage(GetSafeHwnd(), CBEM_SETIMAGELIST, 0, (LPARAM)m_hImageList);
  213. GetComboBoxCtrl()->ResetContent();
  214. DeleteAllItemData();
  215. CShCMSort *pItem=NULL;
  216. int nCount = GetShellPidl().GetCount(pidlAbsSel);
  217. LPITEMIDLIST pidlCompare=NULL;
  218. int nSelItem=-1;
  219. int nItem=0;
  220. int n=0;
  221. int nIndent=0;
  222. CString sPath;
  223. STL_FOR_ITERATOR(vecCMSort,m_vItems)
  224. {
  225. pItem = STL_GET_CURRENT(m_vItems);
  226. nItem = AddItem(pItem);
  227. nIndent = pItem->GetIndent();
  228. if (nIndent == 0)
  229. nIndent = 1;
  230. // TRACE2("Getting pidl %d of %un",nIndent,nCount);
  231. pidlCompare=GetShellPidl().CopyItemID(pidlAbsSel,nIndent);
  232. // Desktop item
  233. if (nCount == 0 && n == 0)
  234. {
  235. nSelItem = 0;
  236. sPath = pItem->GetText();
  237. }
  238. else if (nCount == 1 && GetShellPidl().ComparePidls(NULL,pItem->GetPidl(),pidlAbsSel) == true) 
  239. {
  240. nSelItem = nItem;
  241. sPath = pItem->GetText();
  242. }
  243. else if (GetShellPidl().CompareMemPidls(pItem->GetPidl(),pidlCompare) == true 
  244. && GetShellPidl().CompareMemPidls(pItem->GetPidl(),m_pidlMyComputer) == false)
  245. {
  246. LPITEMIDLIST pidlAbs=NULL;
  247. CString sDisplayName;
  248. CShCMSort Item;
  249. int nImage=0;
  250. int nSelImage=0;
  251. for(int i=nIndent+1;i < (nCount+1);i++)
  252. {
  253. pidlAbs = GetShellPidl().CopyAbsItemID(pidlAbsSel,i);
  254. if (pidlAbs)
  255. {
  256. GetShellPidl().SHPidlToPathEx(pidlAbs,sPath,NULL);
  257. GetShellPidl().GetDisplayName(pidlAbs,sDisplayName);
  258. GetShellPidl().GetNormalAndSelectedIcons(pidlAbs,nImage,nSelImage);
  259. Item.SetText(sDisplayName);
  260. Item.SetImage(nImage);
  261. Item.SetSelImage(nSelImage);
  262. LPTVITEMDATA lptvid = (LPTVITEMDATA)m_pMalloc->Alloc(sizeof(TVITEMDATA));
  263. lptvid->lpi = GetShellPidl().CopyItemID(pidlAbs);
  264. lptvid->lpifq = pidlAbs;
  265. LPTVITEMDATA dt_lptvid = (LPTVITEMDATA)pItem->GetItemData();
  266. lptvid->lpsfParent = dt_lptvid->lpsfParent;
  267. lptvid->lpsfParent->AddRef();
  268. Item.SetItemData((DWORD)lptvid);
  269. Item.SetIndent(i);
  270. m_vecItemData.push_back(lptvid);
  271. nItem = AddItem(&Item);
  272. }
  273. }
  274. if (nSelItem == -1)
  275. nSelItem = nItem;
  276. if (sPath.Find(_T("::")) == 0)
  277. GetShellPidl().GetDisplayName(pidlAbsSel,sPath);
  278. else if(sPath.IsEmpty())
  279. sPath = pItem->GetText();
  280. }
  281. if (pidlCompare)
  282. {
  283. m_pMalloc->Free(pidlCompare);
  284. pidlCompare = NULL;
  285. }
  286. n++;
  287. }
  288. if (nSelItem >= 0)
  289. GetComboBoxCtrl()->SetCurSel(nSelItem);
  290. GetEditCtrl()->SetWindowText(sPath);
  291. m_bInternet = false;
  292. }
  293. int CIEShellComboBox::AddItem(const CShCMSort *pItem)
  294. {
  295. // add the node to the combo box
  296. COMBOBOXEXITEM item;
  297. ZeroMemory(&item,sizeof(item));
  298. item.mask |= (CBEIF_IMAGE | CBEIF_INDENT | CBEIF_LPARAM | CBEIF_TEXT | CBEIF_SELECTEDIMAGE);
  299. item.iItem = -1;
  300. item.pszText = (LPTSTR)(LPCTSTR)pItem->GetText();
  301. item.cchTextMax = lstrlen(item.pszText);
  302. item.iImage = pItem->GetImage();
  303. item.iSelectedImage = pItem->GetSelImage();
  304. item.iOverlay = pItem->GetOverlayImage();
  305. item.iIndent = pItem->GetIndent();
  306. item.lParam = (LPARAM)pItem->GetItemData();
  307. return InsertItem(&item);
  308. }
  309. void CIEShellComboBox::AddItems(vecCMSort &vItems,IShellFolder* pFolder,LPITEMIDLIST pidlAbs,int nIndent)
  310. {
  311. IEnumIDList* pItems = NULL;
  312. LPITEMIDLIST pidlNext = NULL;
  313. LPITEMIDLIST pidlCopy = NULL;
  314. LPTSTR pszFilePath = NULL;
  315. STRRET StrRetFilePath;
  316. // Enumerate all object in the given folder
  317. HRESULT hr = pFolder->EnumObjects(NULL, SHCONTF_FOLDERS|SHCONTF_NONFOLDERS, &pItems);
  318. SHFILEINFO fileinfo;
  319. while (NOERROR == hr)
  320. {
  321. hr = pItems->Next(1, &pidlNext, NULL);
  322. if (hr == S_FALSE || pidlNext == NULL || pidlNext == pidlCopy)
  323. break;
  324. pidlCopy = pidlNext;
  325. pFolder->GetDisplayNameOf(pidlNext,SHGDN_INFOLDER,&StrRetFilePath);
  326. GetShellPidl().StrRetToStr(StrRetFilePath, &pszFilePath, pidlNext);
  327. ZeroMemory(&fileinfo,sizeof(fileinfo));
  328. fileinfo.dwAttributes=SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
  329. hr = pFolder->GetAttributesOf(1,(const struct _ITEMIDLIST **)&pidlCopy,&fileinfo.dwAttributes);
  330. if (SUCCEEDED(hr))
  331. lstrcpy(fileinfo.szDisplayName,pszFilePath);
  332. // Create a submenu if this item is a folder
  333. if (fileinfo.dwAttributes & (SFGAO_HASSUBFOLDER | SFGAO_FOLDER))
  334. {
  335. if (fileinfo.dwAttributes & SFGAO_FOLDER)
  336. {
  337. AddFolder(vItems,fileinfo,pidlAbs,pidlNext,pFolder,nIndent);
  338. }
  339. }
  340. if (pszFilePath)
  341. m_pMalloc->Free(pszFilePath);
  342. }
  343. if (pidlNext)
  344. m_pMalloc->Free(pidlNext);
  345. if (pItems)
  346. pItems->Release();
  347. }
  348. void CIEShellComboBox::AddFolder(vecCMSort &vItems,const SHFILEINFO &FileInfo,LPITEMIDLIST pidlAbs,LPITEMIDLIST pidl,LPSHELLFOLDER pFolder,int nIndent)
  349. {
  350. ASSERT(m_pMalloc);
  351. // allocate new itemdata
  352. LPTVITEMDATA lptvid = (LPTVITEMDATA)m_pMalloc->Alloc(sizeof(TVITEMDATA));
  353. if (lptvid == NULL)
  354. return;
  355. ZeroMemory(lptvid,sizeof(TVITEMDATA));
  356. // create new fully qualified pidl
  357. lptvid->lpifq = m_ShellPidl.ConcatPidl(pidlAbs,pidl);
  358. // Now make a copy of the last item in the pidl.
  359. lptvid->lpi = pidl;
  360. int nImage=0;
  361. int nSelImage=0;
  362. // get icons for new fq pidl
  363. m_ShellPidl.GetNormalAndSelectedIcons(lptvid->lpifq, nImage, nSelImage);
  364. // save folder for later use(when node is expanded)
  365. lptvid->lpsfParent = pFolder; // pointer to parent folder
  366. // keep hold of it(will be released in clean up)
  367. lptvid->lpsfParent->AddRef();
  368. CShCMSort *pSMI = new CShCMSort;
  369. pSMI->SetPidl(pidl);
  370. pSMI->SetText(FileInfo.szDisplayName);
  371. pSMI->SetImage(nImage);
  372. pSMI->SetSelImage(nSelImage);
  373. pSMI->SetItemData((DWORD)lptvid);
  374. pSMI->SetIndent(nIndent);
  375. STL_ADD_ITEM(vItems,pSMI);
  376. }
  377. void CIEShellComboBox::SetShellImageList()
  378. {
  379. // TODO: Add your specialized creation code here
  380. HKEY hKey;
  381. if (RegOpenKeyEx(HKEY_CLASSES_ROOT,strIEKey,0,KEY_READ,&hKey) == ERROR_SUCCESS)
  382. {
  383. BYTE szValueName[_MAX_PATH];
  384. DWORD dwType=0;
  385. DWORD dwSizeData = sizeof(szValueName)-1;
  386. RegQueryValueEx(hKey,NULL,0,&dwType,szValueName,&dwSizeData);
  387. CString sPath((LPCTSTR)szValueName);
  388. if (sPath.Left(1) == _T('"'))
  389. sPath = sPath.Right(sPath.GetLength()-1);
  390. if (sPath.Right(1) == _T('"'))
  391. sPath = sPath.Left(sPath.GetLength()-1);
  392. if (sPath.Find(_T("%")) != -1)
  393. {
  394. TCHAR szPath[MAX_PATH];
  395. if (ExpandEnvironmentStrings(sPath,szPath,sizeof(szPath)) > 0)
  396. sPath = szPath;
  397. }
  398. if (sPath.Find(_T("~")) != -1)
  399. {
  400. TCHAR szPath[MAX_PATH];
  401. if (GetLongPathName(sPath,szPath,sizeof(szPath)) > 0)
  402. sPath = szPath;
  403. }
  404. ExtractIconEx(sPath, 1, NULL, &m_hIcon, 1);
  405. // create the small icon image list
  406. UINT cxSmallIcon = ::GetSystemMetrics(SM_CXSMICON);
  407. UINT cySmallIcon = ::GetSystemMetrics(SM_CYSMICON);
  408. if (m_ImageList.GetSafeHandle() != NULL)
  409. m_ImageList.DeleteImageList();
  410. m_ImageList.Create(cxSmallIcon,
  411. cySmallIcon,
  412. ILC_MASK | ILC_COLOR16,
  413. 1,
  414. 1);
  415. if (m_hIcon)
  416. m_ImageList.Add(m_hIcon);
  417. }
  418.     SHFILEINFO    sfi;
  419.     m_hImageList = (HIMAGELIST)SHGetFileInfo((LPCTSTR)_T("C:\"), 
  420.                                            0,
  421.                                            &sfi, 
  422.                                            sizeof(SHFILEINFO), 
  423.                                            SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
  424.     // Attach ImageList to the window
  425.     if (m_hImageList)
  426.     ::SendMessage(m_hWnd, CBEM_SETIMAGELIST, 0, (LPARAM)m_hImageList);
  427. }
  428. void CIEShellComboBox::SelectionChanged(bool bEnter)
  429. {
  430. LPITEMIDLIST pidlSel = GetSelectedPidl();
  431. GetEditCtrl()->GetWindowText(m_sText);
  432. UINT mess=WM_APP_CB_IE_SEL_CHANGE;
  433. if (bEnter)
  434. mess=WM_APP_CB_IE_HIT_ENTER;
  435. if (m_hTreeWnd)
  436. {
  437. if (mess == WM_APP_CB_IE_SEL_CHANGE)
  438. ::SendMessage(m_hTreeWnd,mess,(WPARAM)pidlSel,(LPARAM)(LPCTSTR)m_sText);
  439. else
  440. ::SendMessage(m_hTreeWnd,mess,(WPARAM)m_bInternet,(LPARAM)(LPCTSTR)m_sText);
  441. }
  442. }
  443. int CIEShellComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  444. {
  445. if (CComboBoxEx::OnCreate(lpCreateStruct) == -1)
  446. return -1;
  447. SetShellImageList();
  448. if (m_cbEdit.GetSafeHwnd() == NULL)
  449. {
  450. m_cbEdit.SubclassWindow(GetEditCtrl()->GetSafeHwnd());
  451. m_cbEdit.SetTreeWnd(m_hTreeWnd);
  452. }
  453. return 0;
  454. }
  455. void CIEShellComboBox::OnDestroy() 
  456. {
  457. SetImageList(NULL);
  458. CComboBoxEx::OnDestroy();
  459. // TODO: Add your message handler code here
  460. }
  461. LRESULT CIEShellComboBox::OnCBIEPopulate(WPARAM wParam,LPARAM lParam)
  462. {
  463. Populate((LPITEMIDLIST)wParam);
  464. return 1L;
  465. }
  466. void CIEShellComboBox::OnDropDown()
  467. {
  468. }
  469. void CIEShellComboBox::OnSelChange()
  470. {
  471. SelectionChanged(false);
  472. }
  473. void CIEShellComboBox::OnKillFocus(CWnd *pNewWnd)
  474. {
  475. CComboBoxEx::OnKillFocus(pNewWnd);
  476. SetEditSel(-1,0);
  477. }
  478. void CIEShellComboBox::OnSetFocus(CWnd *pWnd)
  479. {
  480. CComboBoxEx::OnSetFocus(pWnd);
  481. SetEditSel(-1,-1);
  482. }
  483. BOOL CIEShellComboBoxEdit::PreTranslateMessage(MSG* pMsg)
  484. {
  485. // TODO: Add your specialized code here and/or call the base class
  486. if (pMsg->message == WM_KEYDOWN)
  487. {
  488. if (pMsg->wParam == VK_RETURN)
  489. {
  490. GetParent()->GetParent()->PostMessage(WM_APP_CB_IE_HIT_ENTER);
  491. return TRUE;
  492. }
  493. }
  494. return CEdit::PreTranslateMessage(pMsg);
  495. }
  496. void CIEShellComboBox::PreSubclassWindow()
  497. {
  498. // TODO: Add your specialized code here and/or call the base class
  499. CComboBoxEx::PreSubclassWindow();
  500. if (m_cbEdit.GetSafeHwnd() == NULL)
  501. {
  502. m_cbEdit.SubclassWindow(GetEditCtrl()->GetSafeHwnd());
  503. m_cbEdit.SetTreeWnd(m_hTreeWnd);
  504. }
  505. }
  506. LRESULT CIEShellComboBox::OnAppCbIeHitEnter(WPARAM wParam, LPARAM lParam)
  507. {
  508. SelectionChanged(true);
  509. return 1;
  510. }