QT_BEGIN_NAMESPACE
+Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
+
static QByteArray debugWinStyle(DWORD style)
{
QByteArray rc = "0x";
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);
QWindowsWindow::~QWindowsWindow()
{
destroyWindow();
+ destroyIcon();
}
void QWindowsWindow::destroyWindow()
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
void setEnabled(bool enabled);
bool isEnabled() const;
+ void setWindowIcon(const QIcon &icon);
#ifndef Q_OS_WINCE
void alertWindow(int durationMs = 0);
void unregisterDropSite();
void handleGeometryChange();
void handleWindowStateChange(Qt::WindowState state);
+ inline void destroyIcon();
mutable WindowData m_data;
mutable unsigned m_flags;
#ifdef Q_OS_WINCE
bool m_previouslyHidden;
#endif
+ HICON m_iconSmall;
+ HICON m_iconBig;
};
// Conveniences for window frames.
SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(ud));
}
+inline void QWindowsWindow::destroyIcon()
+{
+ if (m_iconBig) {
+ DestroyIcon(m_iconBig);
+ m_iconBig = 0;
+ }
+ if (m_iconSmall) {
+ DestroyIcon(m_iconSmall);
+ m_iconSmall = 0;
+ }
+}
+
QT_END_NAMESPACE
#endif // QWINDOWSWINDOW_H