-
Notifications
You must be signed in to change notification settings - Fork 0
/
DialogSetBrushSize.cpp
105 lines (79 loc) · 2.39 KB
/
DialogSetBrushSize.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// DialogSetBrushSize.cpp : implementation file
//
#include "stdafx.h"
#include "ImpressionistPaint.h"
#include "DialogSetBrushSize.h"
// CDialogSetBrushSize dialog
IMPLEMENT_DYNAMIC(CDialogSetBrushSize, CDialog)
CDialogSetBrushSize::CDialogSetBrushSize(CWnd* pParent /*=NULL*/)
: CDialog(CDialogSetBrushSize::IDD, pParent)
, m_pBrush(NULL)
{
}
CDialogSetBrushSize::~CDialogSetBrushSize()
{
}
void CDialogSetBrushSize::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SLIDERBRUSHSIZE, m_sldBrushSize);
DDX_Control(pDX, IDC_EDITBRUSHSIZE, m_txtBrushSize);
DDX_Control(pDX, IDC_STATICFRAME, m_lblFrame);
}
BEGIN_MESSAGE_MAP(CDialogSetBrushSize, CDialog)
ON_WM_ACTIVATE()
ON_WM_HSCROLL()
ON_BN_CLICKED(IDOK, &CDialogSetBrushSize::OnBnClickedOk)
END_MESSAGE_MAP()
// CDialogSetBrushSize message handlers
BOOL CDialogSetBrushSize::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_sldBrushSize.SetRange(0, 1000);
m_sldBrushSize.SetPos(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//INT_PTR CDialogSetBrushSize::DoModal()
//{
// // TODO: Add your specialized code here and/or call the base class
//
//
// return CDialog::DoModal();
//}
void CDialogSetBrushSize::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CDialog::OnActivate(nState, pWndOther, bMinimized);
// TODO: Add your message handler code here
double dBrushSize=m_pBrush->GetSize();
int pos=static_cast<int>((dBrushSize / 100.0) * 1000);
m_sldBrushSize.SetPos(pos);
CString fmt;
fmt.Format(_T("%f"), dBrushSize);
m_txtBrushSize.SetWindowTextW(fmt);
m_lblFrame.SetWindowTextW(m_pBrush->GetID());
}
void CDialogSetBrushSize::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int pos=m_sldBrushSize.GetPos();
double dBrushSize=(double)pos / 1000.0 * 100.0;
CString fmt;
fmt.Format(_T("%f"), dBrushSize);
m_txtBrushSize.SetWindowTextW(fmt);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CDialogSetBrushSize::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
int pos=m_sldBrushSize.GetPos();
if(pos == 0)
{
AfxMessageBox(_T("Brush Size cannot be zero"));
return;
}
double dBrushSize=(double)pos / 1000.0 * 100.0;
m_pBrush->SetSize(dBrushSize);
OnOK();
}