代码拉取完成,页面将自动刷新
<<<<<<< HEAD
#include "mainform.h"
#include "ui_mainform.h"
#include <QListWidgetItem>
#include <QDebug>
#include <QPixmap>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QMimeData>
#include <QUrl>
int idx = 0;
ICONDIR ico;
MainForm::MainForm(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainForm)
{
ui->setupUi(this);
memset(&ico, 0, sizeof(ICONDIR));
ico.idType = 1;
ico.idCount = 1;
ico.idEntries[0].wPlanes = 1;
ico.idEntries[0].dwImageOffset = 22;
setWindowTitle("");
setAcceptDrops(true);
}
MainForm::~MainForm()
{
delete ui;
}
void MainForm::on_lstIcon_itemSelectionChanged()
{
QListWidgetItem* item = ui->lstIcon->currentItem();
if (item) {
QIcon ico = item->icon();
ui->labIcon->setPixmap(ico.pixmap(ico.availableSizes().first().width()));
}
}
BOOL CALLBACK UpdateIcons(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG lParam)
{
Ui::MainForm *ui = (Ui::MainForm *)lParam;
HRSRC hRes = FindResource(hModule, lpszName, lpszType);
HGLOBAL hResLoaded = LoadResource(hModule, hRes);
void* pData = LockResource(hResLoaded);
int nSizeOfIconRes = SizeofResource(hModule,hRes);
qDebug() << "data:" << pData << ":" << nSizeOfIconRes;
QByteArray arr;
ico.idEntries[0].dwBytesInRes = nSizeOfIconRes*4;
ico.idEntries[0].bWidth = ico.idEntries[0].bHeight = (byte)((char*)pData)[4];
arr.clear();
arr.append((char*)&ico, 22);
arr.append((char*)pData, nSizeOfIconRes);
QPixmap p;
p.loadFromData(arr, "ico");
QString str = QString("%1 (%2x%2)").arg(++idx).arg(p.width());
QListWidgetItem* item = new QListWidgetItem(str);
item->setIcon(QIcon(p));
ui->lstIcon->addItem(item);
UnlockResource(hResLoaded);
FreeResource(hResLoaded);
return TRUE;
}
void MainForm::getIcons(const QString &appName)
{
idx = 0;
ui->lstIcon->clear();
HMODULE hModule = LoadLibraryExA( appName.toLocal8Bit().data(), NULL, LOAD_LIBRARY_AS_DATAFILE );//::LoadLibraryA(appName.toLocal8Bit().data());
qDebug() << "e:" << EnumResourceNames(hModule, RT_ICON, UpdateIcons, (long)this->ui);
::FreeLibrary(hModule);
}
void MainForm::dragEnterEvent(QDragEnterEvent *e)
{
if (e->mimeData()->urls().size() != 1)
return;
QString name = e->mimeData()->urls().first().toString();
if (name.endsWith(".exe", Qt::CaseInsensitive) || name.endsWith(".dll", Qt::CaseInsensitive))
e->acceptProposedAction();
}
void MainForm::dropEvent(QDropEvent *e)
{
QString name = e->mimeData()->urls().first().toString().remove("file:///");
setWindowTitle(name);
getIcons(name);
}
=======
#include "mainform.h"
#include "ui_mainform.h"
#include <QListWidgetItem>
#include <QDebug>
#include <QPixmap>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QMimeData>
#include <QUrl>
int idx = 0;
ICONDIR ico;
MainForm::MainForm(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainForm)
{
ui->setupUi(this);
memset(&ico, 0, sizeof(ICONDIR));
ico.idType = 1;
ico.idCount = 1;
ico.idEntries[0].wPlanes = 1;
ico.idEntries[0].dwImageOffset = 22;
setWindowTitle("");
setAcceptDrops(true);
}
MainForm::~MainForm()
{
delete ui;
}
void MainForm::on_lstIcon_itemSelectionChanged()
{
QListWidgetItem* item = ui->lstIcon->currentItem();
if (item) {
QIcon ico = item->icon();
ui->labIcon->setPixmap(ico.pixmap(ico.availableSizes().first().width()));
}
}
BOOL CALLBACK UpdateIcons(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG lParam)
{
Ui::MainForm *ui = (Ui::MainForm *)lParam;
HRSRC hRes = FindResource(hModule, lpszName, lpszType);
HGLOBAL hResLoaded = LoadResource(hModule, hRes);
void* pData = LockResource(hResLoaded);
int nSizeOfIconRes = SizeofResource(hModule,hRes);
qDebug() << "data:" << pData << ":" << nSizeOfIconRes;
QByteArray arr;
ico.idEntries[0].dwBytesInRes = nSizeOfIconRes*4;
ico.idEntries[0].bWidth = ico.idEntries[0].bHeight = (byte)((char*)pData)[4];
arr.clear();
arr.append((char*)&ico, 22);
arr.append((char*)pData, nSizeOfIconRes);
QPixmap p;
p.loadFromData(arr, "ico");
QString str = QString("%1 (%2x%2)").arg(++idx).arg(p.width());
QListWidgetItem* item = new QListWidgetItem(str);
item->setIcon(QIcon(p));
ui->lstIcon->addItem(item);
UnlockResource(hResLoaded);
FreeResource(hResLoaded);
return TRUE;
}
void MainForm::getIcons(const QString &appName)
{
idx = 0;
ui->lstIcon->clear();
HMODULE hModule = LoadLibraryExA( appName.toLocal8Bit().data(), NULL, LOAD_LIBRARY_AS_DATAFILE );//::LoadLibraryA(appName.toLocal8Bit().data());
qDebug() << "e:" << EnumResourceNames(hModule, RT_ICON, UpdateIcons, (long)this->ui);
::FreeLibrary(hModule);
}
void MainForm::dragEnterEvent(QDragEnterEvent *e)
{
if (e->mimeData()->urls().size() != 1)
return;
QString name = e->mimeData()->urls().first().toString();
if (name.endsWith(".exe", Qt::CaseInsensitive) || name.endsWith(".dll", Qt::CaseInsensitive))
e->acceptProposedAction();
}
void MainForm::dropEvent(QDropEvent *e)
{
QString name = e->mimeData()->urls().first().toString().remove("file:///");
setWindowTitle(name);
getIcons(name);
}
>>>>>>> 3fab9eac9b2b32ef37fa477b4b150f71d4a4f234
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。