[Qt-interest] qtwinmigrate: reusing the window icon

Hendrik Fuß fuss at molecular-machines.com
Thu Mar 11 09:42:16 CET 2010


Hi,
 
I just tried out QtWinMigrate in order to use a couple Qt dialogs in a Borland C++ builder based Windows application and, hey, it works out of the box. Cool!

The one thing that I couldn't get working so far is to reuse the Windows application's window icon in my Qt Dialogs. Please consider this a feature request! :)

My problem may be Windows- or even Borland-specific, but in case anyone knows how to get this working, my code looks like this:

 
void reuseWindowIcon(QDialog* dialog, HWND owner)
{
    if (owner != NULL)
    {
        HICON icon = (HICON) SendMessage(owner, WM_GETICON, ICON_SMALL, 0);
        // alternatively:
        // HICON icon = (HICON) GetClassLong(owner, GCL_HICON);

        if (icon != NULL)
        {
            QPixmap windowIcon = QPixmap::fromWinHICON(icon);
            dialog->setWindowIcon(QIcon(windowIcon));
        }
    }
}


Unfortunately, icon is always NULL, regardless of whether I use SendMessage() or GetClassLong().

cheers
Hendrik




More information about the Qt-interest-old mailing list