void CMabinogiResourceToolView::OnInitialUpdate() { int nIndex = 0; GetListCtrl().InsertColumn(nIndex++, TEXT("文件名"), LVCFMT_LEFT, 120); GetListCtrl().InsertColumn(nIndex++, TEXT("版本"), LVCFMT_LEFT, 60); GetListCtrl().InsertColumn(nIndex++, TEXT("类型说明"), LVCFMT_LEFT, 150); GetListCtrl().InsertColumn(nIndex++, TEXT("大小"), LVCFMT_LEFT, 80); GetListCtrl().InsertColumn(nIndex++, TEXT("压缩后大小"), LVCFMT_LEFT, 80); GetListCtrl().InsertColumn(nIndex++, TEXT("文件时间1"), LVCFMT_LEFT, 140); GetListCtrl().InsertColumn(nIndex++, TEXT("文件时间2"), LVCFMT_LEFT, 140); GetListCtrl().InsertColumn(nIndex++, TEXT("文件时间3"), LVCFMT_LEFT, 140); HIMAGELIST hImgList;// = (HIMAGELIST)SHGetFileInfo(TEXT(""), 0, &shFilefo,sizeof(shFilefo), SHGFI_SYSICONINDEX|SHGFI_LARGEICON); SHGetImageList(SHIL_EXTRALARGE, IID_IImageList, (void**) &hImgList); GetListCtrl().SetImageList(CImageList::FromHandle(hImgList), TVSIL_NORMAL); SHGetImageList(SHIL_SMALL, IID_IImageList, (void**) &hImgList); GetListCtrl().SetImageList(CImageList::FromHandle(hImgList), LVSIL_SMALL); GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_HEADERDRAGDROP); LVTILEVIEWINFO lvtvi = { sizeof(LVTILEVIEWINFO), LVTVIM_COLUMNS }; lvtvi.cLines = 2; lvtvi.dwFlags = LVTVIF_AUTOSIZE; GetListCtrl().SetTileViewInfo ( &lvtvi ); CListView::OnInitialUpdate(); }
HRESULT CMenuToolbarBase::UpdateImageLists() { if ((m_initFlags & (SMINIT_TOPLEVEL | SMINIT_VERTICAL)) == SMINIT_TOPLEVEL) // not vertical. { // No image list, prevents the buttons from having a margin at the left side SetImageList(NULL); return S_OK; } // Assign the correct imagelist and padding based on the current icon size int shiml; if (m_menuBand->UseBigIcons()) { shiml = SHIL_LARGE; SetPadding(4, 0); } else { shiml = SHIL_SMALL; SetPadding(4, 4); } IImageList * piml; HRESULT hr = SHGetImageList(shiml, IID_PPV_ARG(IImageList, &piml)); if (FAILED_UNEXPECTEDLY(hr)) { SetImageList(NULL); } else { SetImageList((HIMAGELIST)piml); } return S_OK; }
HRESULT PreviewGenerator::GetHighResolutionIcon(CString filePath) { // Get the image list index of the icon SHFILEINFO sfi; if (!SHGetFileInfo(filePath, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX)) return NULL; // Get the jumbo image list IImageList *piml; HRESULT hr = SHGetImageList(SHIL_JUMBO, IID_PPV_ARGS(&piml)); if (hr != S_OK) return hr; // Extract an icon HICON hico; piml->GetIcon(sfi.iIcon, ILD_IMAGE, &hico); HDC hdc = previewControl->GetDC()->GetSafeHdc(); DrawIconEx(hdc, 0, 0, hico, 256, 256, 0, NULL, DI_NORMAL); //ICONINFO iconinfo; //GetIconInfo(hico, &iconinfo); //HBITMAP hBitmap = iconinfo.hbmColor; //BITMAP bmpInfo; //GetObject(hBitmap, sizeof(bmpInfo), &bmpInfo); //SIZE bitmapSize; //bitmapSize.cx = bmpInfo.bmWidth; //bitmapSize.cy = bmpInfo.bmHeight; piml->Release(); return hr; }
//------------------------------------------------------------------------------ // CDevicePropertyPage::GetIconFromItem [STATIC FUNC] // // Gets a handle to the icon of the shell item. phIcon needs to be cleaned // up with DestroyIcon() when done. //------------------------------------------------------------------------------ HRESULT CDevicePropertyPage::GetIconFromItem( __in IShellItem* pShellItem, __in int iImageList, __out HICON* phIcon ) { HRESULT hr = S_OK; int iIcon = 0; PITEMID_CHILD pidl = NULL; IImageList* pImageList = NULL; IParentAndItem* pParentAndItem = NULL; IShellFolder* pShellFolder = NULL; *phIcon = NULL; hr = pShellItem->QueryInterface( &pParentAndItem ); if( S_OK == hr ) { hr = pParentAndItem->GetParentAndItem( NULL, &pShellFolder, &pidl ); } if( S_OK == hr ) { hr = SHGetImageList( iImageList, __uuidof(IImageList), reinterpret_cast<void**>(&pImageList) ); } if( S_OK == hr ) { iIcon = SHMapPIDLToSystemImageListIndex( pShellFolder, pidl, NULL ); hr = pImageList->GetIcon( iIcon, 0, phIcon ); } // // Cleanup // if( NULL != pImageList ) { pImageList->Release(); } if( NULL != pidl ) { ILFree( pidl ); } if( NULL != pShellFolder ) { pShellFolder->Release(); } if( NULL != pParentAndItem ) { pParentAndItem->Release(); } return hr; }// CDevicePropertyPage::GetIconFromItem
HICON GetHighResolutionIcon(LPTSTR pszPath) { // Get the image list index of the icon SHFILEINFO sfi; if (!SHGetFileInfo(pszPath, -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_ICON | SHGFI_LARGEICON)) { return NULL; } // Get the jumbo image list IImageList *piml; if (DEFAULT_ICOH_SIZE_WIDHT == 32) { if (FAILED(SHGetImageList(SHIL_LARGE, IID_IImageList, (void **)(&piml)))) { return NULL; } } else // 48 { if (FAILED(SHGetImageList(SHIL_EXTRALARGE, IID_IImageList, (void **)(&piml)))) { return NULL; } } // Extract an icon HICON hico; piml->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hico); int w, h; piml->GetIconSize(&w, &h); // Clean up piml->Release(); // Return the icon return hico; }
CDuiAddFrame::CDuiAddFrame() { if(m_pImageList == NULL) { HRESULT hResult = SHGetImageList(SHIL_JUMBO, IID_IImageList, (void**)&m_pImageList); if(hResult != S_OK){ m_pImageList = NULL; } } m_ImagePath = CPaintManagerUI::GetInstancePath() + L"Icon\\tmp.png"; }
static IExplorerBrowserEvents *make_explorer_events(explorer_info *info) { IExplorerBrowserEventsImpl *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(IExplorerBrowserEventsImpl)); ret->IExplorerBrowserEvents_iface.lpVtbl = &vt_IExplorerBrowserEvents; ret->info = info; ret->ref = 1; SHGetImageList(SHIL_SMALL,&IID_IImageList,(void**)&(ret->info->icon_list)); SendMessageW(info->path_box,CBEM_SETIMAGELIST,0,(LPARAM)ret->info->icon_list); return &ret->IExplorerBrowserEvents_iface; }
bool WinIconProvider::addIconFromImageList(int imageListIndex, int iconIndex, QIcon& icon) const { HICON hIcon = 0; IImageList* imageList; HRESULT hResult = SHGetImageList(imageListIndex, IID_IImageList, (void**)&imageList); if (hResult == S_OK) { hResult = ((IImageList*)imageList)->GetIcon(iconIndex, ILD_TRANSPARENT, &hIcon); imageList->Release(); } if (hResult == S_OK && hIcon) { icon.addPixmap(QtWin::fromHICON(hIcon)); DestroyIcon(hIcon); } return SUCCEEDED(hResult); }
HICON GetFileIcon(LPCWSTR pszFilePath) { SHFILEINFOW sfi = {0}; SHGetFileInfo(pszFilePath, -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX); // Retrieve the system image list. // To get the 48x48 icons, use SHIL_EXTRALARGE // To get the 256x256 icons (Vista only), use SHIL_JUMBO HIMAGELIST* imageList; HRESULT hResult = SHGetImageList(SHIL_EXTRALARGE, IID_IImageList, (void**)&imageList); HICON hIcon; if (hResult == S_OK) { // Get the icon we need from the list. Note that the HIMAGELIST we retrieved // earlier needs to be casted to the IImageList interface before use. hResult = ((IImageList*)imageList)->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hIcon); if (hResult == S_OK) { } } return hIcon; }
int CShellIcons::Get(LPCTSTR pszFile, int nSize) { CImageList* pImage; CIconMap* pIndex; switch ( nSize ) { case 16: pImage = &m_i16; pIndex = &m_m16; break; //case 24: // pImage = &m_i24; // pIndex = &m_m24; // break; case 32: pImage = &m_i32; pIndex = &m_m32; break; case 48: pImage = &m_i48; pIndex = &m_m48; break; default: ASSERT( FALSE ); return SHI_FILE; } CString strType = PathFindExtension( pszFile ); if ( strType.IsEmpty() ) return SHI_FILE; // No extension strType.MakeLower(); // Test for individual icons CString strFilename; if ( strType == L".exe" ) { strFilename = pszFile; strFilename.MakeLower(); } CQuickLock oLock( m_pSection ); if ( m_i16.m_hImageList == NULL ) Clear(); HICON hIcon = NULL; int nIndex = SHI_FILE; if ( pIndex->Lookup( strFilename.IsEmpty() ? strType : strFilename, nIndex ) ) return nIndex; if ( ! strFilename.IsEmpty() ) { LoadIcon( pszFile, ( ( nSize == 16 ) ? &hIcon : NULL ), ( ( nSize == 32 ) ? &hIcon : NULL ), ( ( nSize == 48 ) ? &hIcon : NULL ) ); if ( ! hIcon ) { if ( pIndex->Lookup( strType, nIndex ) ) { pIndex->SetAt( strFilename, nIndex ); return nIndex; } } } HICON hShellIcon = NULL; if ( ! hIcon ) { SHFILEINFO sfi = {}; DWORD dwFlags = ( strFilename.IsEmpty() ? SHGFI_USEFILEATTRIBUTES : 0 ) | SHGFI_ICON | ( ( nSize == 16 ) ? SHGFI_SMALLICON : SHGFI_LARGEICON ); if ( SHGetFileInfo( ( strFilename.IsEmpty() ? strType : strFilename ), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof( SHFILEINFO ), dwFlags ) ) { dwFlags = ( nSize == 16 ) ? SHIL_SMALL : ( ( nSize == 32 ) ? SHIL_LARGE : SHIL_EXTRALARGE ); CComPtr< IImageList > pImageList; if ( SUCCEEDED( SHGetImageList( dwFlags, IID_IImageList, (void**)&pImageList ) ) && SUCCEEDED( pImageList->GetIcon( sfi.iIcon, ILD_NORMAL, &hShellIcon ) ) ) { DestroyIcon( sfi.hIcon ); } else { // Use previously loaded one hShellIcon = sfi.hIcon; } if ( sfi.iIcon ) { hIcon = hShellIcon; hShellIcon = NULL; } } } if ( ! hIcon ) { Lookup( strType, NULL, NULL, ( ( nSize == 16 ) ? &hIcon : NULL ), ( ( nSize == 32 ) ? &hIcon : NULL ), ( ( nSize == 48 ) ? &hIcon : NULL ) ); } if ( hShellIcon ) { if ( hIcon ) DestroyIcon( hShellIcon ); else hIcon = hShellIcon; } nIndex = hIcon ? pImage->Add( hIcon ) : SHI_FILE; pIndex->SetAt( ( strFilename.IsEmpty() ? strType : strFilename ), nIndex ); #ifdef _DEBUG ICONINFO ii = {}; GetIconInfo( hIcon, &ii ); BITMAP bi = {}; GetObject( ii.hbmColor, sizeof( bi ), &bi ); TRACE( "CShellIcons::Get %dx%d (real %dx%d %dbpp) icon #%d for %s\n", nSize, nSize, bi.bmWidth, bi.bmHeight, bi.bmBitsPixel, nIndex, (LPCSTR)CT2A( strFilename.IsEmpty() ? strType : strFilename ) ); if ( ii.hbmMask ) DeleteObject( ii.hbmMask ); if ( ii.hbmColor ) DeleteObject( ii.hbmColor ); #endif // _DEBUG if ( hIcon ) DestroyIcon( hIcon ); return nIndex; }
HRESULT STDMETHODCALLTYPE CAddressBand::SetSite(IUnknown *pUnkSite) { CComPtr<IShellService> shellService; HWND parentWindow; HWND combobox; HRESULT hResult; IImageList *piml; if (pUnkSite == NULL) { fSite.Release(); return S_OK; } fSite.Release(); hResult = pUnkSite->QueryInterface(IID_PPV_ARG(IDockingWindowSite, &fSite)); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; // get window handle of parent parentWindow = NULL; hResult = IUnknown_GetWindow(fSite, &parentWindow); if (!::IsWindow(parentWindow)) return E_FAIL; // create combo box ex combobox = CreateWindowEx(WS_EX_TOOLWINDOW, WC_COMBOBOXEXW, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_TABSTOP | CCS_NODIVIDER | CCS_NOMOVEY | CBS_OWNERDRAWFIXED, 0, 0, 500, 250, parentWindow, (HMENU)IDM_TOOLBARS_ADDRESSBAR, _AtlBaseModule.GetModuleInstance(), 0); if (combobox == NULL) return E_FAIL; SubclassWindow(combobox); HRESULT hr = SHGetImageList(SHIL_SMALL, IID_PPV_ARG(IImageList, &piml)); if (FAILED_UNEXPECTEDLY(hr)) { SendMessageW(combobox, CBEM_SETIMAGELIST, 0, 0); } else { SendMessageW(combobox, CBEM_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(piml)); } SendMessage(CBEM_SETEXTENDEDSTYLE, CBES_EX_CASESENSITIVE | CBES_EX_NOSIZELIMIT, CBES_EX_CASESENSITIVE | CBES_EX_NOSIZELIMIT); fEditControl = reinterpret_cast<HWND>(SendMessage(CBEM_GETEDITCONTROL, 0, 0)); fComboBox = reinterpret_cast<HWND>(SendMessage(CBEM_GETCOMBOCONTROL, 0, 0)); hResult = CAddressEditBox_CreateInstance(IID_PPV_ARG(IAddressEditBox, &fAddressEditBox)); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; hResult = fAddressEditBox->QueryInterface(IID_PPV_ARG(IShellService, &shellService)); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; hResult = fAddressEditBox->Init(combobox, fEditControl, 8, fSite /*(IAddressBand *)this*/); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; hResult = shellService->SetOwner(fSite); if (FAILED_UNEXPECTEDLY(hResult)) return hResult; fGoButtonShown = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main", L"ShowGoButton", FALSE, TRUE); if (fGoButtonShown) CreateGoButton(); return hResult; }
LRESULT CALLBACK FormTagManager::DlgProc( _In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { //::PrintLog(L"Message: 0x%x, wParam = 0x%x, lParam = 0x%x, hwnd = 0x%x", uMsg, wParam, lParam, hwnd); switch(uMsg) { case WM_INITDIALOG: { ::PrintLog(L"Message: WM_INITDIALOG"); // init this->_hwnd = hwnd; this->_handler = (CHandler *)lParam; this->_handler->AddRef(); // to keep the instance after the Form opend, will be released in WM_NCDESTROY. SHGetImageList(SHIL_SMALL,IID_IImageList,(void **)&_sysImgList); _sysImgList->AddRef(); // will be released in ~ctor. _hErrorInfo = GetDlgItem(_hwnd,IDC_TAGMANAGER_STATIC_ERROR_INFO); _hListTags = GetDlgItem(_hwnd,IDC_TAGMANAGER_LIST_TAGS); _hListFiles = GetDlgItem(_hwnd,IDC_TAGMANAGER_LIST_SelectedFiles); _hEditCtlNewTag = GetDlgItem(_hwnd,IDC_TAGMANAGER_EDIT_TagWord); _hCheckAttachToFiles = GetDlgItem(_hwnd, IDC_TAGMANAGER_CHECK_AttachNewTagToFiles); _hBuAdd = GetDlgItem(_hwnd,IDC_TAGMANAGER_BU_ADD); _hBuEdit = GetDlgItem(_hwnd,IDC_TAGMANAGER_BU_EDIT); _hBuDel = GetDlgItem(_hwnd,IDC_TAGMANAGER_BU_DEL); InitText(); InitTagList(); InitFileList(); Button_SetCheck(_hCheckAttachToFiles,BST_CHECKED); Button_Enable(_hBuAdd,false); Edit_TakeFocus(_hEditCtlNewTag); break; } case MSG_TRANSFER_INSTANCES: ::PrintLog(L"Message: MSG_TRANSFER_INSTANCES: wParam: %d, lParam: %d",wParam, lParam); break; case WM_CTLCOLORSTATIC: { // change the text color of static label ERROR_INFO if( (UINT)lParam == (UINT)_hErrorInfo){ HDC hdcStatic = (HDC) wParam; SetTextColor(hdcStatic, _msgColor); // the background color will be changed to white, that is not what I want, so, restore the background color manual. auto oldBkColor = GetSysColor(CTLCOLOR_DLG); SetBkColor(hdcStatic,oldBkColor); if (_hbrBkgnd == NULL) { _hbrBkgnd = CreateSolidBrush(oldBkColor); } // the return value is a handle to a brush that the system uses to paint the background of the static control. // http://msdn.microsoft.com/en-us/library/windows/desktop/bb787524(v=vs.85).aspx return (INT_PTR)_hbrBkgnd; } } case WM_SYSCOMMAND: { switch (wParam) { case SC_KEYMENU: { ::PrintLog(L"Message: SC_KEYMENU: wParam: %d, lParam: %d",wParam, lParam); break; } case SC_CLOSE: { DestroyWindow(hwnd); break; } default: break; } } break; case WM_COMMAND: { ::PrintLog(L"Message: WM_COMMAND"); switch(LOWORD(wParam)) { case IDC_TAGMANAGER_BU_DEL: { DelTags(); break; } case IDC_TAGMANAGER_BU_EDIT: { EditTag(); break; } case IDC_TAGMANAGER_BU_ADD: { AddTag(); break; } case IDC_TAGMANAGER_CHECK_AttachNewTagToFiles: ::PrintLog(L"Message: IDC_CHECK_AttachNewTagToFiles"); break; case IDC_TAGMANAGER_BU_CANCEL: DestroyWindow(hwnd); break; case IDC_TAGMANAGER_EDIT_TagWord: { OnNewTagChanged(wParam,lParam); break; } default: break; } } break; //case WM_SIZE: // { // auto hTreeView = GetDlgItem(hdlg, IDC_TREE1); // if(hTreeView!=NULL) // { // } // return 0; // } case WM_KEYDOWN: { ::PrintLog(L"Message: WM_KEYDOWN"); } break; case WM_KEYUP: { ::PrintLog(L"Message: WM_KEYUP"); if(wParam==VK_ESCAPE) { DestroyWindow(hwnd); } else if( wParam == VK_RETURN ) { // simulate text changed to validate the new tag. OnNewTagChanged(MAKEWPARAM(IDC_TAGMANAGER_EDIT_TagWord, EN_SETFOCUS),(LPARAM)_hEditCtlNewTag); // simulate the button ADD to be Clicked. SendMessage(_hwnd,WM_COMMAND, MAKEWPARAM(IDC_TAGMANAGER_BU_ADD, BN_CLICKED),(LPARAM)_hBuAdd); } } break; case WM_CHAR: { ::PrintLog(L"Message: WM_CHAR"); } break; case WM_SYSCHAR: { ::PrintLog(L"Message: WM_SYSCHAR"); } break; case WM_DEADCHAR: { ::PrintLog(L"Message: WM_DEADCHAR"); } break; case WM_SYSDEADCHAR: { ::PrintLog(L"Message: WM_SYSDEADCHAR"); } break; case WM_NOTIFY: { LPNMHDR pNmhdr = (LPNMHDR) lParam; switch (pNmhdr->idFrom) { case IDC_TAGMANAGER_LIST_TAGS: { WM_NOTIFY_LIST_Tags(wParam,lParam); break; } case IDC_TAGMANAGER_LIST_SelectedFiles: { WM_NOTIFY_LIST_Files(wParam,lParam); break; } default: break; } } break; case WM_DESTROY: { PostQuitMessage(0); } break; case WM_NCDESTROY: { ::PrintLog(L"Message: WM_NCDESTROY"); if(this->_handler != NULL){ auto x = this->_handler->Release(); if( x == 0 ){ this->_handler = NULL; } } } break; default: break; } return (INT_PTR)FALSE; }