@@ -133,8 +133,59 @@ BEGIN_MESSAGE_MAP(CPPageToolBar, CMPCThemePPageBase)
133
133
ON_BN_CLICKED(IDC_BUTTON5, &CPPageToolBar::MoveUp)
134
134
ON_BN_CLICKED(IDC_BUTTON6, &CPPageToolBar::MoveDown)
135
135
ON_BN_CLICKED(IDC_BUTTON1, &CPPageToolBar::DefaultButtons)
136
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON3, OnUpdateLeft)
137
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON4, OnUpdateRight)
138
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON5, OnUpdateUp)
139
+ ON_UPDATE_COMMAND_UI(IDC_BUTTON6, OnUpdateDown)
136
140
END_MESSAGE_MAP()
137
141
142
+ void CPPageToolBar::OnUpdateLeft(CCmdUI* pCmdUI) {
143
+ CPlayerToolBar& tb = AfxGetMainFrame ()->m_wndToolBar ;
144
+ CToolBarCtrl& tbctrl = tb.GetToolBarCtrl ();
145
+ auto supportedButtons = tb.GetSupportedSvgButtons ();
146
+
147
+ int selectedRowLeft = m_list_active.GetSelectionMark ();
148
+ int selectedRowRight = m_list_inactive.GetSelectionMark ();
149
+
150
+ if (IsValidInsertPos (selectedRowLeft) && -1 != selectedRowRight) {
151
+ pCmdUI->Enable (true );
152
+ } else {
153
+ pCmdUI->Enable (false );
154
+ }
155
+ }
156
+
157
+ bool CPPageToolBar::LeftSelectedButtonLocked () {
158
+ CPlayerToolBar& tb = AfxGetMainFrame ()->m_wndToolBar ;
159
+ CToolBarCtrl& tbctrl = tb.GetToolBarCtrl ();
160
+ auto supportedButtons = tb.GetSupportedSvgButtons ();
161
+
162
+ int selectedRowLeft = m_list_active.GetSelectionMark ();
163
+
164
+ bool enable = false ;
165
+ if (-1 != selectedRowLeft) {
166
+ int tidCommand = (int )m_list_active.GetItemData (selectedRowLeft);
167
+ if (supportedButtons.count (tidCommand) == 0 || supportedButtons[tidCommand].positionLocked ) {
168
+ enable = false ;
169
+ } else {
170
+ enable = true ;
171
+ }
172
+ }
173
+ return enable;
174
+ }
175
+
176
+ void CPPageToolBar::OnUpdateRight (CCmdUI* pCmdUI) {
177
+ pCmdUI->Enable (LeftSelectedButtonLocked ());
178
+ }
179
+
180
+ void CPPageToolBar::OnUpdateUp (CCmdUI* pCmdUI) {
181
+ pCmdUI->Enable (LeftSelectedButtonLocked ());
182
+ }
183
+
184
+ void CPPageToolBar::OnUpdateDown (CCmdUI* pCmdUI) {
185
+ pCmdUI->Enable (LeftSelectedButtonLocked ());
186
+ }
187
+
188
+
138
189
bool CPPageToolBar::InsertButton (int beforeID, int buttonID) {
139
190
CPlayerToolBar& tb = AfxGetMainFrame ()->m_wndToolBar ;
140
191
CToolBarCtrl& tbctrl = tb.GetToolBarCtrl ();
@@ -175,6 +226,7 @@ bool CPPageToolBar::IsValidInsertPos(int destRow) {
175
226
if (destRow == -1 || destRow >= m_list_active.GetItemCount ()) {
176
227
return false ;
177
228
}
229
+
178
230
// avoid inserting between two locked rows, or before first locked or after last locked
179
231
180
232
CPlayerToolBar& tb = AfxGetMainFrame ()->m_wndToolBar ;
0 commit comments