![]() |
Highlighting/Emphasizing Popup Entries |
Post Reply ![]() |
Author | |
mrmathis ![]() Senior Member ![]() ![]() Joined: 17 May 2007 Location: United States Status: Offline Points: 105 |
![]() ![]() ![]() ![]() ![]() Posted: 24 January 2008 at 12:22pm |
I have some "command finder" functionality that is used to highlight a command's location on the ribbon bar. It's a learning tool to help the novice user with menu navigation. To identify a given command, I "flash" it with a few timer-spaced calls to pControl->SetChecked(TRUE/FALSE).
This works fine until I come to items on a popup menu. In that case, the call only highlights the icon portion of the menu, as shown on the left. I would like to highlight the entire menu entry, as shown on the right.
![]() ![]() I get the desired "look" when the user mouses over the menu, but I can't figure out how to get there programmatically.
Additionally, I would like to do this with commands that are currently inactive (disabled). I've tried enabling the command temporarily, but the command-active code kicks in and re-disables the command before the display happens. I'd rather not involve the command-active code with this (rather peripheral) functionality, but can't figure out a way to get around that.
I've attached modifications to the ribbon sample to show how I got this far (uploads/20080124_121530_ribbonsamplecod.zip). I'd appreciate any suggestions on how to complete this task.
Thanks!
--Mike
|
|
--Mike
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Vert dirty code. Easy to write new than fix your. Here my solution:CXTPControl* GetControlPath(int nID, CXTPControls* pControls, CPtrArray& arr) { int nCount = pControls->GetCount(); for (int i = 0; i < nCount; ++i)
{ CXTPControl* pControl = pControls->GetAt(i); if(nID == pControl->GetID())
{ return pControl; } if (pControl->GetCommandBar() != NULL)
{ CXTPControl* p = GetControlPath(nID, pControl->GetCommandBar()->GetControls(), arr); if (p) { arr.InsertAt(0, pControl); return p; } } } return NULL; } CXTPControl* GetControlPath(CXTPCommandBars* pCommandBars, int nID, CPtrArray& arr)
{ int nCount = pCommandBars->GetCount(); for (int i = 0; i < nCount; ++i) { CXTPToolBar* pBar = pCommandBars->GetAt(i); CXTPControl* pControl = GetControlPath(nID, pBar->GetControls(), arr); if (pControl) return pControl; } return NULL;
} void CMainFrame::OnViewShowHide(UINT nID) { int CmdID = ID_EDIT_PASTE_SPECIAL; CPtrArray arrPath;
CXTPControl* pControl = GetControlPath(GetCommandBars(), CmdID, arrPath); if(!pControl) return; for (int i = 0; i < arrPath.GetSize(); i++)
{ CXTPControl* pControl = (CXTPControl*)arrPath.GetAt(i); pControl->GetParent()->SetTrackingMode(TRUE, FALSE, TRUE);
pControl->GetParent()->SetSelected(pControl->GetIndex(), TRUE); pControl->GetParent()->SetPopuped(pControl->GetIndex()); } pControl->GetParent()->SetTrackingMode(TRUE, FALSE, TRUE);
pControl->GetParent()->SetSelected(-1); DWORD dwSleep = 100;
int nCnt = 4; pControl->GetParent()->UpdateWindow();
AfxGetApp()->PumpMessage(); for (int ii = 0; ii < nCnt; ii++) { { CClientDC dc(pControl->GetParent()); dc.Draw3dRect(pControl->GetRect(), 0xFF, 0xFF); } Sleep(dwSleep); pControl->RedrawParent(0); pControl->GetParent()->UpdateWindow(); Sleep(dwSleep); } } |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
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 |