24 lines
661 B
C++
24 lines
661 B
C++
|
#include "stdafx.h"
|
||
|
#include "WinHelper.h"
|
||
|
|
||
|
#include <windows.h>
|
||
|
#include <Shlwapi.h>
|
||
|
#include <Shlobj.h>
|
||
|
|
||
|
QImage LoadWindowsIcon(const QString& Path, quint32 Index)
|
||
|
{
|
||
|
std::wstring path = QString(Path).replace("/", "\\").toStdWString();
|
||
|
HICON icon = ExtractIconW(NULL, path.c_str(), Index);
|
||
|
QImage Icon = QImage::fromHICON(icon);
|
||
|
DestroyIcon(icon);
|
||
|
return Icon;
|
||
|
}
|
||
|
|
||
|
bool PickWindowsIcon(QWidget* pParent, QString& Path, quint32& Index)
|
||
|
{
|
||
|
wchar_t iconPath[MAX_PATH] = { 0 };
|
||
|
Path.toWCharArray(iconPath);
|
||
|
BOOL Ret = PickIconDlg((HWND)pParent->window()->winId(), iconPath, MAX_PATH, (int*)&Index);
|
||
|
Path = QString::fromWCharArray(iconPath);
|
||
|
return !!Ret;
|
||
|
}
|