Positionsänderung eines wxFrame
-
Hallo. Ich habe ein Problem mit der Verschiebung eines wxFrame in einem anderen Fenster. Einleitung: Ich erstelle 2 Arten von Frames die ich via ::SetParent(mychild,theparent) aus der API auf ein anderes Fenster, z.B. Notepad platziere. Eins dient als Menü, das andere als Infoquelle. Jetzt diese Frames auch verschiebbar sein, also hole ich mir via API, GetCursorpos die aktuellen Mouse-Coordinaten und schiebe meine Fenster dahin. So weit so, mit meinem Menü klappt es, mit dem anderen nicht....wenn ich die Mouse benutze.
Kann mir jemand helfen? Das wäre einfaach super. Hier der Quäl-code
Funzt nicht:
// get the mouse-position of the parent window void CEasyOverlay::GetParentMousePos() { #ifdef __WXMSW__ POINT pCursor; GetCursorPos(&pCursor); ::ScreenToClient(GetParentHWND(), &pCursor); m_nXCoord = pCursor.x; m_nYCoord = pCursor.y; #endif /*! * wxEVT_MOTION event handler for ID_CEASYOVERLAY */ void CEasyOverlay::OnMouseMotion( wxMouseEvent& event ) { wxString coords; /* ////@begin wxEVT_MOTION event handler for ID_CEASYOVERLAY in CEasyOverlay. // Before editing this code, remove the block markers. event.Skip(); ////@end wxEVT_MOTION event handler for ID_CEASYOVERLAY in CEasyOverlay. */ if(event.Dragging() && event.LeftIsDown()) { ::wxCursor(wxCURSOR_HAND); GetParentMousePos(); // get the mouse-position in the parent window if( m_nXCoord >= 0) { // the coordinates ... should not be outside of the parent window if(m_nYCoord < 0) m_nYCoord = 0; if(m_nYCoord > pheight) m_nYCoord = pheight - (GetSize().GetWidth()*2); SetPosition(wxPoint(m_nXCoord, m_nYCoord)); } if( m_nYCoord >= 0) { // the coordinates ... should not be outside of the parent window if(m_nXCoord < 0) m_nXCoord = 0; if(m_nXCoord > pwidth) m_nXCoord = pwidth- (GetSize().GetHeight()*2); SetPosition(wxPoint(m_nXCoord, m_nYCoord)); } coords = wxString::Format(_T("%d / %d"), m_nXCoord, m_nYCoord); } ::wxCursor(wxCURSOR_DEFAULT); } }
Und das hier funzt aber:
/*! * wxEVT_KEY_DOWN event handler for ID_CEASYOVERLAY */ void CEasyOverlay::OnKeyDown( wxKeyEvent& event ) { /* ////@begin wxEVT_KEY_DOWN event handler for ID_CEASYOVERLAY in CEasyOverlay. // Before editing this code, remove the block markers. event.Skip(); ////@end wxEVT_KEY_DOWN event handler for ID_CEASYOVERLAY in CEasyOverlay. */ if(FindFocus() == this) { switch(event.GetKeyCode()) { case WXK_UP: m_nYCoord--; break; case WXK_DOWN: m_nYCoord++; break; case WXK_LEFT: m_nXCoord--; break; case WXK_RIGHT: m_nXCoord++; break; } SetPosition(wxPoint(m_nXCoord,m_nYCoord)); } }
Funzt:
/*! * wxEVT_MOTION event handler for ID_COVERLAY */ void COverlayMenu::OnMouseMotion( wxMouseEvent& event ) { /* ////@begin wxEVT_MOTION event handler for ID_COVERLAY in COverlayMenu. // Before editing this code, remove the block markers. event.Skip(); ////@end wxEVT_MOTION event handler for ID_COVERLAY in COverlayMenu. */ if(event.Dragging() && event.LeftIsDown()) { GetParentMousePos(); // get the mouse-position in the parent window if( mx >= 0) { // the coordinates ... should not be outside of the parent window if(my <= 0) my = 0; if(my > pheight) my = pheight - (GetSize().GetWidth()*2); SetPosition(wxPoint(mx,my)); } if( my >= 0) { // the coordinates ... should not be outside of the parent window if(mx <= 0) mx = 0; if(mx > pwidth) mx = pwidth- (GetSize().GetHeight()*2); SetPosition(wxPoint(mx,my)); } } } // get the mouse-position of the parent window void COverlayMenu::GetParentMousePos() { #ifdef __WXMSW__ POINT pCursor; GetCursorPos(&pCursor); ::ScreenToClient(m_WinParentHnd, &pCursor); mx = pCursor.x; my = pCursor.y; #endif }
Ich wäre sehr dankbar für Hilfe!!