MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / AttachNativeWindow

Method AttachNativeWindow

DSView/pv/mainframe.cpp:702–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700}
701
702void MainFrame::AttachNativeWindow()
703{
704#ifdef _WIN32
705
706 assert(_parentNativeWidget == NULL);
707
708 int k = _initWndInfo.k;
709 int x = _normalRegion.x * k;
710 int y = _normalRegion.y * k;
711 int w = _normalRegion.w * k;
712 int h = _normalRegion.h * k;
713
714
715 QColor bkColor = AppConfig::Instance().GetStyleColor();
716 WinNativeWidget *nativeWindow = new WinNativeWidget(x, y, w, h, bkColor);
717 nativeWindow->setGeometry(x, y, w, h);
718
719 if (nativeWindow->Handle() == NULL){
720 dsv_info("ERROR: native window is invalid.");
721 return;
722 }
723
724 //check the normal region
725 QScreen *scr = nativeWindow->GetPointScreen();
726 if (scr != NULL){
727 QRect full_rc = scr->availableGeometry();
728 PopupDlgList::SetCurrentScreen(scr);
729
730 if (full_rc.width() - _normalRegion.w < 100 && !_initWndInfo.isMaxSize)
731 {
732 int w1 = full_rc.width() / 1.5;
733 int h1 = full_rc.height() / 1.5;
734 int x1 = full_rc.left() + (full_rc.width() - w1) / 2;
735 int y1 = full_rc.top() + (full_rc.height() - h1) / 2;
736 int x2 = full_rc.left() + (full_rc.width() - w1) / 2 * k;
737 int y2 = full_rc.top() + (full_rc.height() - h1) / 2 * k;
738
739 this->move(x1, y1);
740 this->resize(w1,w1);
741 nativeWindow->setGeometry(x2 , y2 , w1 * k, h1 *k);
742
743 dsv_info("%s:Reset the normal region, x:%d, y:%d, w:%d, h:%d",
744 scr->name().toStdString().c_str(),
745 x1, y1, w1, h1);
746 }
747 }
748 else{
749 dsv_info("ERROR: get point screen error.");
750 }
751
752 //Show the qt window before bind parent, the icon can show at the task bar first time.
753 QFrame::show();
754
755 nativeWindow->SetChildWidget(this);
756 nativeWindow->SetNativeEventCallback(this);
757 nativeWindow->UpdateChildDpi();
758 nativeWindow->SetTitleBarWidget(_titleBar);
759 _titleBar->EnableAbleDrag(false);

Callers

nothing calls this directly

Calls 15

GetStyleColorMethod · 0.80
setGeometryMethod · 0.80
HandleMethod · 0.80
GetPointScreenMethod · 0.80
nameMethod · 0.80
SetChildWidgetMethod · 0.80
UpdateChildDpiMethod · 0.80
SetTitleBarWidgetMethod · 0.80
EnableAbleDragMethod · 0.80
ShowMaxMethod · 0.80
ResizeChildMethod · 0.80

Tested by

no test coverage detected