BMonitor/MainFrame.cpp
2024-12-26 10:28:02 +08:00

43 lines
984 B
C++

#include "MainFrame.h"
CMainFrame::CMainFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(300, 200),
wxFRAME_NO_TASKBAR | wxFRAME_SHAPED)
{
this->Bind(wxEVT_LEFT_DOWN, &CMainFrame::mouse_down, this);
this->Bind(wxEVT_MOTION, &CMainFrame::mouse_motion, this);
this->Bind(wxEVT_LEFT_UP, &CMainFrame::mouse_leftup, this);
}
void CMainFrame::init()
{
}
void CMainFrame::mouse_down(wxMouseEvent& event)
{
drag_ = true;
ps_ = event.GetPosition();
CaptureMouse();
}
void CMainFrame::mouse_motion(wxMouseEvent& event)
{
if (drag_ && event.Dragging()) {
wxPoint mousePos = event.GetPosition();
wxPoint screenPos = ClientToScreen(mousePos);
wxPoint framePos = screenPos - ps_;
Move(framePos);
}
}
void CMainFrame::mouse_leftup(wxMouseEvent& event)
{
if (drag_) {
drag_ = false;
if (HasCapture()) {
ReleaseMouse();
}
}
}