基于MFC对话框实现简单的绘图软件
核心代码展示:
protected:
HICON m_hIcon;
// 生成的消息映射函数
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
//图形类型选择列表框变量
CListBox MY_STYLE_LIST;
CStatic my_static;
//画笔颜色选择列表框变量
CComboBox my_ComboBox_PenColor;
CStatic my_static_Pencolor;
//画刷颜色选择列表框变量
CStatic my_static_HbrushColor;
CComboBox my_comb_Hbrush;
//画笔尺寸选择列表框变量
CStatic my_Line_size;
CComboBox my_Comb_LineSize;
//画笔类型标记
int Flag_Line_Style;
//画笔尺寸
int my_Pen_Size;
//画刷类型标记
int Flag_Hbrush_Style;
//画笔颜色标记
COLORREF Flag_PEN_Color;
//画刷颜色标记
COLORREF Flag_Hbrush_Color;
afx_msg void OnBnClickedRadio1Solid();
afx_msg void OnBnClickedRadio2Dash();
afx_msg void OnBnClickedButton1Paint();
afx_msg void OnBnClickedRadio3Dot();
afx_msg void OnBnClickedRadio4Dashdot();
afx_msg void OnBnClickedRadio5Solidbrush();
afx_msg void OnBnClickedRadio6Cross();
afx_msg void OnBnClickedRadio7Fdiagional();
afx_msg void OnBnClickedRadio8Bdiagional();
afx_msg void OnBnClickedButton2Exit();
afx_msg void OnCbnSelendokCombo1Pencolor();
afx_msg void OnCbnSelendokCombo2();
afx_msg void OnCbnSelendokCombo1();
};
PaintDlg.cpp文件代码:
#include "stdafx.h"
#include "Paint.h"
#include "PaintDlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CPaintDlg 对话框
CPaintDlg::CPaintDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CPaintDlg::IDD, pParent)
, Flag_Line_Style(0)
, Flag_Hbrush_Style(0)
, my_Pen_Size(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPaintDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1_STYLE, MY_STYLE_LIST);
DDX_Control(pDX, IDC_STATIC_STYLE, my_static);
DDX_Control(pDX, IDC_COMBO1_PenColor, my_ComboBox_PenColor);
DDX_Control(pDX, IDC_STATIC_PenColor, my_static_Pencolor);
DDX_Control(pDX, IDC_STATIC_HbrushColor, my_static_HbrushColor);
DDX_Control(pDX, IDC_COMBO2, my_comb_Hbrush);
DDX_Control(pDX, IDC_STATIC_Line_Size, my_Line_size);