-
Notifications
You must be signed in to change notification settings - Fork 2
/
ChipSelectDlg.cpp
151 lines (115 loc) · 3.43 KB
/
ChipSelectDlg.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// CScaleEditorDlg.cpp : implementation file
//
#include "stdafx.h"
//#include "afxdialogex.h"
#include <cstdlib>
#include <cmath>
#include "FamiTracker.h"
#include "FamiTrackerDoc.h"
#include "MainFrm.h"
#include "ChipSelectDlg.h"
// CScaleEditorDlg dialog
IMPLEMENT_DYNAMIC(CChipSelectDlg, CDialog)
CChipSelectDlg::CChipSelectDlg(CWnd* pParent /*=nullptr*/)
: CDialog(CChipSelectDlg::IDD, pParent), m_pDocument(NULL)
{
}
CChipSelectDlg::~CChipSelectDlg()
{
}
void CChipSelectDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CChipSelectDlg, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_WM_VSCROLL()
END_MESSAGE_MAP()
// CScaleEditorDlg message handlers
BOOL CChipSelectDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Get active document
//CFrameWnd* pFrameWnd = static_cast<CFrameWnd*>(GetParent());
//m_pDocument = static_cast<CFamiTrackerDoc*>(pFrameWnd->GetActiveDocument());
RECT rcClient, rcWind, rcMenu;
POINT ptDiff;
GetClientRect(&rcClient);
GetWindowRect(&rcWind);
ptDiff.x = (rcWind.right - rcWind.left) - rcClient.right;
ptDiff.y = (rcWind.bottom - rcWind.top) - rcClient.bottom;
m_pChipList.Create(IDD_CHIP_LIST, this);
m_pChipList.ShowWindow(SW_SHOW);
m_pChipList.GetWindowRect(&rcMenu);
((CButton*)m_pChipList.GetDlgItem(IDC_CHIP_2A03))->SetCheck(1);
SCROLLINFO info;
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_ALL;
info.nMin = 0;
info.nMax = rcMenu.bottom-rcMenu.top+ptDiff.y;
info.nPage = rcClient.bottom;
info.nPos = 0;
info.nTrackPos = 0;
InitializeFlatSB(m_hWnd);
FlatSB_EnableScrollBar(m_hWnd, SB_VERT, ESB_ENABLE_BOTH);
FlatSB_ShowScrollBar(m_hWnd, SB_VERT, true);
FlatSB_SetScrollInfo(m_hWnd, SB_VERT, &info, true);
return TRUE;
}
void CChipSelectDlg::OnBnClickedOk()
{
OnOK();
}
void CChipSelectDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int CurPos = FlatSB_GetScrollPos(m_hWnd, SB_VERT);
RECT rcClient, rcWind;
POINT ptDiff;
GetClientRect(&rcClient);
GetWindowRect(&rcWind);
ptDiff.x = (rcWind.right - rcWind.left) - rcClient.right;
ptDiff.y = (rcWind.bottom - rcWind.top) - rcClient.bottom;
// Determine the new position of scroll box.
switch (nSBCode)
{
case SB_LEFT: // Scroll to far left.
CurPos = 0;
break;
case SB_RIGHT: // Scroll to far right.
CurPos = 122;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINEUP: // Scroll up.
//if (CurPos > 0)
CurPos=std::max(0,CurPos-16);
break;
case SB_LINEDOWN: // Scroll down.
//if (CurPos < 388 + 32)
CurPos = std::min(388 - 224 + (int)ptDiff.y,CurPos+16);
break;
case SB_PAGEUP: // Scroll one page up.
{
// Get the page size.
CurPos = std::max(0, CurPos - 224);
}
break;
case SB_PAGEDOWN: // Scroll one page down
{
// Get the page size.
CurPos = std::min(388 - 224 + (int)ptDiff.y, CurPos + 224);
}
break;
case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
CurPos = nPos; // of the scroll box at the end of the drag operation.
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. nPos is the
CurPos = nPos; // position that the scroll box has been dragged to.
break;
}
// Scroll window
m_pChipList.ScrollWindow(0, FlatSB_GetScrollPos(m_hWnd, SB_VERT) - CurPos);
FlatSB_SetScrollPos(m_hWnd, SB_VERT, CurPos, true);
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}