I'm trying to figure out how to use the winapi
SetWindowSubclass
On a non-Qt project under MSVC I can use the API by including:
#include <commctrl.h>
#pragma comment(lib, "Comctl32.lib")
I have been trying for hours unsuccessfully to link this lib on my project. I have found these comctl32.lib
on my machine:
https://i.stack.imgur.com/ZQhN3.png
I tried adding into .pro
:
LIBS += -comctl32
LIBS += -comctl32.lib
=> error: unrecognized command-line option '-comctl32'
LIBS += comctl32
LIBS += comctl32.lib
=> error: cannot find comctl32: No such file or directory
I copied the one from C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\arm64
and past it on a new folder under C:\Qt\Libs
LIBS += C:\Qt\Libs
=> error: cannot find C:\Qt\Libs: Permission denied
LIBS += -L"C:\Qt\Libs"
=> this didn't throw any of the errors from above, but now I have these compiler error:
.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
LIBS += -L"C:\Qt\Libs"
#win32:QMAKE_FLAGS += -L"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\arm64"
#win32:LIBS += cm-comctl32.lib
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
rcdata.qrc
.h
#include <commctrl.h>
#pragma comment(lib, "Comctl32.lib") // <- warning: Unkown pragma ignored
.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
SetWindowSubclass((HWND)ui->tabWidget->find(0), ButtonProc, 0, (DWORD_PTR)&ui);
DWORD err = GetLastError();
}
Using Qt Creator 8.0.1
Qt 6.3.1, compiler MinGW 64-bit