summaryrefslogtreecommitdiffstats
path: root/tests/manual/mediaplayer/mediaaxwidget.h
blob: 3a49b6139805fa950d7d98d4f51f7f133229f4c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef MEDIAAXWIDGET_H
#define MEDIAAXWIDGET_H

#include <QtAxContainer/QAxWidget>
#include <qt_windows.h>

// Overrides the translateKeyEvent() function to pass keystrokes
// to the Windows Media Player ActiveX control.
class MediaAxWidget : public QAxWidget
{
public:
    MediaAxWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {})
        : QAxWidget(parent, f)
    {
    }

protected:
    bool translateKeyEvent(int message, int keycode) const override
    {
        if (message >= WM_KEYFIRST && message <= WM_KEYLAST)
            return true;
        return QAxWidget::translateKeyEvent(message, keycode);
    }
};

#endif // MEDIAAXWIDGET_H