bool CUIWindow::AlignHintWndPos( Frect const& vis_rect, float border, float dx16pos ) //this = hint wnd { float const cursor_height = 43.0f; Fvector2 cursor_pos = GetUICursor()->GetCursorPosition(); if ( UI()->is_16_9_mode() ) { cursor_pos.x -= dx16pos; } if ( !vis_rect.in(cursor_pos) ) { return false; } Frect rect; rect.set( -border, -border, GetWidth() - 2.0f*border, GetHeight() - 2.0f*border ); rect.add( cursor_pos.x, cursor_pos.y ); rect.sub( 0.0f, rect.height() - border ); if ( !is_in( vis_rect, rect ) ) { rect.sub( rect.width() - border, 0.0f ); } if ( !is_in( vis_rect, rect ) ) { rect.add( 0.0f , rect.height() - border ); } if ( !is_in( vis_rect, rect ) ) { rect.add( rect.width() - border, cursor_height ); } float yn = rect.top - vis_rect.height() + rect.height( ) - border + cursor_height; if ( !is_in( vis_rect, rect ) ) { rect.sub( 0.0f , yn ); } if ( !is_in( vis_rect, rect ) ) { rect.sub( rect.width() - border, 0.0f ); } SetWndPos( rect.lt ); return true; }
bool CUIScrollBox::OnMouse(float x, float y, EUIMessages mouse_action) { bool cursor_over; if(x>=-10.0f && x<GetWidth()+10.0f && y>=-10.0f && y<GetHeight()+10.0f) cursor_over = true; else cursor_over = false; bool im_capturer = (GetParent()->GetMouseCapturer()==this); if(mouse_action == WINDOW_LBUTTON_DOWN) { GetParent()->SetCapture(this, true); } else if(mouse_action == WINDOW_LBUTTON_UP) { GetParent()->SetCapture(this, false); } else if(im_capturer && mouse_action == WINDOW_MOUSE_MOVE && cursor_over) { Fvector2 pos = GetWndPos(); Fvector2 delta = GetUICursor()->GetPosDelta(); if(m_bIsHorizontal) pos.x += delta.x; else pos.y += delta.y; SetWndPos (pos); GetMessageTarget()->SendMessage(this, SCROLLBOX_MOVE); } return true; }
void CDlgOpentools::UndoInitPaint() { KillTimer(TIMER_ANIMATE); ShowWindow(SW_HIDE); ////////////////////////////////////////////////////////////////////////// CRect rcArce; SystemParametersInfo(SPI_GETWORKAREA,0,&rcArce,SPIF_SENDCHANGE); int nWorkHeight = rcArce.Height(); int nWorkWidth = rcArce.Width(); // int x = 1120; // int y = 630; // int xStart = (nWorkWidth - x) / 2; // int yStart = (nWorkHeight - y) / 2; // // ::SetWindowPos(m_hWnd, NULL, xStart , yStart, x-1, y-1, SWP_NOZORDER|SWP_FRAMECHANGED); //::SetWindowPos(m_hWnd, NULL, 0, 0, nWorkWidth, nWorkHeight, SWP_NOZORDER); SetWndPos();//设置窗口大小 ////////////////////////////////////////////////////////////////////////// SetWindowLong(m_hWnd, GWL_STYLE, m_dwStyle); SetWindowLong(m_hWnd, GWL_EXSTYLE, m_dwExStyle); DWORD dwExStyle=GetWindowLong(m_hWnd,GWL_EXSTYLE); if((dwExStyle & WS_EX_LAYERED) == WS_EX_LAYERED) SetWindowLong(m_hWnd, GWL_EXSTYLE, dwExStyle^WS_EX_LAYERED); ShowWindow(SW_SHOW); }
CChangeLevelWnd::CChangeLevelWnd () { m_messageBox = xr_new<CUIMessageBox>(); m_messageBox->SetAutoDelete(true); AttachChild (m_messageBox); m_messageBox->Init ("message_box_change_level"); SetWndPos (m_messageBox->GetWndPos()); m_messageBox->SetWndPos (0.0f,0.0f); SetWndSize (m_messageBox->GetWndSize()); }
void CUIGlobalMap::ClipByVisRect() { Frect r = GetWndRect(); Frect clip = GetClipperRect(); if (r.x2<clip.width()) r.x1 += clip.width()-r.x2; if (r.y2<clip.height()) r.y1 += clip.height()-r.y2; if (r.x1>0.0f) r.x1 = 0.0f; if (r.y1>0.0f) r.y1 = 0.0f; SetWndPos (r.x1,r.y1); }
void CUIMessageBoxEx::InitMessageBox(LPCSTR xml_template) { //CUIDialogWnd::SetWndRect(Frect().set(0.0f,0.0f,1024.0f,768.0f)); m_pMessageBox->InitMessageBox(xml_template); SetWndPos( m_pMessageBox->GetWndPos() ); SetWndSize( m_pMessageBox->GetWndSize() ); m_pMessageBox->SetWndPos( Fvector2().set(0,0) ); AddCallback( m_pMessageBox->WindowName(), MESSAGE_BOX_YES_CLICKED, CUIWndCallback::void_function( this, &CUIMessageBoxEx::OnOKClicked ) ); }
void UIProperty::init_from_xml( CUIXml& ui_xml ) { m_ui_icon = new CUIStatic(); m_ui_text = new CUIStatic(); AttachChild( m_ui_icon ); AttachChild( m_ui_text ); m_ui_icon->SetAutoDelete( true ); m_ui_text->SetAutoDelete( true ); CUIXmlInit::InitWindow( ui_xml, "properties", 0, this ); SetWndPos( Fvector2().set( 0, 0 ) ); CUIXmlInit::InitWindow( ui_xml, "properties:icon", 0, m_ui_icon ); CUIXmlInit::InitWindow( ui_xml, "properties:text", 0, m_ui_text ); }
bool CUIScrollBox::OnMouseAction(float x, float y, EUIMessages mouse_action) { Fvector2 border; border.x = 512.0f; // :) border.y = 512.0f; bool over_x = ( x >= -border.x && x < (GetWidth() + border.x) ); bool over_y = ( y >= -border.y && y < (GetHeight() + border.y) ); bool cursor_over = false; if(over_x && over_y) { cursor_over = true; } bool im_capturer = (GetParent()->GetMouseCapturer() == this); if(mouse_action == WINDOW_LBUTTON_DOWN || mouse_action == WINDOW_LBUTTON_DB_CLICK) { GetParent()->SetCapture(this, true); return true; } if(mouse_action == WINDOW_LBUTTON_UP) { GetParent()->SetCapture(this, false); return true; } if(im_capturer && mouse_action == WINDOW_MOUSE_MOVE && cursor_over) { Fvector2 pos = GetWndPos(); Fvector2 delta = GetUICursor().GetCursorPositionDelta(); if(IsHorizontal()) pos.x += delta.x; else pos.y += delta.y; SetWndPos (pos); GetMessageTarget()->SendMessage(this, SCROLLBOX_MOVE); } if( !cursor_over ) { GetParent()->SetCapture(this, false); } return true; }
void CUIDetectorWave::Update() { Fvector2 P = GetWndPos(); float dp = m_curr_v*Device.fTimeDelta; P.x += dp; if(P.x > 0) P.x -= m_step; else if(P.x < -(2*m_step) ) P.x += m_step; SetWndPos (P); inherited::Update(); }
void CUIWindow::Draw(float x, float y) { SetWndPos (Fvector2().set(x,y)); Draw (); }
BOOL CDlgOpentools::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText("组件编辑 - 类型:" + m_sBaseType + " 名称:" + m_sNodeName); HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON_OPENTOOLS); //SetIcon(hIcon, FALSE); SetIcon(hIcon, TRUE); // TODO: 在此添加额外的初始化 CRect rcArce; SystemParametersInfo(SPI_GETWORKAREA,0,&rcArce,SPIF_SENDCHANGE); int nWorkHeight = rcArce.Height(); int nWorkWidth = rcArce.Width(); // int x = 1120; // int y = 630; // int xStart = (nWorkWidth - x) / 2; // int yStart = (nWorkHeight - y) / 2; // ::SetWindowPos(m_hWnd, NULL, xStart, yStart, x, y, SWP_NOZORDER); // ::SetWindowPos(m_hWnd, NULL, 0, 0, nWorkWidth, nWorkHeight, SWP_NOZORDER); SetWndPos();//设置窗口大小 ////////////////////////////////////////////////////////////////////////// //取窗口句柄 DWORD dwPid = 0; HWND hWnd = 0; m_pSharedMemoryOnlineEdit->GetInfo(&dwPid, &hWnd); //窗口句柄有效,直接返回 if (hWnd != 0 && IsWindow(hWnd)) { m_hWndOpentools = hWnd; m_dProcessId = dwPid; //ShowWindow(SW_SHOWMAXIMIZED); BindWindow(); //发送任务指令 SetTimer(TIMER_SEND_MISSON, 1, NULL); } else { //窗口句柄无效时,从进程中查 HANDLE hProcess = NULL; if (dwPid != 0) { hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwPid); } //若进程无效,重新启动封装环境 if (hProcess == NULL || hProcess == INVALID_HANDLE_VALUE) { m_dProcessId = m_pSharedMemoryOnlineEdit->StartOpenTools(); if (m_dProcessId == 0) { MyClose(IDCANCEL); return TRUE; } InitPaint(); SetTimer(TIMER_FIND_WINDOW, 500, NULL); } else { m_dProcessId = dwPid; CloseHandle(hProcess); HWND hWndFindOpentools = SharedMemoryOnlineEdit::GetMainWindow(m_dProcessId, "组件封装", "HwndWrapper[PeraComponentEditor.exe"); if (hWndFindOpentools && IsWindow(hWndFindOpentools)) { m_hWndOpentools = hWndFindOpentools; //更新共享内存 m_pSharedMemoryOnlineEdit->SetInfo(m_dProcessId, m_hWndOpentools); BindWindow(); //发送任务指令 SetTimer(TIMER_SEND_MISSON, 1, NULL); } else { InitPaint(); SetTimer(TIMER_FIND_WINDOW, 500, NULL); } } } ShowWindow(SW_SHOWMAXIMIZED); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
void CDlgOpentools::BindWindow() { ////////////////////////////////////////////////////////////////////////// CRect rcArce; SystemParametersInfo(SPI_GETWORKAREA,0,&rcArce,SPIF_SENDCHANGE); int nWorkHeight = rcArce.Height(); int nWorkWidth = rcArce.Width(); int x = 1120; int y = 630; int xStart = (nWorkWidth - x) / 2; int yStart = (nWorkHeight - y) / 2; //::SetWindowPos(m_hWnd, NULL, xStart , yStart, x, y, SWP_NOZORDER); { SetWndPos(); //缩小一些 } //::SetWindowPos(m_hWnd, NULL, 0 , 0, nWorkWidth, nWorkHeight, SWP_NOZORDER); //设置为全屏 ////////////////////////////////////////////////////////////////////////// ModifyStyle(m_hWndOpentools, WS_THICKFRAME|WS_SYSMENU, WS_CHILD, 0); ModifyStyleEx(m_hWndOpentools, WS_EX_APPWINDOW, NULL, 0); //取得原始风格 // DWORD dwExStyle = ::GetWindowLong(m_hWndOpentools, GWL_EXSTYLE); // DWORD dwStyle = ::GetWindowLong(m_hWndOpentools, GWL_STYLE); // // //WRITELOG(GetWindowStyleStr(m_hwndApp)); // // DWORD m_dwAppStyle; // DWORD m_dwAppExStyle; // m_dwAppStyle = dwStyle; // m_dwAppExStyle = dwExStyle; // //添加 // //dwStyle |= WS_CHILD; //如果嵌入的是wpf的程序,必须设置此属性,否则,会导致嵌入的wpf程序在切换tab标签页时,不显示,需要手工点击一次页面才显示。 // dwStyle |= WS_VISIBLE; // dwStyle |= WS_CLIPSIBLINGS; // dwStyle |= WS_CLIPCHILDREN; // // //dwExStyle |= WS_EX_TOOLWINDOW; //移走程序的任务栏图标 // // //移除 // dwStyle &= ~WS_CAPTION; // dwStyle &= ~WS_POPUP; // dwStyle &= ~WS_OVERLAPPED; // dwStyle &= ~WS_THICKFRAME; // dwStyle &= ~WS_DLGFRAME; // dwStyle &= ~WS_BORDER; //边框 // dwStyle &= ~WS_SYSMENU; // dwStyle &= ~WS_MINIMIZE; // dwStyle &= ~WS_MAXIMIZE; // dwStyle &= ~WS_MINIMIZEBOX; // dwStyle &= ~WS_MAXIMIZEBOX; // // dwExStyle &= ~WS_EX_APPWINDOW; // // //设置父子关系和窗口风格 // ::SetWindowLong(m_hWndOpentools, GWL_EXSTYLE, dwExStyle); // ::SetWindowLong(m_hWndOpentools, GWL_STYLE, dwStyle); ::SetParent(m_hWndOpentools, this->GetSafeHwnd()); CRect rc; GetClientRect(&rc); ::MoveWindow(m_hWndOpentools, 0, 0, rc.Width() - 1, rc.Height() - 1, TRUE); ::SetWindowPos(m_hWndOpentools, NULL, 0, 0, rc.Width(), rc.Height(), SWP_NOZORDER|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE); ::MoveWindow(m_hWndOpentools, 0, 0, rc.Width(), rc.Height(), TRUE); int ns = rc.Width() - 8; ns = ns << 16; ns |= rc.Height() - 4; //::SendMessage(m_hWndOpentools, WM_FLEXWARE_RESIZE, ns, TRUE); SetTimer(TIMER_REFRESH_OPENTOOLS, 1000, NULL); m_bApplied = FALSE; }
void CUIWindow::Draw(float x, float y){ SetWndPos (x,y); Draw (); }