Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Highlighting/Emphasizing Popup Entries
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Highlighting/Emphasizing Popup Entries

 Post Reply Post Reply
Author
Message
mrmathis View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 May 2007
Location: United States
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mrmathis Quote  Post ReplyReply Direct Link To This Post Topic: Highlighting/Emphasizing Popup Entries
    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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2008 at 1:46am

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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.