UID:80312
图片:123.JPG
UID:7394
const QString qt_reg_winclass(QWidget *w) // register window class{ int flags = w->windowFlags(); int type = flags & Qt::WindowType_Mask; uint style; bool icon; QString cname; if (qt_widget_private(w)->isGLWidget) { cname = QLatin1String("QGLWidget"); style = CS_DBLCLKS;#ifndef Q_WS_WINCE style |= CS_OWNDC;#endif icon = true; } else if (flags & Qt::MSWindowsOwnDC) { cname = QLatin1String("QWidgetOwnDC"); style = CS_DBLCLKS;#ifndef Q_WS_WINCE style |= CS_OWNDC;#endif icon = true; } else if (type == Qt::Tool || type == Qt::ToolTip){ style = CS_DBLCLKS; if (w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) { if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) { style |= CS_DROPSHADOW; } cname = QLatin1String("QToolTip"); } else { cname = QLatin1String("QTool"); }#ifndef Q_WS_WINCE style |= CS_SAVEBITS;#endif icon = false; } else if (type == Qt::Popup) { cname = QLatin1String("QPopup"); style = CS_DBLCLKS;#ifndef Q_WS_WINCE style |= CS_SAVEBITS;#endif if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) style |= CS_DROPSHADOW; icon = false; } else { cname = QLatin1String("QWidget"); style = CS_DBLCLKS; icon = true; }#ifndef Q_WS_WINCE // force CS_OWNDC when the GL graphics system is // used as the default renderer if (qt_win_owndc_required) style |= CS_OWNDC;#endif#ifdef Q_OS_WINCE // We need to register the classes with the // unique ID on WinCE to make sure we can // move the windows to the front when starting // a second instance. wchar_t uniqueAppID[MAX_PATH]; GetModuleFileName(0, uniqueAppID, MAX_PATH); cname = QString::number(RegisterWindowMessage( (const wchar_t *) QString::fromWCharArray(uniqueAppID).toLower().replace(QLatin1Char('\\'), QLatin1Char('_')).utf16()));#endif // since multiple Qt versions can be used in one process // each one has to have window class names with a unique name // The first instance gets the unmodified name; if the class // has already been registered by another instance of Qt then // add an instance-specific ID, the address of the window proc. static int classExists = -1; if (classExists == -1) { WNDCLASS wcinfo; classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (wchar_t*)cname.utf16(), &wcinfo); classExists = classExists && wcinfo.lpfnWndProc != QtWndProc; } if (classExists) cname += QString::number((quintptr)QtWndProc); if (winclassNames()->contains(cname)) // already registered in our list return cname; WNDCLASS wc; wc.style = style; wc.lpfnWndProc = (WNDPROC)QtWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = qWinAppInst(); if (icon) { wc.hIcon = (HICON)LoadImage(qWinAppInst(), L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);#ifndef Q_WS_WINCE if (!wc.hIcon) wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);#endif } else { wc.hIcon = 0; } wc.hCursor = 0;#ifndef Q_WS_WINCE wc.hbrBackground = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW);#else wc.hbrBackground = 0;#endif wc.lpszMenuName = 0; wc.lpszClassName = (wchar_t*)cname.utf16(); ATOM atom = RegisterClass(&wc);#ifndef QT_NO_DEBUG if (!atom) qErrnoWarning("QApplication::regClass: Registering window class failed.");#else Q_UNUSED(atom);#endif winclassNames()->insert(cname, 1); return cname;}
UID:82419