📄 picture.cpp
字号:
// PICTURE.cpp : implementation file
//
#include "stdafx.h"
#include "THIRDWORK.h"
#include "PICTURE.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// PICTURE dialog
PICTURE::PICTURE(CWnd* pParent /*=NULL*/)
: CDialog(PICTURE::IDD, pParent)
{
//{{AFX_DATA_INIT(PICTURE)
m_show = _T("");
//}}AFX_DATA_INIT
}
void PICTURE::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(PICTURE)
DDX_Text(pDX, IDC_SHOW, m_show);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(PICTURE, CDialog)
//{{AFX_MSG_MAP(PICTURE)
ON_BN_CLICKED(IDC_JUXING, OnJuxing)
ON_BN_CLICKED(IDC_TUOYUAN, OnTuoyuan)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BLACK, OnBlack)
ON_BN_CLICKED(IDC_QING, OnQing)
ON_BN_CLICKED(IDC_BLUE, OnBlue)
ON_BN_CLICKED(IDC_GREEN, OnGreen)
ON_BN_CLICKED(IDC_RED, OnRed)
ON_BN_CLICKED(IDC_WHITE, OnWhite)
ON_BN_CLICKED(IDC_YELLOW, OnYellow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// PICTURE message handlers
void PICTURE::OnJuxing()
{
// TODO: Add your control notification handler code here
rect = 1;
//Invalidate();
UpdateData(true);
m_show = "您选择了矩形";
UpdateData(false);
}
void PICTURE::OnTuoyuan()
{
// TODO: Add your control notification handler code here
rect = 2;
//Invalidate();
UpdateData(true);
m_show = "您选择了椭圆";
UpdateData(false);
}
void PICTURE::OnOK()
{
// TODO: Add extra validation here
OnCancel();
}
void PICTURE::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CBrush mybrush;
CBrush* oldbrush;
UpdateData();
dc.SetBkMode(TRANSPARENT);
//mybrush.CreateSolidBrush(RGB(255,255,255));
dc.Rectangle(210,110,430,260);
//dc.SelectObject(oldbrush);
mybrush.CreateSolidBrush(RGB(red,green,blue));
oldbrush = dc.SelectObject(&mybrush);
switch(rect)
{
case 1:
dc.Rectangle(230,120,400,250);
break;
case 2:
dc.Ellipse(230,120,400,250);
break;
}
dc.SelectObject(oldbrush);
// Do not call CDialog::OnPaint() for painting messages
}
void PICTURE::OnBlack()
{
// TODO: Add your control notification handler code here
red = 0;
green = 0;
blue = 0;
Invalidate();
}
void PICTURE::OnQing()
{
// TODO: Add your control notification handler code here
red = 0;
green = 255;
blue = 255;
Invalidate();
}
void PICTURE::OnBlue()
{
// TODO: Add your control notification handler code here
blue = 255;
red = 0;
green = 0;
Invalidate();
}
void PICTURE::OnGreen()
{
// TODO: Add your control notification handler code here
red = 0;
blue = 0;
green = 255;
Invalidate();
}
void PICTURE::OnRed()
{
// TODO: Add your control notification handler code here
red = 255;
blue = 0;
green = 0;
Invalidate();
}
void PICTURE::OnWhite()
{
// TODO: Add your control notification handler code here
red = 255;
green = 255;
blue = 255;
Invalidate();
}
void PICTURE::OnYellow()
{
// TODO: Add your control notification handler code here
red = 255;
blue = 0;
green = 255;
Invalidate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -