How to (move && drag) wxdialog without caption?
-
- Filthy Rich wx Solver
- Posts: 210
- Joined: Sat May 07, 2005 8:24 pm
- Location: Eskisehir, TURKEY
- Contact:
How to (move && drag) wxdialog without caption?
How to (move && drag) wxdialog without caption with mousedown event?
Thanks!
Thanks!
Re: How to (move && drag) wxdialog without caption?
Hi!
Check if the mouse entered the dialog and catch mouse events for the dialog. If left button is down, use Move() for the dialog.emarti wrote:How to (move && drag) wxdialog without caption with mousedown event?
Thanks!
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
-
- Filthy Rich wx Solver
- Posts: 210
- Joined: Sat May 07, 2005 8:24 pm
- Location: Eskisehir, TURKEY
- Contact:
thanks answer to me.
I am thinking..... for Windows
if leftdown event is done, dialog window not move. What's wrong?
OR
Your advice?
I am thinking..... for Windows
Code: Select all
/*
* movetheDlgMouseEvents
*/
void movetheDlg::movetheDlgMouseEvents(wxMouseEvent& event)
{
// insert your code here
if (event.LeftDown())
{
HWND Handle;
ReleaseCapture();
SendMessage(Handle,WM_SYSCOMMAND,SC_MOVE,0);
}
event.Skip();
}
OR
Your advice?
-
- Filthy Rich wx Solver
- Posts: 210
- Joined: Sat May 07, 2005 8:24 pm
- Location: Eskisehir, TURKEY
- Contact:
Use wxFrame in Windows OS
That's all folks. Thank again!
Code: Select all
/*
* movewindowFrmMouseEvents
*/
void movewindowFrm::movewindowFrmMouseEvents(wxMouseEvent& event)
{
// insert your code here
if (event.LeftDown())
{
ReleaseCapture();
SendMessage((HWND)this->GetHandle(),WM_SYSCOMMAND,SC_MOVE+1,0);
}
event.Skip();
}
Hi!
This works with dialogs too. Try using wxWindow::Move() to have a cross platform implementation.
This works with dialogs too. Try using wxWindow::Move() to have a cross platform implementation.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
Hi!
1. Get the x/y coordinates of the mouse event. Store them somewhere.
2. Set capture to the dialog.
3. Check if the mouse has been moved during the next event using the stored x/y values while the left button is pressed.
4. If so, it was a "drag" event. You'll have to recalculate the x/y values to get the actual position of the dialogs upper left corner, then use the stored and the event x/y values to get how many pixels it should be moved.
5. Use the actual positon +/- the x/y moved values and use Move() to move the dialog.
This might look complicated, but it isn't
These are separate handlers for left down, left up and motion events. Note that m_delta is an internal wxPoint. If this doesn't work for the dialog directly, use these for a wxPanel on the dialog and do GetParent()->Move().
I suggest the following:emarti wrote: I tried with wxWindow::Move(wxPoint).
How to set wxPoint while leftdown()?
1. Get the x/y coordinates of the mouse event. Store them somewhere.
2. Set capture to the dialog.
3. Check if the mouse has been moved during the next event using the stored x/y values while the left button is pressed.
4. If so, it was a "drag" event. You'll have to recalculate the x/y values to get the actual position of the dialogs upper left corner, then use the stored and the event x/y values to get how many pixels it should be moved.
5. Use the actual positon +/- the x/y moved values and use Move() to move the dialog.
This might look complicated, but it isn't
Code: Select all
void MyDialog::OnLeftDown(wxMouseEvent& evt)
{
CaptureMouse();
wxPoint pos = ClientToScreen(evt.GetPosition());
wxPoint origin = GetPosition();
int dx = pos.x - origin.x;
int dy = pos.y - origin.y;
m_delta = wxPoint(dx, dy);
}
Code: Select all
void MyDialog::OnMouseMove(wxMouseEvent& evt)
{
wxPoint pt = evt.GetPosition();
if (evt.Dragging() && evt.LeftIsDown())
{
wxPoint pos = ClientToScreen(pt);
Move(wxPoint(pos.x - m_delta.x, pos.y - m_delta.y));
}
}
Code: Select all
void MyDialog::OnLeftUp(wxMouseEvent& evt)
{
if (HasCapture())
{
ReleaseMouse();
}
}
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
-
- Earned some good credits
- Posts: 103
- Joined: Sun Aug 05, 2007 5:49 am