?? -
字號(hào):
// 透明窗口View.cpp : implementation of the CMyView class
//
#include "stdafx.h"
#include "透明窗口.h"
#include "透明窗口Doc.h"
#include "透明窗口View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyView
IMPLEMENT_DYNCREATE(CMyView, CView)
BEGIN_MESSAGE_MAP(CMyView, CView)
//{{AFX_MSG_MAP(CMyView)
ON_WM_CREATE()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyView construction/destruction
CMyView::CMyView()
{
// TODO: add construction code here
}
CMyView::~CMyView()
{
memDC.SelectObject(oldObject);//釋放資源
memDC.DeleteDC();
}
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
//將客戶(hù)區(qū)窗口的刷子該為空刷子
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMyView drawing
void CMyView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics
#ifdef _DEBUG
void CMyView::AssertValid() const
{
CView::AssertValid();
}
void CMyView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
//CWnd* mainfraim;
// mainfraim=AfxGetMainWnd();
//mainfraim->SetActiveWindow();
// TODO: Add your specialized creation code here
::SetClassLong(this->m_hWnd,GCL_HBRBACKGROUND,(long)GetStockObject(HOLLOW_BRUSH));
width=GetSystemMetrics(SM_CXSCREEN);//保存當(dāng)前顯示器的分辨率
height=GetSystemMetrics(SM_CYSCREEN);
CWindowDC screenDC(NULL);//獲得屏幕窗口的上下文
//初始化位圖
hbmp.CreateBitmap(width,height,screenDC.GetDeviceCaps(PLANES),screenDC.GetDeviceCaps(BITSPIXEL),NULL);
memDC.CreateCompatibleDC(NULL);
oldObject=memDC.SelectObject(&hbmp);
memDC.BitBlt(0,0,width,height,&screenDC,0,0,SRCCOPY);
return 0;
}
void CMyView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
RECT clientRect;
GetClientRect(&clientRect);//獲得當(dāng)前客戶(hù)區(qū)的大小
POINT lefttop;
lefttop.x=clientRect.left;
lefttop.y=clientRect.top;
ClientToScreen(&lefttop);//將窗口客戶(hù)區(qū)左上角的點(diǎn)坐標(biāo)轉(zhuǎn)換為屏幕坐標(biāo)
//用保存的位圖將客戶(hù)區(qū)重畫(huà)
dc.BitBlt(0,0,clientRect.right,clientRect.bottom,&memDC,lefttop.x,lefttop.y,SRCCOPY);
dc.TextOut(100,0,"Hello world");
// Do not call CView::OnPaint() for painting messages
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -