Print Page | Close Window

Highlighting/Emphasizing Popup Entries

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=9408
Printed Date: 06 October 2024 at 2:22am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Highlighting/Emphasizing Popup Entries
Posted By: mrmathis
Subject: Highlighting/Emphasizing Popup Entries
Date 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 ( https://forum.codejock.com/uploads/20080124_121530_ribbonsamplecod.zip - uploads/20080124_121530_ribbonsamplecod.zip ).  I'd appreciate any suggestions on how to complete this task.
 
Thanks!
 
--Mike
 


-------------
--Mike



Replies:
Posted By: Oleg
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net