21 QString str1 =
"Windows Version = " 22 + QString::number(QSysInfo::WindowsVersion);
23 QString str2 =
"Windows Message";
25 WId
id = effectiveWinId();
27 MSG* pmsg =
reinterpret_cast<MSG*
>(pmessage);
29 switch(pmsg->message) {
32 (
const WCHAR*)str1.utf16(),
33 (
const WCHAR*)str2.utf16(),
34 MB_OK | MB_ICONEXCLAMATION
41 return QWidget::nativeEvent(baType, pmessage, result);
46 WId
id = effectiveWinId();
48 HDC hDC = ::GetDC(hWnd);
49 HBRUSH hBrush = ::CreateSolidBrush(RGB(255, 0, 255));
50 HBRUSH hBrushRect = ::CreateSolidBrush(RGB(200, 200, 200));
51 HPEN hPen = ::CreatePen(PS_SOLID, 2, RGB(0, 0, 128));
52 QString str =
"GDI Drawing";
55 ::SelectObject(hDC, hBrushRect);
56 ::Rectangle(hDC, 0, 0, width(), height());
57 ::GetTextMetrics(hDC, &tm);
58 ::SelectObject(hDC, hBrush);
59 ::SelectObject(hDC, hPen);
62 width() / 2 - (tm.tmAveCharWidth * str.length()) / 2,
63 (height() - tm.tmHeight) / 2,
64 (
const WCHAR*)str.utf16(),
67 ::DeleteObject(hBrushRect);
68 ::DeleteObject(hBrush);
70 ::ReleaseDC(hWnd, hDC);
76 QWidget::resizeEvent(pe);
80 WinAPI(QWidget* pwgt = 0) : QWidget(pwgt)
82 setAutoFillBackground(
false);
83 setAttribute(Qt::WA_PaintOnScreen,
true);
93 int main(
int argc,
char** argv)
95 QApplication app(argc, argv);
98 winAPI.resize(280, 200);
QPaintEngine * paintEngine() const
int main(int argc, char **argv)
virtual void resizeEvent(QResizeEvent *pe)
virtual bool nativeEvent(const QByteArray &baType, void *pmessage, long *result)
virtual void paintEvent(QPaintEvent *)