summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowswindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index f3830eb962..a31b09d2bf 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -61,6 +61,8 @@
QT_BEGIN_NAMESPACE
+Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
+
static QByteArray debugWinStyle(DWORD style)
{
QByteArray rc = "0x";
@@ -699,13 +701,15 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) :
m_cursor(QWindowsScreen::screenOf(aWindow)->windowsCursor()->standardWindowCursor()),
m_dropTarget(0),
m_savedStyle(0),
- m_format(aWindow->format())
+ m_format(aWindow->format()),
#ifdef QT_OPENGL_ES_2
- , m_eglSurface(0)
+ m_eglSurface(0),
#endif
#ifdef Q_OS_WINCE
- , m_previouslyHidden(false)
+ m_previouslyHidden(false),
#endif
+ m_iconBig(0),
+ m_iconSmall(0)
{
if (aWindow->surfaceType() == QWindow::OpenGLSurface)
setFlag(OpenGLSurface);
@@ -730,6 +734,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) :
QWindowsWindow::~QWindowsWindow()
{
destroyWindow();
+ destroyIcon();
}
void QWindowsWindow::destroyWindow()
@@ -1754,4 +1759,32 @@ QByteArray QWindowsWindow::debugWindowFlags(Qt::WindowFlags wf)
return rc;
}
+static HICON createHIcon(const QIcon &icon, int xSize, int ySize)
+{
+ if (!icon.isNull()) {
+ const QPixmap pm = icon.pixmap(icon.actualSize(QSize(xSize, ySize)));
+ if (!pm.isNull())
+ return qt_pixmapToWinHICON(pm);
+ }
+ return 0;
+}
+
+void QWindowsWindow::setWindowIcon(const QIcon &icon)
+{
+ if (m_data.hwnd) {
+ destroyIcon();
+
+ m_iconSmall = createHIcon(icon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
+ m_iconBig = createHIcon(icon, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
+
+ if (m_iconBig) {
+ SendMessage(m_data.hwnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)m_iconSmall);
+ SendMessage(m_data.hwnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)m_iconBig);
+ } else {
+ SendMessage(m_data.hwnd, WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)m_iconSmall);
+ SendMessage(m_data.hwnd, WM_SETICON, 1 /* ICON_BIG */, (LPARAM)m_iconSmall);
+ }
+ }
+}
+
QT_END_NAMESPACE