Ejemplo n.º 1
0
bool MainWindow::winEvent(MSG * message, long * result)
{
    switch (message->message)
    {
    case WM_DWMSENDICONICTHUMBNAIL: {
            HBITMAP hbitmap = m_thumbnail.toWinHBITMAP();
            DwmSetIconicThumbnail(this->winId(), hbitmap, 0);

            if (hbitmap) DeleteObject(hbitmap);
        }
        break;

    case WM_DWMSENDICONICLIVEPREVIEWBITMAP: {
            HBITMAP hbitmap = QPixmap::grabWidget(this).scaled(this->size(), Qt::KeepAspectRatio).toWinHBITMAP();

            DwmSetIconicLivePreviewBitmap(this->winId(), hbitmap, 0, 0);
            if (hbitmap) DeleteObject(hbitmap);
        }
        break;
    default:
        return false;
    }


    return false;
}
/*!
    Sends the image that will appear as the window's iconic thumbnail.

    The image should not be larger than 200 by 108 pixels but will be
    scaled down preserving aspect ratio if necessary. To use the Windows
    default iconic thumbnail (an image of the window itself) pass a
    null pixmap.
 */
void IntegratedMainWindow::sendThumbnailInternal()
{
    QPixmap pix = sendThumbnail();
    if (!pix.isNull())
    {
        // If our image is larger than Windows said it could be in winEvent, scale it down
        if (pix.width() > d->m_maxThumbnailSize.width() || pix.height() > d->m_maxThumbnailSize.height())
        {
            pix = pix.scaled(d->m_maxThumbnailSize, Qt::KeepAspectRatio);
        }

        // Assert that our image does not exceed either of Windows' requested maximum dimensions
        Q_ASSERT(pix.width() <= d->m_maxThumbnailSize.width() && pix.height() <= d->m_maxThumbnailSize.height());

        // Convert our pixmap to Windows bitmap and send it to the DWM
        HBITMAP hBitmap = pix.toWinHBITMAP();
        DwmSetIconicThumbnail(winId(), hBitmap, d->m_windowFrameForIconicThumbnails ? DWM_SIT_DISPLAYFRAME : 0);
        if (hBitmap)
        {
            DeleteObject(hBitmap);
        }
    }
}
Ejemplo n.º 3
0
LRESULT TaskbarWnd::wndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    LRESULT lResult = 0;

    switch (message)
    {
        case WM_CREATE:
        {
			enableTabs(false);
			tbl_->RegisterTab(*this,tb_->parent());
            break;
        }

        case WM_ACTIVATE:
		{
			if (LOWORD(wParam) == WA_ACTIVE)
            {
				tbl_->ActivateTab(*this);
				tbl_->SetTabActive( *this, tb_->parent(), 0 );
				::SetForegroundWindow(tb_->parent());

				::ShowWindow(tb_->parent(),SW_RESTORE);
				::PostMessage( mol::win::mdiClient(), WM_MDIACTIVATE, (WPARAM)(HWND)(doc), 0);
            }
            break;
		}

        case WM_SYSCOMMAND:
		{
            if (wParam != SC_CLOSE)
            {
                lResult = SendMessage( tb_->parent(), WM_SYSCOMMAND, wParam, lParam);
            }
            else
            {
                lResult = ::DefWindowProc(hWnd, message, wParam, lParam);
            }
            break;
		}
        case WM_CLOSE:
		{

			LRESULT lr = ::SendMessage(doc,WM_CLOSE,0,0);
			if ( lr == 0 )
			{
				::DestroyWindow(hWnd_);	
			}
			break;
		}

        case WM_DWMSENDICONICTHUMBNAIL:
		{
			HBITMAP bmp = GetIconicRepresentation( HIWORD(lParam), LOWORD(lParam), 2 );
			DwmSetIconicThumbnail( *this, bmp, 0);
			break;
		}

        case WM_DWMSENDICONICLIVEPREVIEWBITMAP:
		{
			sendLivePreviewBitmap();
			break;
		}
        default:
		{
            lResult = ::DefWindowProc( hWnd, message, wParam, lParam );
            break;
		}
    }

    return lResult;
}