📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "自动停靠窗口.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_WINDOWPOSCHANGING()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx=400; //修改主窗口的位置和大小
cs.cy=300;
cs.x=200;
cs.y=150;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
void CMainFrame::OnWindowPosChanging( WINDOWPOS* lpwndpos )
{
RECT WorkAREA;
SystemParametersInfo(SPI_GETWORKAREA,0,&WorkAREA,0);
//SystemParametersInfo(SPI_SETDRAGFULLWINDOWS,TRUE,NULL,0);
if(lpwndpos->x-WorkAREA.left<50) //靠近左边
lpwndpos->x=0;
if(WorkAREA.right-lpwndpos->x-lpwndpos->cx<50)//靠近右边
lpwndpos->x=WorkAREA.right-lpwndpos->cx;
if(lpwndpos->y-WorkAREA.top<50) //靠近上边
lpwndpos->y=0;
if(WorkAREA.bottom-lpwndpos->y-lpwndpos->cy<50)//靠近下边
lpwndpos->y=WorkAREA.bottom-lpwndpos->cy;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -