SimulateMouseView.cpp
上传用户:qzzxgm
上传日期:2009-12-14
资源大小:1882k
文件大小:4k
- // SimulateMouseView.cpp : implementation of the CSimulateMouseView class
- //
- #include "stdafx.h"
- #include "SimulateMouse.h"
- #include "SimulateMouseDoc.h"
- #include "SimulateMouseView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSimulateMouseView
- IMPLEMENT_DYNCREATE(CSimulateMouseView, CFormView)
- BEGIN_MESSAGE_MAP(CSimulateMouseView, CFormView)
- //{{AFX_MSG_MAP(CSimulateMouseView)
- ON_BN_CLICKED(IDC_LDBCLICK, OnLdbclick)
- ON_BN_CLICKED(IDC_LCLICK, OnLclick)
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSimulateMouseView construction/destruction
- CSimulateMouseView::CSimulateMouseView()
- : CFormView(CSimulateMouseView::IDD)
- {
- //{{AFX_DATA_INIT(CSimulateMouseView)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // TODO: add construction code here
- }
- CSimulateMouseView::~CSimulateMouseView()
- {
- }
- void CSimulateMouseView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSimulateMouseView)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BOOL CSimulateMouseView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CFormView::PreCreateWindow(cs);
- }
- void CSimulateMouseView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
- GetParentFrame()->RecalcLayout();
- ResizeParentToFit();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSimulateMouseView printing
- BOOL CSimulateMouseView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CSimulateMouseView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CSimulateMouseView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- void CSimulateMouseView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
- {
- // TODO: add customized printing code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSimulateMouseView diagnostics
- #ifdef _DEBUG
- void CSimulateMouseView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void CSimulateMouseView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- CSimulateMouseDoc* CSimulateMouseView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSimulateMouseDoc)));
- return (CSimulateMouseDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CSimulateMouseView message handlers
- void CSimulateMouseView::OnLdbclick()
- {
- //将鼠标的位置放在窗口的标题条上
- POINT lpPoint;
- CRect rc;
- CWnd* pParent = AfxGetApp()->GetMainWnd();
- pParent->GetWindowRect(&rc);
- lpPoint.x = rc.left+50;
- lpPoint.y = rc.top+10;
- SetCursorPos(lpPoint.x, lpPoint.y);
- //双击该标题条
- mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
- mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
- mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
- mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
- }
- void CSimulateMouseView::OnLclick()
- {
- //将鼠标的位置放在窗口的关闭按钮上
- POINT lpPoint;
- CRect rc;
- CWnd* pParent = AfxGetApp()->GetMainWnd();
- pParent->GetWindowRect(&rc);
- lpPoint.x = rc.right-5;
- lpPoint.y = rc.top +5;
- SetCursorPos(lpPoint.x, lpPoint.y);
- //单击
- mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
- mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
- }