📄 labeldlg.cpp
字号:
// LabelDlg.cpp : implementation file
//
#include "stdafx.h"
#include "彩票.h"
#include "LabelDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLabelDlg dialog
CLabelDlg::CLabelDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLabelDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLabelDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CLabelDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLabelDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLabelDlg, CDialog)
//{{AFX_MSG_MAP(CLabelDlg)
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_WM_TIMER()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLabelDlg message handlers
BOOL CLabelDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CWindowDC dc(this);
CDC memDC;
CBitmap bmp;
bmp.LoadBitmap(IDB_STAMP);
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
int iWidth = bmpInfo.bmWidth;
int iHeight = bmpInfo.bmHeight;
CRect rect;
GetWindowRect(&rect);
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(&bmp);
CRgn wndRgn, rgnTemp;
wndRgn.CreateRectRgn(0,0,iWidth,iHeight);
::SetBkMode(dc.m_hDC, TRANSPARENT);
COLORREF col = memDC.GetPixel(0,0);
for(int i = 0 ; i < iWidth; i ++)
for(int j = 0; j < iHeight; j ++)
{
COLORREF colTemp = memDC.GetPixel(i,j);
if(colTemp == col)
{
rgnTemp.CreateRectRgn(i,j,i+1,j+1);
wndRgn.CombineRgn(&wndRgn,&rgnTemp,RGN_XOR);
rgnTemp.DeleteObject();
}
}
SetWindowRgn((HRGN)wndRgn, TRUE);
memDC.DeleteDC();
// MoveWindow(rect.left,rect.top,rect.left + iWidth,rect.top + iHeight);
MoveWindow(0,0,iWidth,iHeight);
CenterWindow();
SetWindowText("阿皮小精灵");
SetTimer(1,1,NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLabelDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
delete this;
CDialog::PostNcDestroy();
}
void CLabelDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CBitmap bmp;
bmp.LoadBitmap(IDB_STAMP);
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
int iWidth = bmpInfo.bmWidth;
int iHeight = bmpInfo.bmHeight;
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(&bmp);
dc.BitBlt(0,0,iWidth,iHeight,&memDC,0,0,SRCCOPY);
// Do not call CDialog::OnPaint() for painting messages
}
int CLabelDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
void CLabelDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SendMessage(WM_SYSCOMMAND, SC_MOVE|HTCLIENT, 0);
CDialog::OnLButtonDown(nFlags, point);
}
void CLabelDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(nIDEvent == 1)
{
int iFullWidth = GetSystemMetrics(SM_CXFULLSCREEN);
int iFullHeigth = GetSystemMetrics( SM_CYFULLSCREEN);
// time tTime = CTime::getCurrentTime;
CTime tCur = CTime::GetCurrentTime();
srand(tCur.GetTime());
srand(rand());
srand(rand());
srand(rand());
srand(rand());
//随机抽取坐标
int iXPos = rand() % iFullWidth;
int iYPos = rand() % iFullHeigth;
CRect rect;
GetWindowRect(&rect);
rect.right = iXPos + rect.Width();
rect.bottom = iYPos + rect.Height();
rect.left = iXPos;
rect.top = iYPos;
MoveWindow(&rect);
}
CDialog::OnTimer(nIDEvent);
}
void CLabelDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
KillTimer(1);
CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -