#include #include #include class VideoWidget : public QFrame { public: VideoWidget() { layout = new QHBoxLayout (this); layout->setContentsMargins (0, 0, 0, 0); setLayout (layout); stable = 0; show(); } WId request() { stable = new QWidget(); QPalette plt = palette(); plt.setColor (QPalette::Window, Qt::black); stable->setPalette (plt); stable->setAutoFillBackground (true); stable->setAttribute (Qt::WA_PaintOnScreen, true); layout->addWidget (stable); return stable->winId(); } void release() { layout->removeWidget (stable); stable->deleteLater(); stable = 0; updateGeometry(); } QHBoxLayout *layout; QWidget *stable; }; class MainWindow : public QMainWindow { public: MainWindow() { QWidget *main = new QWidget(); setCentralWidget (main); QVBoxLayout *mainLayout = new QVBoxLayout (main); main->setContentsMargins (0, 0, 0, 0); mainLayout->setSpacing (0); mainLayout->setMargin (0); QStackedWidget *stackCentralW = new QStackedWidget (main); stackCentralW->addWidget (new QLabel ("Background")); videoWidget = new VideoWidget(); stackCentralW->addWidget (videoWidget); mainLayout->insertWidget (1, stackCentralW); mainLayout->insertWidget (2, new QLabel ("Controls")); stackCentralW->setCurrentWidget (videoWidget); id = videoWidget->request(); startTimer (1000); } void timerEvent (QTimerEvent *) { qDebug() << "*** timer" << qDebugFmtHex (id); HWND hwnd = id; HPS hps = WinGetPS (hwnd); if (hps) { RECTL rcl; // WinQueryWindowRect (hwnd, &rcl); rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = videoWidget->size().width(); rcl.yTop = videoWidget->size().height(); qDebug() << rcl.xRight << rcl.yTop; WinDrawBorder (hps, &rcl, 3, 3, CLR_RED, CLR_DARKGREEN, DB_INTERIOR); WinReleasePS (hps); } } VideoWidget *videoWidget; WId id; }; int main (int argc, char **argv) { QApplication app (argc, argv); MainWindow window; window.resize (400, 300); window.show(); return app.exec(); }