📄 girldlg.cpp
字号:
// girlDlg.cpp : implementation file
//
#include "stdafx.h"
#include "girl.h"
#include "girlDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGirlDlg dialog
CGirlDlg::CGirlDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGirlDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGirlDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_girl=0;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGirlDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGirlDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGirlDlg, CDialog)
//{{AFX_MSG_MAP(CGirlDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_ERASEBKGND()
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGirlDlg message handlers
BOOL CGirlDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
DoChange();
SetWindowText("水晶美眉");
SetTimer(2,100,NULL);
m_rect1.left=0;
m_rect1.right=0;
m_rect1.top=0;
m_rect1.bottom=0;
SetTimer(1,5000,NULL);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CGirlDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CGirlDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGirlDlg::SetupRegion(CDC *pDC)
{
CDC memDC;
CBitmap &cBitmap=m_bmpDraw;
CBitmap* pOldMemBmp = NULL;
COLORREF col,colMask;
CRect cRect;
int x, y;
CRgn wndRgn, rgnTemp;
GetWindowRect(&cRect);
CPoint ptOrg=cRect.TopLeft();
BITMAP bmInfo;
cBitmap.GetObject(sizeof(bmInfo),&bmInfo);
CRect rcNewWnd=CRect(ptOrg,CSize(bmInfo.bmWidth,bmInfo.bmHeight));
memDC.CreateCompatibleDC(pDC);
pOldMemBmp = memDC.SelectObject(&cBitmap);
colMask=memDC.GetPixel(0,0);
wndRgn.CreateRectRgn(0, 0, 64, 128);
for(x=0; x<=64; x++)
{
for(y=0; y<=128; y++)
{
col = memDC.GetPixel(x, y);
if(col == colMask)
{
rgnTemp.CreateRectRgn(x, y, x+1, y+1);
wndRgn.CombineRgn(&wndRgn, &rgnTemp, RGN_XOR);
rgnTemp.DeleteObject();
}
}
}
if (pOldMemBmp) memDC.SelectObject(pOldMemBmp);
SetWindowRgn((HRGN)wndRgn, TRUE);
MoveWindow(rcNewWnd);
InvalidateRect(NULL,TRUE);
// Invalidate();
}
void CGirlDlg::DoChange()
{
m_bmpDraw.DeleteObject();
if(m_girl==0)
m_bmpDraw.LoadBitmap(IDB_BITMAP5);
else if(m_girl==1)
m_bmpDraw.LoadBitmap(IDB_BITMAP6);
else if(m_girl==2)
m_bmpDraw.LoadBitmap(IDB_BITMAP7);
else if(m_girl==3)
m_bmpDraw.LoadBitmap(IDB_BITMAP8);
CWindowDC dc(this);
SetupRegion(&dc);
}
BOOL CGirlDlg::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetWindowRect(&rect);
CDC memDC;
CBitmap cBitmap;
if(m_girl==0)
cBitmap.LoadBitmap(IDB_BITMAP1);
if(m_girl==1)
cBitmap.LoadBitmap(IDB_BITMAP2);
if(m_girl==2)
cBitmap.LoadBitmap(IDB_BITMAP3);
if(m_girl==3)
cBitmap.LoadBitmap(IDB_BITMAP4);
CBitmap* pOldMemBmp = NULL;
CFont* pOldMemFont=NULL;
memDC.CreateCompatibleDC(pDC);
pOldMemBmp = memDC.SelectObject(&cBitmap);
pDC->BitBlt(0,0,64, 128, &memDC, 0,0, SRCCOPY);
if (pOldMemBmp) memDC.SelectObject( pOldMemBmp );
return TRUE;
return CDialog::OnEraseBkgnd(pDC);
}
int CGirlDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); //窗体总在总前面
return 0;
}
void CGirlDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
ShowWindow(SW_HIDE);
CDialog::OnLButtonDown(nFlags, point);
}
void CGirlDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
m_chose.m_girl=m_girl;
m_chose.DoModal();
if(m_chose.m_exit==TRUE)
OnOK();
m_girl=m_chose.m_girl;
DoChange();
CDialog::OnRButtonDown(nFlags, point);
}
void CGirlDlg::OnTimer(UINT nIDEvent)
{
if(nIDEvent==1)
{
CWindowDC dc(this);
CDC memDC;
CBitmap cBitmap;
if(m_girl==0)
cBitmap.LoadBitmap(IDB_BITMAP9);
if(m_girl==1)
cBitmap.LoadBitmap(IDB_BITMAP10);
if(m_girl==2)
cBitmap.LoadBitmap(IDB_BITMAP11);
if(m_girl==3)
cBitmap.LoadBitmap(IDB_BITMAP12);
CBitmap* pOldMemBmp = NULL;
CFont* pOldMemFont=NULL;
memDC.CreateCompatibleDC(&dc);
pOldMemBmp = memDC.SelectObject(&cBitmap);
dc.BitBlt(0,24,64, 47, &memDC, 0,0, SRCCOPY);
if (pOldMemBmp) memDC.SelectObject( pOldMemBmp );
Sleep(300);
InvalidateRect(NULL,TRUE);
}
if(nIDEvent==2)
{
m_tophwnd=::GetForegroundWindow();
if(m_tophwnd==this->m_hWnd)
return;
if(m_tophwnd==m_chose.m_hWnd)
return;
::GetWindowRect(m_tophwnd,m_rect);
if(m_rect==m_rect1)
return;
m_rect1=m_rect;
m_rect.top-=95;
m_rect.right-=80;
m_rect.bottom=m_rect.top+128;
m_rect.left=m_rect.right-64;
MoveWindow(m_rect.left,m_rect.top,m_rect.right,m_rect.bottom);
ShowWindow(SW_SHOWNORMAL);
// ::SetForegroundWindow(m_tophwnd);
}
CDialog::OnTimer(nIDEvent);
}
void CGirlDlg::OnDestroy()
{
CDialog::OnDestroy();
KillTimer(1);
KillTimer(2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -