![]() |
Control identifier |
Post Reply ![]() |
Author | |
Bart6 ![]() Groupie ![]() ![]() Joined: 22 March 2009 Location: Belgium Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() Posted: 13 May 2009 at 10:50am |
Hi all,
My application used a user-defined number of cameras (minimum 1). The user can pick from a commandbar the active camera. To populate the commandbar, i use: BOOST_FOREACH(ICamera* camera, cameras->Collection()) { CXTPControl* pCameraItem = pControls->Add(xtpControlButton, ID_CAMERA); pCameraItem->SetCaption( camera->Name().c_str() ); pCameraItem->SetChecked( camera == cameras->Active() ); } The listen to the commands, i use: ON_COMMAND(ID_CAMERA, OnCamera) and void CPyroView::OnCamera() { // what camera is being picked? } Question: all the controls in the commandbar have the same id (ID_CAMERA) - in OnCamera i can't make the distinction between what camera is picked. What is the correct method to use, when the amount of camera's is unknown (iow ON_COMMAND_RANGE cant be used) Thanks Bart |
|
![]() |
|
jimmy ![]() Senior Member ![]() Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
![]() ![]() ![]() ![]() ![]() |
Hi,
Add pCameraItem->SetTag( iIndex) Remove ON_COMMAND and insert this line ON_XTP_EXECUTE(ID_FILE_RECENTPROJECTS, OnCamera) void CPyroView::OnCamera(NMHDR *pNMHDR,LRESULT *pResult) { CXTPControl *pControl = ((NMXTPCONTROL *)pNMHDR)->pControl; if (pControl) { DWORD_PTR myIndex = pControl->GetTag(); // do yours } } Jimmy |
|
![]() |
|
jimmy ![]() Senior Member ![]() Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
![]() ![]() ![]() ![]() ![]() |
Or
pCameraItem->SetTag( (DWORD_PTR) camera ); ICamera* camera = (ICamera*) pControl->GetTag(); Jimmy |
|
![]() |
|
jimmy ![]() Senior Member ![]() Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
![]() ![]() ![]() ![]() ![]() |
Also can use
CXTPControl *CPyroView::GetControl(CCmdUI *pCmdUI) { if (!pCmdUI->m_pOther) return NULL; return ((CXTPCommandBar*)pCmdUI->m_pOther)->GetControl(pCmdUI->m_nIndex); } void CPyroView::OnUpdateCamera(CCmdUI *pCmdUI) { if (m_dwMenuLock & ML_ANY) pCmdUI->Enable(FALSE); else { CXTPControl* pControl = GetControl(pCmdUI); if (pControl) { ICamera* camera = (ICamera*) pControl->GetTag(); pCmdUI->SetCheck( (camera->Active()) ); } else pCmdUI->Enable(FALSE); } } Jimmy |
|
![]() |
|
Bart6 ![]() Groupie ![]() ![]() Joined: 22 March 2009 Location: Belgium Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() |
Thank you Kimmy - i'm trying the latter, but bump into undefined "m_dwMenuLock" & "ML_ANY". I searched the library, but could find any reference to it.
Will the last proposal also be capable of checking the active camera? (only active camera is checked, the other arent) Thanks again for looking inito this Bart |
|
![]() |
|
Bart6 ![]() Groupie ![]() ![]() Joined: 22 March 2009 Location: Belgium Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() |
(Jimmy - sorry for misspelling your name)
(I commented m_dwMenuLock & ML_ANY) I got this to work: //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- // void CPyroView::OnCamera(NMHDR *pNMHDR,LRESULT *pResult) { CXTPControl *pControl = ((NMXTPCONTROL *)pNMHDR)->pControl; if (pControl) { ICamera* camera = (ICamera*)pControl->GetTag(); assert(camera); camera->Activate(); } } //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- // CXTPControl* CPyroView::GetControl(CCmdUI *pCmdUI) { if (!pCmdUI->m_pOther) return NULL; return ((CXTPCommandBar*)pCmdUI->m_pOther)->GetControl(pCmdUI->m_nIndex); } //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- // void CPyroView::OnUpdateCamera(CCmdUI *pCmdUI) { //if (m_dwMenuLock & ML_ANY) // pCmdUI->Enable(FALSE); //else { CXTPControl* pControl = GetControl(pCmdUI); if (pControl) { ICamera* camera = (ICamera*) pControl->GetTag(); ASSERT(camera); pCmdUI->SetCheck(camera->IsActive()); pCmdUI->Enable(camera != NULL); } else pCmdUI->Enable(FALSE); } } Thanks! Bart |
|
![]() |
|
jimmy ![]() Senior Member ![]() Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
![]() ![]() ![]() ![]() ![]() |
Hi,
Sorry forgot to remove this lines. Because i copy some part from our application. Jimmy |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |