Example #1
0
void CMenuSpawn::RemapMenu(HMENU hMenu)
{
	static int iRecurse = 0;
	iRecurse ++;

	CMenu pMenu;
	pMenu.Attach(hMenu);
	
	ASSERT(pMenu);
	int nItem = pMenu.GetMenuItemCount();
	while ((--nItem)>=0)
	{
		UINT itemId = pMenu.GetMenuItemID(nItem);
		if (itemId == (UINT) -1)
		{
			CMenu pops(pMenu.GetSubMenu(nItem));
			if (pops.GetHandleMenu()) RemapMenu(pops.GetHandleMenu());
			if (bIsPopup || iRecurse > 0)
			{
				TCHAR cs[128];
				memset(cs,0x00,128);
				pMenu.GetMenuString(nItem, cs, 128,MF_BYPOSITION);
				if (lstrlen(cs)>0)
				{
					SpawnItem * sp = AddSpawnItem(cs, (!bIsPopup && iRecurse == 1) ? -4 : -2);
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW, (UINT) -1, (LPCTSTR)sp);
				}
			}
		}
		else
		{
			if (itemId != 0)
			{
				UINT oldState = pMenu.GetMenuState(nItem,MF_BYPOSITION);
				if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP))
				{
					ASSERT(oldState != (UINT)-1);
					TCHAR cs[128];
					memset(cs,0x00,128);
					pMenu.GetMenuString(nItem, cs, 128, MF_BYPOSITION);
					SpawnItem * sp = AddSpawnItem(cs, itemId);
					if (itemId!=SC_CLOSE)
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW|oldState, (LPARAM)itemId, (LPCTSTR)sp);
				}
			}
			else
			{
				UINT oldState = pMenu.GetMenuState(nItem,MF_BYPOSITION);
				if (!(oldState&MF_OWNERDRAW) && !(oldState&MF_BITMAP))
				{
					ASSERT(oldState != (UINT)-1);
					SpawnItem * sp = AddSpawnItem("--", -3);
					pMenu.ModifyMenu(nItem,MF_BYPOSITION|MF_OWNERDRAW|oldState, (LPARAM)itemId, (LPCTSTR)sp);
				}
			}
		}
	}
	iRecurse --;
	pMenu.Detach();
}
Example #2
0
void CHello2Dlg::OnStnDblclickRunGraph()
{
	// TODO: 在此添加控件通知处理程序代码
  CMenu   mainmenu;    
  mainmenu.LoadMenu(IDR_SELPROBE);
  m_graph.Invalidate();
  CMenu *pM = mainmenu.GetSubMenu(0);
  //remove the existing menu
  CString   str ;  
  int i;
  for(i=pM->GetMenuItemCount()-1;i>=0;i--)   //取得菜单的项数。  
  {    
          pM->GetMenuString(i,str,MF_BYPOSITION);    
          //将指定菜单项的标签拷贝到指定的缓冲区。MF_BYPOSITION的解释见上。    
		  pM->DeleteMenu(i,MF_BYPOSITION);   
  }
  pM->AppendMenu(MF_STRING,ID_32771,_T("关闭辅助显示"));
  for(i=0;i<sizeof(m_ridlgs)/sizeof(CRunitemDialog*);i++){
		CString name;
		name.Format(_T("同时显示通道%i"),i+1);
  		pM->AppendMenu(MF_STRING,ID_32771+1+i,name);
  }
  m_cmdbase = ID_32772;

  
  CPoint pt;
  GetCursorPos(&pt);
	SetForegroundWindow();
    pM->TrackPopupMenu(TPM_LEFTALIGN,pt.x,pt.y,this);
	return;
/*  CString tt;
  tt.Format(_T("clicked:%i,%i"),pt.x,pt.y);
  GetDlgItem(IDC_MAIN_STATUS)->SetWindowText(tt);
*/
}
Example #3
0
void CHello2Dlg::OnLbnDblclkList4()
{
	// TODO: 在此添加控件通知处理程序代码
  CMenu   mainmenu;    
  mainmenu.LoadMenu(IDR_SELPROBE);

  CMenu *pM = mainmenu.GetSubMenu(0);
  //remove the existing menu
  CString   str ;  
  int i;
  for(i=pM->GetMenuItemCount()-1;i>=0;i--)   //取得菜单的项数。  
  {    
          pM->GetMenuString(i,str,MF_BYPOSITION);    
          //将指定菜单项的标签拷贝到指定的缓冲区。MF_BYPOSITION的解释见上。    
		  pM->DeleteMenu(i,MF_BYPOSITION);   
  }
  pM->AppendMenu(MF_STRING,ID_32771,_T("显示转换结果"));
  pM->AppendMenu(MF_STRING,ID_32771+1,_T("显示原始数据"));
  pM->AppendMenu(MF_STRING,ID_32771+2,_T("删除选中数据"));
  pM->AppendMenu(MF_STRING,ID_32771+3,_T("清空所有数据"));
  pM->AppendMenu(MF_STRING,ID_32771+4,_T("导出所有数据"));
  m_cmdbase = ID_32773;

  CRect rect;
  m_chlist.GetClientRect(&rect);
  
  CPoint pt;
  GetCursorPos(&pt);

    pM->TrackPopupMenu(TPM_LEFTALIGN,pt.x,pt.y,this);
	return;

}
Example #4
0
void CCoolMenuBarCtrl::SetMenu(HMENU hMenu)
{
	m_hMenu = hMenu;
	
	Clear();
	
	if ( ! m_hMenu ) return;
	
	CMenu pMenu;
	pMenu.Attach( m_hMenu );
	
	for ( UINT nItem = 0 ; nItem < pMenu.GetMenuItemCount() ; nItem++ )
	{
		CString strMenu;
		pMenu.GetMenuString( nItem, strMenu, MF_BYPOSITION );
		
		int nAmp = strMenu.Find( '&' );
		if ( nAmp >= 0 ) strMenu = strMenu.Left( nAmp ) + strMenu.Mid( nAmp + 1 );
		
		CCoolBarItem* pItem = new CCoolBarItem( this, nItem + 1 );
		pItem->SetText( _T(" ") + strMenu + _T(" ") );
		m_pItems.AddTail( pItem );
	}
	
	pMenu.Detach();
}
Example #5
0
	void set_value(int id)	// sets selected menu item
	{
		for(int i=0; i<nItems; i++) popmenu.CheckMenuItem(i+100,MF_UNCHECKED);
		popmenu.CheckMenuItem(id+100,MF_CHECKED);
		CString	txt;
		popmenu.GetMenuString(id+100, txt, 24 );
		back.redraw();
		butt.redraw();
		txtbox.SetWindowText(txt);
		curr_sel=id+100;
	};
Example #6
0
static 
CString pGetMenuString(UINT MenuId)
{
	CMenu menu;
	CString menuString;
	menu.LoadMenu(MAKEINTRESOURCE(IDR_MAINPOPUP));
	menu.GetMenuString(MenuId, menuString, MF_BYCOMMAND);
	menuString.Remove(_T('&'));
	menu.DestroyMenu();
	return menuString;
}
//**************************************************************************************
void CBCGPTearOffManager::SetupTearOffMenus (HMENU hMenu)
{
	ASSERT (hMenu != NULL);

	CMenu* pMenu = CMenu::FromHandle (hMenu);
	if (pMenu == NULL)
	{
		return;
	}

	int iCount = (int) pMenu->GetMenuItemCount ();
	for (int i = 0; i < iCount; i ++)
	{
		UINT uiID = pMenu->GetMenuItemID (i);
		if (uiID != (UINT) -1)
		{
			continue;
		}

		UINT uiState = pMenu->GetMenuState (i, MF_BYPOSITION);
		if (uiState & MF_MENUBARBREAK)
		{
			CString str;
			pMenu->GetMenuString (i, str, MF_BYPOSITION);

			if (str [0] != cIDChar)
			{
				UINT uiCtrlBarId = GetFreeTearOffID ();
				if (uiCtrlBarId == 0)	// No more free IDs!
				{						// Reserve more IDs in Initialize!!!
					ASSERT (FALSE);
					return;
				}

				Build (uiCtrlBarId, str);
				pMenu->ModifyMenu (i, MF_BYPOSITION, i, str);
			}
		}

		CMenu* pPopupMenu = pMenu->GetSubMenu (i);
		if (pPopupMenu != NULL)
		{
			SetupTearOffMenus (pPopupMenu->GetSafeHmenu ());
		}
	}
}
//
// Find a statistic by its name (as stored in result file) and select it
// as though it had been selected from the menu.
// 
void CPageDisplay::SelectStatisticByName( int button, const char *statistic_name )
{
	unsigned int submenu_id, menu_item;

	if ( (button < 0) || (button >= NUM_STATUS_BARS) )
	{
		ErrorMessage("Invalid button value in CPageDisplay::SelectStatisticByName()");
		return;
	}
	if ( !statistic_name )
	{
		ErrorMessage("Invalid string in CPageDisplay::SelectStatisticByName()");
		return;
	}

	CMenu menu;
	VERIFY(menu.LoadMenu(IDR_POPUP_DISPLAY_LIST));

	CMenu* pPopup = menu.GetSubMenu(0);
	ASSERT(pPopup != NULL); // we can use ASSERT here because this should work every time if it works at all

	for ( submenu_id = 0; submenu_id < MDisplayNumSubmenus; submenu_id++ )
	{
		CMenu* pSubPopup = pPopup->GetSubMenu( submenu_id );
		if ( pSubPopup == NULL )
		{
			ErrorMessage("Could not get submenu in CPageDisplay::SelectStatisticByName()");
			return;
		}

		for ( menu_item = 0; menu_item < pSubPopup->GetMenuItemCount(); menu_item++ )
		{
			CString title;
			pSubPopup->GetMenuString( menu_item, title, MF_BYPOSITION );

			if ( title.CompareNoCase(statistic_name) == 0 )
			{
				selected_button = button;
				theApp.pView->OnMDisplay( submenu_id, pSubPopup->GetMenuItemID( menu_item ) );
				return;
			}
		}
	}
	// No match found, just leave the current selection unchanged
	return;
}
Example #9
0
// Call AttachCustomMenu once
//   it will replace the menu item with the ID  'IDM_TEST_CUSTOM_MENU'
//   with a color menu popup
// Replace the specified menu item with a color popup
void CTestWindow::AttachCustomMenu()
{
	// now add a few new menu items

	for (int iColor = 0; iColor < nColors; iColor++)
		m_colorMenu.AppendColorMenuItem(IDS_COLOR_NAME_FIRST + iColor, colors[iColor]);

	// Replace the specified menu item with a color popup
	//  (note: will only work once)
	CMenu* pMenuBar = GetMenu();
	ENSURE(pMenuBar != NULL);
	TCHAR szString[256];     // don't change the string

	pMenuBar->GetMenuString(IDM_TEST_CUSTOM_MENU, szString, sizeof(szString),
		MF_BYCOMMAND);
	VERIFY(GetMenu()->ModifyMenu(IDM_TEST_CUSTOM_MENU, MF_BYCOMMAND | MF_POPUP,
		(UINT_PTR)m_colorMenu.m_hMenu, szString));
}
//
// Generic handler for any selection from the IDR_POPUP_DISPLAY_LIST menu.  
// (The specific handlers for each selection are members of the CGalileoView class;
// they each call this function.)  Its main purpose is to set the result_to_display
// member variable.
//
// This function assumes that the member variable selected_button is set to 
// indicate the button that was pressed to pop up the menu.  This is typically done
// by the function OnBResultType(), which popped up the menu.
//
// The parameters submenu_id and menu_item are resource ID's, used to get the
// menu item string for the button label.  The parameter result_code must be one 
// of the *_RESULT constants from PageDisplay.h, and determines which result will
// be displayed by the status bar associated with the selected_button.
// 
void CPageDisplay::OnMDisplay( int submenu_id, int menu_item, int result_code )
{
	if ( (selected_button < 0) || (selected_button >= NUM_STATUS_BARS) )
	{
		ErrorMessage("Invalid selected_button value in CPageDisplay::OnMDisplay()");
		return;
	}
	if ( (submenu_id < 0) || (submenu_id >= MDisplayNumSubmenus) )
	{
		ErrorMessage("Invalid submenu_id value in CPageDisplay::OnMDisplay()");
		return;
	}
	if ( (result_code < 0) || (result_code >= NUM_RESULTS) )
	{
		ErrorMessage("Invalid result_code value in CPageDisplay::OnMDisplay()");
		return;
	}

	// store the selected result for later use
	barcharts[selected_button].result_to_display = result_code;

	// get the selected menu item's title and store it in the selected button
	CMenu menu;
	VERIFY(menu.LoadMenu(IDR_POPUP_DISPLAY_LIST));

	CMenu* pPopup = menu.GetSubMenu(0);
	ASSERT(pPopup != NULL); // we can use ASSERT here because this should work every time if it works at all

	CMenu* pSubPopup = pPopup->GetSubMenu( submenu_id );
	if ( pSubPopup == NULL )
	{
		ErrorMessage("Could not get submenu in CPageDisplay::OnMDisplay()");
		return;
	}

	CString title;
	pSubPopup->GetMenuString( menu_item, title, MF_BYCOMMAND );

	GetDlgItem( BResultType1 + selected_button )->SetWindowText( title );
	( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->SetCheck( FALSE );

	Update();
}
//**************************************************************************************
void CBCGPTearOffManager::Reset (HMENU hMenu)
{
	int nCount = m_uiTearOffMenuLast - m_uiTearOffMenuFirst + 1;

	if (hMenu == NULL)	// Reset all
	{
		for (int i = 0; i < nCount; i ++)
		{
			m_arTearOffIDsUsage [i] = 0;
		}

		return;
	}

	CMenu* pMenu = CMenu::FromHandle (hMenu);
	if (pMenu == NULL)
	{
		ASSERT (FALSE);
		return;
	}

	int iCount = (int) pMenu->GetMenuItemCount ();
	for (int i = 0; i < iCount; i ++)
	{
		CString str;
		pMenu->GetMenuString (i, str, MF_BYPOSITION);

		UINT uiTearOffID = Parse (str);
		if (uiTearOffID >= m_uiTearOffMenuFirst && uiTearOffID <= m_uiTearOffMenuLast)
		{
			m_arTearOffIDsUsage [uiTearOffID - m_uiTearOffMenuFirst] = 0;
		}

		if (pMenu->GetMenuItemID (i) == (UINT)-1)
		{
			CMenu* pPopupMenu = pMenu->GetSubMenu (i);
			ASSERT (pPopupMenu != NULL);

			Reset (pPopupMenu->GetSafeHmenu ());
		}
	}
}
Example #12
0
BOOL CMonitorWnd::ApplyMenu(UINT nMenuId)
{
	CMenu pMenu;
	pMenu.LoadMenu( nMenuId );
	
	CString str;
	pMenu.GetMenuString( 0, str, MF_BYPOSITION );
	
	CMenu* pSubMenu = pMenu.GetSubMenu( 0 );
	m_hSubMenu = pMenu.GetSubMenu(0)->m_hMenu;
	
	CMenu* pMainMenu = AfxGetMainWnd()->GetMenu();
	pMainMenu->AppendMenu( MF_POPUP|MF_STRING, (UINT)m_hSubMenu, str ); 
	
	pMainMenu->Detach();
	pMenu.Detach();
	
	AfxGetMainWnd()->DrawMenuBar();
	return TRUE;
}
Example #13
0
// Search the "Select" menu to see if a CRC setting name is in use.
// Returns the ID (index into settings_) if found or -1 if not
int CGeneralCRC::find_name(LPCTSTR name)
{
	int retval = -1;

	CMenu menu;
	menu.Attach(select_menu_.m_hMenu);
	int lst = menu.GetMenuItemCount();
	for (int ii = 0; ii < lst; ++ii)
	{
		CString ss;
		menu.GetMenuString(ii, ss, MF_BYPOSITION);
		if (ss.CompareNoCase(name) == 0)
		{
			retval = menu.GetMenuItemID(ii);
			break;
		}
	}

	menu.Detach();
	return retval;
}
Example #14
0
BOOL CCoolMenuBarCtrl::OpenMenuChar(UINT nChar)
{
	CMenu pMenu;
	pMenu.Attach( m_hMenu );

	for ( UINT nItem = 0 ; nItem < pMenu.GetMenuItemCount() ; nItem++ )
	{
		CString strMenu;
		pMenu.GetMenuString( nItem, strMenu, MF_BYPOSITION );

		LPCTSTR pszChar = _tcschr( strMenu, '&' );
		if ( ! pszChar++ ) continue;

		if ( toupper( *pszChar ) == toupper( nChar ) )
		{
			pMenu.Detach();
			if ( m_pSelect = GetIndex( nItem ) ) PostMessage( WM_TIMER, 5 );
			return TRUE;
		}
	}

	pMenu.Detach();
	return FALSE;
}
Example #15
0
void CMainFrame::OnInitMenu(CMenu* pMenu)
{
    CMDIFrameWnd::OnInitMenu(pMenu);

    //find the help submenu
    CMenu* pSubMenu = NULL;
    CString strHelp; strHelp.LoadString(IDS_TIPOFTHEDAYHELP);
    CString strMenu;
    int nMenuCount = pMenu->GetMenuItemCount();
    BOOL bFound = FALSE;
    for (int i=0; i < nMenuCount; i++) 
    {
	    pMenu->GetMenuString(i, strMenu, MF_BYPOSITION);
	    if (strMenu == strHelp)
	    { 
		    pSubMenu = pMenu->GetSubMenu(i);
		    bFound = TRUE;
		    ASSERT(pSubMenu != NULL);
	    }
    }

    CString strTipMenu;
    strTipMenu.LoadString(IDS_TIPOFTHEDAYMENU);
    if(bFound)
    {      
	    //check to see if the menu has already been added.
	    pSubMenu->GetMenuString(0, strMenu, MF_BYPOSITION);

        //only add it if the tips were loaded OK
	    if( strMenu != strTipMenu && m_wndMDIClientArea.m_fTipsLoadedOK )
	    {
		    pSubMenu->InsertMenu(0, MF_BYPOSITION);
		    pSubMenu->InsertMenu(0, MF_STRING|MF_BYPOSITION, IDS_TIPOFTHEDAY, strTipMenu);
	    }
    }
}
Example #16
0
void CHello2Dlg::OnLbnDblclkList3()
{
	// TODO: 在此添加控件通知处理程序代码
  CMenu   mainmenu;    
  mainmenu.LoadMenu(IDR_SELPROBE);

  CMenu *pM = mainmenu.GetSubMenu(0);
  //remove the existing menu
  CString   str   ;  
  
  for(int   i=pM->GetMenuItemCount()-1;i>=0;i--)   //取得菜单的项数。  
  {    
          pM->GetMenuString(i,str,MF_BYPOSITION);    
          //将指定菜单项的标签拷贝到指定的缓冲区。MF_BYPOSITION的解释见上。    
		  pM->DeleteMenu(i,MF_BYPOSITION);   
  }
  
  CSetting<PROBECFG> prbset;
  prbset.InstallFromFile(PRB_DEFINFO);			
  CString namelist = prbset.GetTitleList('|');	

  int curch = m_chlist.GetCurSel();
  if(curch < 0)
	  return;

  if(m_cfgtype == CFGTYPE_BORE)
  {
	int j = 1;
	pM->AppendMenu(MF_STRING,ID_32771,_T("关闭"));

	while(namelist.Find('|',0) >= 0){
		CString item = namelist.Left(namelist.Find('|',0));
		pM->AppendMenu(MF_STRING,ID_32771+j,item);   //添加新的菜单项		
		namelist.Delete(0,item.GetLength() + 1);
		j = j+1;
	}
	m_cmdbase = ID_32771;
  }
  if(m_cfgtype == CFGTYPE_THMO)
  {
	  //TBEJKNRS
	  m_cmdbase = ID_32771;;
	  pM->AppendMenu(MF_STRING,ID_32771,_T("关闭"));
	  pM->AppendMenu(MF_STRING,ID_32772,_T("T型热电偶"));
	  pM->AppendMenu(MF_STRING,ID_32773,_T("B型热电偶"));
	  pM->AppendMenu(MF_STRING,ID_32774,_T("E型热电偶"));
	  pM->AppendMenu(MF_STRING,ID_32775,_T("J型热电偶"));
	  pM->AppendMenu(MF_STRING,ID_32776,_T("K型热电偶"));
	  pM->AppendMenu(MF_STRING,ID_32777,_T("N型热电偶"));
	  pM->AppendMenu(MF_STRING,ID_32778,_T("R型热电偶"));
	  pM->AppendMenu(MF_STRING,ID_32779,_T("S型热电偶"));
  }
  CRect rect;
  m_chlist.GetClientRect(&rect);
  
  CPoint pt;
  GetCursorPos(&pt);
  SetForegroundWindow();
  pM->TrackPopupMenu(TPM_LEFTALIGN,pt.x,pt.y,this);
  return;

}
Example #17
0
BOOL CChatFrame::OnShowPopupMenu (CBCGPopupMenu* pMenuPopup)
{
	clearIdleTime();

	//---------------------------------------------------------
	// Replace ID_VIEW_TOOLBARS menu item to the toolbars list:
	//---------------------------------------------------------
    CFrameWnd::OnShowPopupMenu (pMenuPopup);

    if (pMenuPopup != NULL &&
		pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0)
    {
		if (CBCGToolBar::IsCustomizeMode ())
		{
			//----------------------------------------------------
			// Don't show toolbars list in the cuztomization mode!
			//----------------------------------------------------
			return FALSE;
		}

		pMenuPopup->RemoveAllItems ();

		CMenu menu;
		VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR));

		CMenu* pPopup = menu.GetSubMenu(0);
		ASSERT(pPopup != NULL);

		pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE);
    }
	
	if ( pMenuPopup != NULL && pMenuPopup->GetParentToolBar() == &m_wndTopChatBar )
	{
		if ( m_wndTopChatBar.GetButton( m_GameButton ) == pMenuPopup->GetParentButton() )
		{
			CWaitCursor wait;

			MetaClient & client = CGCQLApp::sm_MetaClient;
			if ( client.getGames( m_Games ) < 0 )
			{
				//MessageBox( "Failed to get game list." );
				return FALSE;
			}

			pMenuPopup->RemoveAllItems();

			CMenu gameMenu;
			gameMenu.CreatePopupMenu();

			for(int i=0;i<m_Games.size() && i < MAX_GAMES;i++)
				gameMenu.AppendMenu( MF_STRING, ID_GAMES_BEGIN + i, CString(m_Games[i].name) );

			pMenuPopup->GetMenuBar()->ImportFromMenu (gameMenu, TRUE);
		}
		if ( m_wndTopChatBar.GetButton( m_RoomsButton ) == pMenuPopup->GetParentButton() )
		{
			CWaitCursor wait;

			MetaClient & client = CGCQLApp::sm_MetaClient;
			if ( client.getRooms( m_Rooms ) < 0 )
				return FALSE;

			pMenuPopup->RemoveAllItems();

			CMenu roomMenu;
			roomMenu.CreatePopupMenu();
			roomMenu.AppendMenu( MF_STRING, ID_CHAT_CREATEROOM, _T("New Room") );
			roomMenu.AppendMenu( MF_SEPARATOR );

			for(int i=0;i<m_Rooms.size() && i < MAX_ROOMS;i++)
			{
				MetaClient::Room & room = m_Rooms[i];
				
				CString sName;
				sName.Format( _T("%s "), CString( room.name ) );
				if ( room.flags & MetaClient::FLAG_ROOM_MODERATED )
					sName += _T("[MODERATED]");
				if ( room.flags & MetaClient::FLAG_ROOM_PASSWORD )
					sName += _T("[PRIVATE]");
				if ( room.flags & MetaClient::FLAG_ROOM_PRIVATE )
					sName += _T("[HIDDEN]");

				CString sMembers;
				sMembers.Format( _T("\t%u"), room.members );

				sName += sMembers;

				roomMenu.AppendMenu( MF_STRING, ID_ROOM_BEGIN + i, sName );
			}

			pMenuPopup->GetMenuBar()->ImportFromMenu (roomMenu, TRUE);
		}
		if ( m_wndTopChatBar.GetButton( m_FriendsButton ) == pMenuPopup->GetParentButton() )
		{
			CWaitCursor wait;

			MetaClient & client = CGCQLApp::sm_MetaClient;
			if ( client.getFriends( m_Friends ) < 0 )
			{
				//MessageBox( "Failed to get room list." );
				return FALSE;
			}
			
			// let friends who are online appear on top of the list
			m_Friends.qsort( userOnlineSort );

			pMenuPopup->RemoveAllItems();

			CMenu friendsMenu;
			friendsMenu.CreatePopupMenu();

			for(int i=0;i<m_Friends.size() && i < MAX_FRIENDS;i++)
			{
				MetaClient::ShortProfile & profile = m_Friends[ i ];

				CString sFriend;
				sFriend.Format(_T("%s\t%s"), CString(profile.name), CString(profile.status) );

				CMenu friendMenu;
				friendMenu.CreateMenu();
				friendMenu.AppendMenu( MF_STRING, ID_FRIEND_MSG_BEGIN + i, _T("Message") );
				friendMenu.AppendMenu( MF_STRING, ID_FRIEND_DEL_BEGIN + i, _T("Delete") );
				friendsMenu.AppendMenu( MF_POPUP, (UINT)friendMenu.Detach(), sFriend );
			}

			pMenuPopup->GetMenuBar()->ImportFromMenu( friendsMenu, TRUE );
		}
		if ( m_wndTopChatBar.GetButton( m_StaffButton ) == pMenuPopup->GetParentButton() )
		{
			CWaitCursor wait;

			MetaClient & client = CGCQLApp::sm_MetaClient;
			if ( client.getStaffOnline( m_Staff ) < 0 )
				return FALSE;
			
			dword userId = client.profile().userId;
			for( int i = 0 ; i < m_Staff.size() ; i++ )
				if( m_Staff[ i ].userId == userId )
				{
					m_Staff.remove(i);
					break;
				}

			pMenuPopup->RemoveAllItems();

			CMenu staffMenu;
			staffMenu.CreatePopupMenu();

			for(int i=0;i<m_Staff.size() && i < MAX_STAFF;i++)
			{
				MetaClient::ShortProfile & profile = m_Staff[ i ];

				CString sType;
				if ( profile.flags & MetaClient::ADMINISTRATOR )
					sType = "[ADMIN]";
				else if ( profile.flags & MetaClient::MODERATOR )
					sType = "[MOD]";

				CString sName;
				sName = profile.name;
				CString sStaffMember;
				sStaffMember.Format( _T("%s: %s\t%s"), sType, sName, CString(profile.status) );

				CMenu stMenu;
				stMenu.CreateMenu();
				stMenu.AppendMenu( MF_STRING, ID_STAFF_MSG_BEGIN + i, _T("Message") );

				bool bInserted = false;
				for(unsigned int j=0;j<staffMenu.GetMenuItemCount() && !bInserted;j++)
				{
					CString sCompare;
					staffMenu.GetMenuString( j, sCompare, MF_BYPOSITION );

					if ( _tcscmp( sCompare, sName ) > 0 )
					{
						staffMenu.InsertMenu( j, MF_BYPOSITION|MF_POPUP, (UINT)stMenu.Detach(), sStaffMember ) ? true : false;
						bInserted = true;
					}
				}

				if (!bInserted )
					staffMenu.AppendMenu( MF_POPUP, (UINT)stMenu.Detach(), sStaffMember );
			}

			pMenuPopup->GetMenuBar()->ImportFromMenu( staffMenu, TRUE );
		}
		if ( m_wndTopChatBar.GetButton( m_ClanButton ) == pMenuPopup->GetParentButton() )
		{
			CWaitCursor wait;

			pMenuPopup->RemoveAllItems();

			MetaClient & client = CGCQLApp::sm_MetaClient;

			CMenu clanMenu;
			clanMenu.CreatePopupMenu();
			//clanMenu.AppendMenu( MF_STRING, ID_GAMEBAR_CLAN, _T("Fleet Home") );

			dword clanId = client.profile().clanId;
			if ( clanId != 0 )
			{
				clanMenu.AppendMenu( MF_SEPARATOR );
				if ( client.getClan( clanId, m_Clan ) < 0 )
				{
					//MessageBox( "Failed to get clan members" );
					return FALSE;
				}
				
				// Remove self from clanlist
				for( int i = 0 ; i < m_Clan.size() ; i++ )
					if( m_Clan[i].userId == client.profile().userId )
					{
						m_Clan.remove(i);
						break;
					}

				// let members who are online appear on top of the list
				m_Clan.qsort( userOnlineSort );

				for( int i = 0 ; i < m_Clan.size() && i < MAX_CLAN ; i++ )
				{
					MetaClient::ShortProfile & profile = m_Clan[ i ];

					CString sClanMember;
					sClanMember.Format( _T("%s\t%s"), CString(profile.name), CString(profile.status) );

					CMenu subMenu;
					subMenu.CreateMenu();
					subMenu.AppendMenu( MF_STRING, ID_CLAN_MSG_BEGIN + i, _T("Message") );

					clanMenu.AppendMenu( MF_POPUP, (UINT)subMenu.Detach(), sClanMember );
				}
			}

			pMenuPopup->GetMenuBar()->ImportFromMenu( clanMenu, TRUE );
		}

	}

	return TRUE;
}
Example #18
0
BOOL CMainWizard::OnInitDialog(void)
{
	CString strRestore;
	CString strMinimize;
	CMenu menuTemp;
	CString strNewItem;
	int nInitialDelay, nAutoPopDelay;
	int cxMaxWidth;
	DWORD crTipBk, crTipText;

	// invoke inherited handler
	BOOL fResult = __super::OnInitDialog();

	CenterWindow(FromHandle(::GetDesktopWindow()));

	// set wizard's icons
	SetIcon(m_hIcon, TRUE);
	SetIcon(m_hSmIcon, FALSE);

	// try to obtain localized text for the "Minimize" system command
	HMODULE hUser32 = ::GetModuleHandle(_T("user32"));
	if (menuTemp.Attach(::LoadMenu(hUser32, MAKEINTRESOURCE(16))))
	{
		menuTemp.GetMenuString(SC_RESTORE, strRestore, MF_BYCOMMAND);
		menuTemp.GetMenuString(SC_MINIMIZE, strMinimize, MF_BYCOMMAND);
		::DestroyMenu(menuTemp.Detach());
	}
	if (strMinimize.IsEmpty())
	{
		// probably fuckin' Win9x
		strRestore.LoadString(IDS_SC_RESTORE);
		strMinimize.LoadString(IDS_SC_MINIMIZE);
	}

	// adjust system menu
	CMenu* pSysMenu = GetSystemMenu(FALSE);
	ASSERT_VALID(pSysMenu);
	pSysMenu->InsertMenu(SC_MOVE, MF_BYCOMMAND, SC_RESTORE, strRestore);
	pSysMenu->InsertMenu(SC_CLOSE, MF_BYCOMMAND, SC_MINIMIZE, strMinimize);
	pSysMenu->InsertMenu(SC_CLOSE, MF_BYCOMMAND | MF_SEPARATOR);
	MENUITEMINFO miInfo = { sizeof(miInfo), MIIM_BITMAP };
	miInfo.hbmpItem = HBMMENU_POPUP_RESTORE;
	::SetMenuItemInfo(pSysMenu->GetSafeHmenu(), SC_RESTORE, FALSE, &miInfo);
	miInfo.hbmpItem = HBMMENU_POPUP_MINIMIZE;
	::SetMenuItemInfo(pSysMenu->GetSafeHmenu(), SC_MINIMIZE, FALSE, &miInfo);
	ModifyStyle(0, WS_MINIMIZEBOX);

	int iInsertPos = 0;

	CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
	ASSERT_VALID(pApp);

	if (m_arrLangNames.GetCount() > 1)
	{
		CMenu menuLangs;
		menuLangs.LoadMenu(IDR_MENU_LANGS);
		CMenu* pPopupMenu = menuLangs.GetSubMenu(0);
		ASSERT_VALID(pPopupMenu);

		UINT_PTR uID = reinterpret_cast<UINT_PTR>(pPopupMenu->Detach());
		CString strText;
		menuLangs.GetMenuString(0, strText, MF_BYPOSITION);
		pSysMenu->InsertMenu(iInsertPos++, MF_BYPOSITION | MF_POPUP, uID, strText);
		pSysMenu->InsertMenu(iInsertPos++, MF_BYPOSITION | MF_SEPARATOR);
		menuLangs.Detach();

		CheckCurLangMenuItem();
	}

	OSVERSIONINFO osVerInfo = { sizeof(osVerInfo) };
	GetVersionEx(&osVerInfo);
	if (osVerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && osVerInfo.dwMajorVersion >= 5)
	{
		// Windows 2000/XP/2003
		strNewItem.LoadString(IDS_SC_EXPORT_SETTINGS);
		pSysMenu->InsertMenu(iInsertPos++, MF_BYPOSITION, IDM_SC_EXPORT_SETTINGS, strNewItem);
		strNewItem.LoadString(IDS_SC_IMPORT_SETTINGS);
		pSysMenu->InsertMenu(iInsertPos++, MF_BYPOSITION, IDM_SC_IMPORT_SETTINGS, strNewItem);
		pSysMenu->InsertMenu(iInsertPos++, MF_BYPOSITION | MF_SEPARATOR);
	}

	// customize tool tips
	nInitialDelay = pApp->GetProfileInt(SZ_REGK_TIPS, SZ_REGV_TIPS_INITIAL_DELAY, 900);
	nAutoPopDelay = pApp->GetProfileInt(SZ_REGK_TIPS, SZ_REGV_TIPS_AUTO_POP_DELAY, 5000);
	cxMaxWidth = pApp->GetProfileInt(SZ_REGK_TIPS, SZ_REGV_TIPS_MAX_WIDTH, 300);
	crTipBk = pApp->GetProfileInt(SZ_REGK_TIPS, SZ_REGV_TIPS_BK_COLOR, ::GetSysColor(COLOR_INFOBK));
	crTipText = pApp->GetProfileInt(SZ_REGK_TIPS, SZ_REGV_TIPS_TEXT_COLOR, ::GetSysColor(COLOR_INFOTEXT));
	int cPages = m_pages.GetSize();
	for (int i = 0; i < cPages; ++i)
	{
		CBetterPropPage* pPage = reinterpret_cast<CBetterPropPage*>(m_pages[i]);
		CToolTipCtrl& tipWnd = pPage->GetToolTipCtrl();
		tipWnd.SetDelayTime(TTDT_INITIAL, nInitialDelay);
		tipWnd.SetDelayTime(TTDT_AUTOPOP, nAutoPopDelay);
		tipWnd.SetMaxTipWidth(cxMaxWidth);
		tipWnd.SetTipBkColor(crTipBk);
		tipWnd.SetTipTextColor(crTipText);
	}

	// initialized
	return (fResult);
}
Example #19
0
bool CMainFrame::SetLanguageMenu()
{
	CMenu* pParentMenu = GetMenu();
	CMenu* pMenu = GetMenu()->GetSubMenu( m_nLangOptionMenuPos );
    
    CUStringConvert strCnv;

	ASSERT( pMenu );

	if ( NULL == m_pPopupMenu )
	{
		m_pPopupMenu = new CMenu;

		m_pPopupMenu->CreatePopupMenu();

		CUString strAdd( g_language.GetString( IDS_CHECKFORADDITIONAL_LANGUAGE_FILES ) );

        CUStringConvert strCnv;

		// Add Check for Updates
        m_pPopupMenu->AppendMenu( MF_STRING | MF_ENABLED, ID_LANGUAGE_START, strCnv.ToT( strAdd ) );

		// Add language menu items
		for ( DWORD idx = 0; idx < g_language.GetNumLanguageStrings() ; idx++ )
		{

			CUString strAdd( g_language.GetLanguageString( idx ) );
			m_pPopupMenu->AppendMenu( MF_STRING | MF_ENABLED, ID_LANGUAGE_START + idx + 1, strCnv.ToT( strAdd ) );
		}
	}

	CString strCurrent;
	pMenu->GetMenuString( m_nLangLangMenuPos, strCurrent, MF_BYPOSITION );

	// Add language menu items
	for ( DWORD idx = 0; idx < m_pPopupMenu->GetMenuItemCount(); idx++ )
	{
		CString strMenu;

		if ( 0 == idx )
		{
			m_pPopupMenu->ModifyMenu(	idx, 
										MF_BYPOSITION | MF_STRING,
										ID_LANGUAGE_START,
										strCnv.ToT( g_language.GetString( IDS_CHECKFORADDITIONAL_LANGUAGE_FILES ) ));

		}

		// get menu string
		m_pPopupMenu->GetMenuString( idx, strMenu, MF_BYPOSITION );

		// check if this is the selected language
		if ( 0 == g_language.GetLanguage().CompareNoCase( CUString( strMenu ) ) )
		{
			m_pPopupMenu->CheckMenuItem( idx, MF_BYPOSITION | MF_CHECKED  );
		}
		else
		{
			m_pPopupMenu->CheckMenuItem( idx, MF_BYPOSITION | MF_UNCHECKED  );
		}
	}

	// remove exisiting menu item
	pMenu->RemoveMenu( m_nLangLangMenuPos, MF_BYPOSITION );

	// insert new popup menu
	pMenu->InsertMenu(	m_nLangLangMenuPos,
						MF_BYPOSITION | MF_POPUP, 
						(UINT)m_pPopupMenu->m_hMenu, 
						strCurrent );


	// peform translation
	g_language.TranslateMenu( GetMenu(), m_nMenuID );

	// refresh frame windows
	ActivateFrame( SW_HIDE );
	ActivateFrame( SW_SHOW );

	return true;
}
Example #20
0
void MenuVoicing::OnMenuSelect(UINT	nItemID, UINT nFlags, HMENU	hSysMenu)
{
	USES_CONVERSION;

	//CMenu* pMenu = DYNAMIC_DOWNCAST(CMenu, (CObject*)hSysMenu);
	//TRACE("OnMenuSelect, hSysMenu=%p is %s\n", hSysMenu, ::IsMenu(hSysMenu) ? "HMENU" : pMenu ? "CMenu" : "unknown");

	bool isSysMenu = false;
	//HWND hWnd = MainWndParts::Instance()->mpMainFrame->GetSafeHwnd();
	CMenu * pSysMenu = mFrm->GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		if (pSysMenu->m_hMenu == hSysMenu)
		{
			amis::util::Log* p_log = amis::util::Log::Instance();
			p_log->writeTrace("System Menu", "MenuVoicing::OnMenuSelect");
			TRACE("System Menu !");
			isSysMenu = true;
		}
	}

	if (isSysMenu)
	{
		CString str;
		pSysMenu->GetMenuString(nItemID, str, MF_BYCOMMAND);
		str.Replace(L"&", L"");
		AudioSequence* seq = new AudioSequence;
		seq->append(str);
		AudioSequencePlayer::Instance()->Play(seq);
		//CMenu* p_menu = p_menu->GetSubMenu(nItemID);

		/*
		int nLen = ::GetMenuString(pSysMenu, nItemID, NULL, 0, MF_BYCOMMAND);
		if (nLen > 0) {

		LPTSTR lpszText = (LPTSTR)_alloca((nLen + 1) * sizeof(TCHAR));
		if (::GetMenuString(pSysMenu, nItemID, lpszText, nLen + 1, MF_BYCOMMAND) == nLen) {

		CString str;

		//pSysMenu->GetMenuString(nItemID, str, nFlags);
		//TRACE(str);
		str.Append(lpszText);

		str.Replace(L"&", L"");

		//str.Replace(CString("&"), CString(""));

		AudioSequence* seq = new AudioSequence;
		seq->append(str);
		AudioSequencePlayer::Instance()->Play(seq);


		}
		}
		*/
		return;
	}


	//don't	read separators
	if (nFlags & MF_SEPARATOR) return;

	CString	s;
	string prompt;

	if (nFlags & MF_POPUP)
	{
		if ( nFlags	& MF_BYPOSITION	)
		{
			//AmisBrain::Instance()->playPromptFromUiId(nItemID);
		}
		if ( nFlags	& MF_BYCOMMAND )
		{
			//AmisBrain::Instance()->playPromptFromUiId(nItemID);
		}

		if ((nItemID ==	8 || nItemID ==	2 || nItemID ==	3) && m_lastOpenPopupMenu != NULL && ::IsMenu(m_lastOpenPopupMenu->m_hMenu))  // 8 => "recent" (including separators), 2 => "show section depth"
		{
			UINT nID = m_lastOpenPopupMenu->GetMenuItemID(0);
			std::string	prompt = computeRootMenuFromFirstChildID(nID, false);

			s.Format(_T("\nMenuVoicing::OnMenuSelect(%d) '%s'\n"), nItemID, prompt.c_str());
			TRACE(s);
			amis::util::Log* p_log = amis::util::Log::Instance();
			p_log->writeTrace(T2A(s));

			AudioSequence* seq = createSeqPrepend(nFlags);
			if (prompt.compare("file") == 0	|| prompt.compare("recentBooksList") ==	0)
			{
				AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "recentBooksList");
				PromptItem* p_prompt_	= DataTree::Instance()->findPromptItem("menu");
				if (p_prompt_ != NULL)
					AudioSequencePlayer::fillSequenceContents(seq, p_prompt_);
				else
					seq->append(_T("menu"));
					
				if (seq->GetCount() == 0) delete seq;
				else AudioSequencePlayer::Instance()->Play(seq);
				
				return;
			}
			else if (prompt.compare("navigate") == 0 || prompt.compare("sectiondepth") ==	0)
			{
				AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "sectiondepth");
				PromptItem* p_prompt_	= DataTree::Instance()->findPromptItem("menu");
				if (p_prompt_ != NULL)
					AudioSequencePlayer::fillSequenceContents(seq, p_prompt_);
				else
					seq->append(_T("menu"));
				
				if (seq->GetCount() == 0)	delete seq;
				else	AudioSequencePlayer::Instance()->Play(seq);
				
				return;
			}
			else if (prompt.compare("view") == 0 || prompt.compare("pageStylesList") ==	0)
			{
				AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "pageStylesList");
				PromptItem* p_prompt_	= DataTree::Instance()->findPromptItem("menu");

				if (p_prompt_ != NULL)
					AudioSequencePlayer::fillSequenceContents(seq, p_prompt_);
				
				else
					seq->append(_T("menu"));
				
				if (seq->GetCount() == 0) delete seq;
				else AudioSequencePlayer::Instance()->Play(seq);
				
				return;
			}
			else
			{
				delete seq;
			}
		} 
		else if ((nItemID >=0 && nItemID <=6) && (m_lastOpenPopupMenu == NULL))  //TODO:	Yuuk ! UGLY	! This is only a temporary workaround !	//(nFlags & MF_GRAYED)
		{
			s.Format(_T("\nMenuVoicing::OnMenuSelect(%d)\n"), nItemID);
			TRACE(s);
			amis::util::Log* p_log = amis::util::Log::Instance();
			p_log->writeMessage(T2A(s), "MenuVoicing::OnMenuSelect");

			AudioSequence* seq = createSeqPrepend(nFlags);
			switch (nItemID)
			{
				case 0:
				{
					AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "file");
					break;
				}
				case 1:
				{
					AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "view");
					break;
				}
				case 2:
				{
					AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "play");
					break;
				}
				case 3:
				{
					AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "navigate");
					break;
				}
				case 4:
				{
					AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "bookmarks");
					break;
				}
				case 5:
				{
					AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "info");
					break;
				}
				case 6:
				{
					AudioSequencePlayer::fillSequenceContainerPromptFromId(seq, "help");
					break;
				}
			}
			
			PromptItem* p_prompt_	= DataTree::Instance()->findPromptItem("menu");
			if (p_prompt_ != NULL)
				AudioSequencePlayer::fillSequenceContents(seq, p_prompt_);
			else
				seq->append(_T("menu"));

			if (seq->GetCount() == 0) delete seq;
			else AudioSequencePlayer::Instance()->Play(seq);
			
			return;
		}
	}
	else
	{
		s.Format(_T("MenuVoicing::OnMenuSelect(%d is	selected)\n"), nItemID);
		TRACE(s);
		amis::util::Log* p_log = amis::util::Log::Instance();
		p_log->writeTrace(T2A(s), "MenuVoicing::OnMenuSelect");

		amis::BookList* books = theApp.getHistory();
		int nRecentBooks = (books ? books->getNumberOfEntries() : 0);

		if	(nRecentBooks > 0 && (nItemID >= AMIS_RECENT_BOOK_BASE_ID && 
			nItemID < AMIS_RECENT_BOOK_BASE_ID + nRecentBooks))
		{
			int	idx	= nItemID -	AMIS_RECENT_BOOK_BASE_ID;
			amis::BookEntry* p_entry = theApp.getHistory()->getEntry(idx);
			AudioSequence* seq = createSeqPrepend(nFlags);
			amis::AudioNode* node = p_entry->getTitleAudio();
			std::wstring title = p_entry->getTitleText();
			CString strTitle(title.c_str());
			if (node != NULL && node->getPath().length() > 0) // todo: the src string length check is there because there seems to be a bug in getTitleAudio
			{
				seq->append(node->clone(), strTitle);
			}
			else if (title.length() != 0)
			{
				seq->append(strTitle);
			}
			
			string str = p_entry->mPath.get_url();
			seq->append(A2T(str.c_str()));
			AudioSequencePlayer::Instance()->Play(seq);
			return;

			//CString cstr_filepath = A2T(filepath.c_str());

			/*
			amis::io::BookmarksFileIO bmk_file_io;
			bmk_file_io.readFromFile(&p_entry->mPath);

			amis::MediaGroup* p_title =	NULL;
			p_title	= bmk_file_io.getBookmarkSet()->getTitle();

			if (p_title	!= NULL)
			{
			if (p_title->hasAudio()	== true)
			{
			amis::AudioNode* p_audio = NULL;
			p_audio	= (amis::AudioNode*)p_title->getAudio(0)->clone();
			if (p_audio	!= NULL)
			{
			seq->append(p_audio);
			AudioSequencePlayer::Instance()->Play(seq);

			}


			}else if (p_title->hasText() == true)
			{
			amis::TextNode* p_text = NULL;
			p_text	= p_title->getText();
			if (p_text	!= NULL)
			{
			wstring str = p_text->getTextString();
			seq->append(str.c_str());
			AudioSequencePlayer::Instance()->Play(seq);
			}


			}

			} */
		}
		else if (nItemID	>= AMIS_BOOKMARKS_BASE_ID &&	nItemID	<= 
				AMIS_BOOKMARKS_BASE_ID + AMIS_MAX_ANYTHING)
		{
			int	idx	= nItemID -	AMIS_BOOKMARKS_BASE_ID;

			//amis::dtb::BookmarkSet* p_bmks = amis::dtb::DtbWithHooks::Instance()->getBookmarks();
			//amis::dtb::PositionMark* p_mark = p_bmks->getItem(idx);

			AudioSequence* seq = createSeqPrepend(nFlags);
			amis::MediaGroup* p_note = amis::dtb::DtbWithHooks::Instance()->getBookmarks()->getItem(idx)->mpNote;
			if (p_note!=NULL)
			{
				if (p_note->hasAudio() == true)
				{
					amis::AudioNode* p_audio = NULL;
					p_audio	= p_note->getAudio(0);
					if (p_audio	!= NULL)
					{
						amis::TextNode* p_text = NULL;
						p_text	= p_note->getText();
						seq->append(p_audio->clone(), (p_text != NULL ? p_text->getTextString().c_str() : L""));
						AudioSequencePlayer::Instance()->Play(seq);
						return;
					}
				}
				else if (p_note->hasText() == true)
				{
					amis::TextNode* p_text = NULL;
					p_text	= p_note->getText();
					if (p_text	!= NULL)
					{
						wstring str = p_text->getTextString();
						seq->append(str.c_str());
						AudioSequencePlayer::Instance()->Play(seq);
						return;
					}
				}
			}
		} 
		else if (nItemID > AMIS_SECTION_DEPTH_BASE_ID 
				&& nItemID <= (AMIS_SECTION_DEPTH_BASE_ID + AMIS_MAX_ANYTHING))
		{
			string strPrompt;
			switch (nItemID)
			{
				case (AMIS_SECTION_DEPTH_BASE_ID+1):
				{
					strPrompt = "numeric_one";
					break;
				}
				case (AMIS_SECTION_DEPTH_BASE_ID+2):
				{
					strPrompt = "numeric_two";
					break;
				}
				case (AMIS_SECTION_DEPTH_BASE_ID+3):
				{
					strPrompt = "numeric_three";
					break;
				}
				case (AMIS_SECTION_DEPTH_BASE_ID+4):
				{
					strPrompt = "numeric_four";
					break;
				}
				case (AMIS_SECTION_DEPTH_BASE_ID+5):
				{
					strPrompt = "numeric_five";
					break;
				}
				case (AMIS_SECTION_DEPTH_BASE_ID+6):
				{
					strPrompt = "numeric_six";
					break;
				}
				case (AMIS_SECTION_DEPTH_BASE_ID+7):
				{
					strPrompt = "numeric_seven";
					break;
				}
				case (AMIS_SECTION_DEPTH_BASE_ID+8):
				{
					strPrompt = "numeric_eight";
					break;
				}
				case (AMIS_SECTION_DEPTH_BASE_ID+9):
				{
					strPrompt = "numeric_nine";
					break;
				}
			}
			if (!strPrompt.empty())
			{
				//seq->append(strPrompt.c_str()); TEST ONLY
				AudioSequencePlayer::playPromptFromStringId(strPrompt);
				return;
			}
		}
		//is this a	view menu item (sections/prodnotes/etc)
		else if	(nItemID >=	AMIS_VIEW_MENU_BASE_ID && nItemID < AMIS_VIEW_MENU_BASE_ID + 
				MenuManip::Instance()->getNumberOfViewMenuNavContainers())
		{
			amis::dtb::nav::NavModel* p_model = amis::dtb::DtbWithHooks::Instance()->getNavModel();
			//first	item in	the	list is	always "sections"
			if (nItemID	== AMIS_VIEW_MENU_BASE_ID)
			{
				AudioSequencePlayer::playPromptFromStringId("sections");
			}
			//then "pages",	if exists
			else if	(nItemID ==	AMIS_VIEW_MENU_BASE_ID + 1 && 
				p_model != NULL && p_model->hasPages())
			{
				AudioSequencePlayer::playPromptFromStringId("pages");
			}
			else if (p_model != NULL)
			{
				//otherwise	it's a nav list	so ask NavParse	for	the	nav	list ID
				//subtract 1 because the menu items	include	sections, pages, navlists
				//we want just the index relative to nav lists
				int	idx	= nItemID -	AMIS_VIEW_MENU_BASE_ID - 1;

				//adjust again by subtracting 1	if there are pages in this book
				if (p_model->hasPages()	== true)
				{
					idx--;
				}

				std::string	item_id	= p_model->getNavList(idx)->getId();

				if (item_id.compare("prodnote")	== 0 ||
					item_id.compare("optional-prodnote") ==	0 )
				{
					AudioSequencePlayer::playPromptFromStringId("prodnotes");
				}
				else if	(item_id.compare("sidebar")	== 0)
				{
					AudioSequencePlayer::playPromptFromStringId("sidebars");
				}
				else if	(item_id.compare("footnote") ==	0 ||
					item_id.compare("noteref") == 0)
				{
					AudioSequencePlayer::playPromptFromStringId("noterefs");
				}
				else 
				{
					//we can't identify	it,	so read	its	name with TTS
					AudioSequencePlayer::playPromptFromUiId(nItemID);
				}
			}
		}
		else 
		{
			AudioSequence* seq = createSeqPrepend(nFlags);
			AudioSequencePlayer::playPromptFromUiId(nItemID, seq);
			return;
		}
	}
}
Example #21
0
void CChatBkDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
	// TODO:  在此添加消息处理程序代码和/或调用默认值

	if(m_selBtnRect.PtInRect(point))
	{
		CMenu poupoMenu;
		poupoMenu.CreatePopupMenu();

		USERINFO::IPListLock.lock(CReadWriteLock::LOCK_LEVEL_READ);
		int index = 0;
		for (set<tstring>::iterator it = m_pCurrentUser->ipList.begin(); it != m_pCurrentUser->ipList.end(); ++it, ++index)
		{
			if(_tcscmp(m_curUserIP.c_str(), (*it).c_str())		== 0)
				poupoMenu.AppendMenu(MF_STRING | MF_CHECKED, WM_INDEXBASE + index,	(*it).c_str());
			else
				poupoMenu.AppendMenu(MF_STRING, WM_INDEXBASE + index,	(*it).c_str());
		}
		USERINFO::IPListLock.unlock();

		int menuSel = 0;
		CPoint pt = point;
		ClientToScreen(&pt);
		if(menuSel = poupoMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, this))
		{
			CString strText = _T("");
			poupoMenu.GetMenuString(menuSel, strText, MF_BYCOMMAND);

			m_curUserIP = strText;
			Invalidate(FALSE);
		}

		poupoMenu.DestroyMenu();
	}
	else if (m_minBtnRect.PtInRect(point))
	{
		ShowWindow(SW_MINIMIZE);
		return;
	}
	else if (m_maxBtnRect.PtInRect(point))
	{
		if (IsZoomed())
			ShowWindow(SW_NORMAL);
		else
			ShowWindow(SW_MAXIMIZE);
		return;
	}
	else if (m_closeBtnRect.PtInRect(point) || m_close1BtnRect.PtInRect(point))
	{
		OnCancel();
		return;
	}
	else if (m_sendBtnRect.PtInRect(point))
	{
		PostMessage(WM_PRESEND);
		return;
	}
	else if (m_sendFileRc.PtInRect(point))
	{
		AfxGetMainWnd()->SendMessage(WM_PRESEND, 1, 0);
		return;
	}
	else if (m_sendDicRc.PtInRect(point))
	{
		AfxGetMainWnd()->SendMessage(WM_PRESEND, 2, 0);
		return;
	}
	else if (m_sendPictureRc.PtInRect(point))
	{
		AfxGetMainWnd()->SendMessage(WM_PRESEND, 3, 0);
		return;
	}


	CDialog::OnLButtonUp(nFlags, point);
}
Example #22
0
void CCompileEditView::SaveDataMenu(UINT nID)
{
	if(g_pSaveMenu.m_hMenu == NULL)
		return;

	CString strComm;
	g_pSaveMenu.GetMenuString(nID,strComm,MF_BYCOMMAND);
	if(strComm.IsEmpty())
		return;

	int nPos = strComm.Find(":");
	if( nPos != -1 )
	{
		strComm = strComm.Mid(nPos+1);
	}
	if(strComm.IsEmpty())
		return;

	if(!IsCompileEdit(COMPILE))
		return;

	CTreeCtrlFormula* pHxTreeCtrl = NULL;

	HTREEITEM hFloatTreeItem = NULL;
	CTreeCtrlFormula* pFloatTree = NULL;
	CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
	if(pMain != NULL)
	{
		if(pMain->GetIndividualInfo() != NULL)
		{
			pFloatTree = pMain->GetIndividualInfo();
		}
	}

	HTREEITEM hTreeItem = NULL;
	char	  cType = 0;
	
	nID -= SAVEMENU_BEGIN;
	if(nID >= 0 && nID < 100)
	{
		cType = Tech;
		if(pHxTreeCtrl != NULL)
		{				
			hTreeItem = pHxTreeCtrl->GetRootTree(CTreeCtrlFormula::g_strTech);//		 = "技术指标";
			hTreeItem = pHxTreeCtrl->GetTreeItem(strComm,hTreeItem);
		}
		if(pFloatTree != NULL)
		{
			hFloatTreeItem = pFloatTree->GetRootTree(CTreeCtrlFormula::g_strTech);//		 = "技术指标";
			hFloatTreeItem = pFloatTree->GetTreeItem(strComm,hFloatTreeItem);
		}
	}
	if( nID >= 100 && nID < 200 )
	{
		cType = Condition;
		if(pHxTreeCtrl != NULL)
		{
			hTreeItem = pHxTreeCtrl->GetRootTree(CTreeCtrlFormula::g_strCondition);//		 = "技术指标";				
			hTreeItem = pHxTreeCtrl->GetTreeItem(strComm,hTreeItem);
		}
		if(pFloatTree != NULL)
		{
			hFloatTreeItem = pFloatTree->GetRootTree(CTreeCtrlFormula::g_strCondition);//		 = "技术指标";
			hFloatTreeItem = pFloatTree->GetTreeItem(strComm,hFloatTreeItem);
		}
	}
	if( nID >= 200 && nID < 300 )
	{
		cType = Exchange;
		if(pHxTreeCtrl != NULL)
		{
			hTreeItem = pHxTreeCtrl->GetRootTree(CTreeCtrlFormula::g_strExchange);//		 = "技术指标";				
			hTreeItem = pHxTreeCtrl->GetTreeItem(strComm,hTreeItem);
		}
		if(pFloatTree != NULL)
		{
			hFloatTreeItem = pFloatTree->GetRootTree(CTreeCtrlFormula::g_strExchange);//		 = "技术指标";
			hFloatTreeItem = pFloatTree->GetTreeItem(strComm,hFloatTreeItem);
		}
	}
	if( nID >= 300 && nID < 400 )
	{
		cType = MoreKLine;
		if(pHxTreeCtrl != NULL)
		{
			hTreeItem = pHxTreeCtrl->GetRootTree(CTreeCtrlFormula::g_strColorKLine);//		 = "技术指标";				
			hTreeItem = pHxTreeCtrl->GetTreeItem(strComm,hTreeItem);
		}
		if(pFloatTree != NULL)
		{
			hFloatTreeItem = pFloatTree->GetRootTree(CTreeCtrlFormula::g_strColorKLine);//		 = "技术指标";
			hFloatTreeItem = pFloatTree->GetTreeItem(strComm,hFloatTreeItem);
		}
	}		
	if( nID >= 400 && nID < 500 )
	{
		cType = ExpressBin;
		if(pHxTreeCtrl != NULL)
		{
			hTreeItem = pHxTreeCtrl->GetRootTree(CTreeCtrlFormula::g_strRecycleBin);//		 = "技术指标";				
			hTreeItem = pHxTreeCtrl->GetTreeItem(strComm,hTreeItem);
		}
		if(pFloatTree != NULL)
		{
			hFloatTreeItem = pFloatTree->GetRootTree(CTreeCtrlFormula::g_strRecycleBin);//		 = "技术指标";
			hFloatTreeItem = pFloatTree->GetTreeItem(strComm,hFloatTreeItem);
		}
	}

	CString strName;
	CComboBox* pBox = NULL;
	if(m_pwndDlgMainBar != NULL)
	{
		pBox = (CComboBox*)m_pwndDlgMainBar->GetDlgItem(IDC_NAMECOMBO);
		if(pBox != NULL)
		{			
			pBox->GetWindowText(strName);
			strName.MakeUpper();
			if( pBox->FindString(0,strName) != CB_ERR )
			{
				CValue* valoare;
				if ( m_pExternExpression->Lookup(strName,valoare) ) // 外部表达式表
				{
				}
			}
			else
			{
				pBox->AddString(strName);
			}
		}
	}
	

	if( pHxTreeCtrl != NULL && hTreeItem != NULL && !strName.IsEmpty())
	{
		m_hExpressInTreePos = pHxTreeCtrl->AddItem(strName,cType,hTreeItem/*pHxTreeCtrl->GetCurSavePos(hTreeItem)*/,m_pExternExpression);
	}

	// 浮动窗口	
	if( pFloatTree != NULL && hFloatTreeItem != NULL && !strName.IsEmpty())
	{
		pFloatTree->AddItem(strName,cType,hFloatTreeItem/*pFloatTree->GetCurSavePos(hFloatTreeItem)*/,m_pExternExpression);
	}

	::SendMessage( g_hParentWnd,HX_USER_UPDATEDATA,0,(LPARAM)&strName );
}
BOOL CXTPResizePropertySheet::OnInitDialog()
{

	CRect rcClientBegin, rcClientEnd;
	GetWindowRect(rcClientBegin);
	SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)(LPRECT)rcClientBegin);

	// Modify the window style to include WS_THICKFRAME for resizing.
	::SetWindowLong(m_hWnd,
		GWL_STYLE, GetStyle() | WS_THICKFRAME);

	GetWindowRect(rcClientEnd);
	SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)(LPRECT)rcClientEnd);

	CPropertySheet::OnInitDialog();

	// subclass our "flicker-free" tab control.
	m_tabCtrl.SubclassWindow(GetTabControl()->m_hWnd);

	// the size icon is too close to the buttons, so inflate the sheet
	CRect rc;
	GetWindowRect(rc);

	if (rcClientBegin.Width() - rcClientEnd.Width() > 3)
	{
		rc.InflateRect((rcClientBegin.Width() - rcClientEnd.Width()) / 2,
			(rcClientBegin.Height() - rcClientEnd.Height()) / 2);
		MoveWindow(rc);
	}
	// Do this last so that any prop pages are moved accordingly
	else if (!HasFlag(xtpResizeNoSizeIcon) && !IsWizard())
	{
		rc.InflateRect(1, 1, 2, 2);
		MoveWindow(rc);
	}

	// add sizing entries to the system menu
	CMenu* pSysMenu = (CMenu*)GetSystemMenu(FALSE);
	if (pSysMenu)
	{
		CString szMaximize, szMinimize, szSize, szRestore;
		// try to get the strings from the topmost window
		CWnd* pwndTop;
		for (pwndTop = this; pwndTop->GetParent(); pwndTop = pwndTop->GetParent());

		CMenu* pTopSysMenu = (CMenu*)pwndTop->GetSystemMenu(FALSE);
		if (pTopSysMenu)
		{
			pTopSysMenu->GetMenuString(SC_MAXIMIZE, szMaximize, MF_BYCOMMAND);
			pTopSysMenu->GetMenuString(SC_MINIMIZE, szMinimize, MF_BYCOMMAND);
			pTopSysMenu->GetMenuString(SC_SIZE, szSize, MF_BYCOMMAND);
			pTopSysMenu->GetMenuString(SC_RESTORE, szRestore, MF_BYCOMMAND);
		}
		// if we din't get the strings then set them to the English defaults
		if (szMaximize.IsEmpty()) szMaximize = _T("Ma&ximize");
		if (szMinimize.IsEmpty()) szMinimize = _T("Mi&nimize");
		if (szSize.IsEmpty()) szSize = _T("&Size");
		if (szRestore.IsEmpty()) szRestore = _T("&Restore");

		pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_SEPARATOR, 0, (LPCTSTR) 0);
		pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_MAXIMIZE, szMaximize);
		pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_MINIMIZE, szMinimize);
		pSysMenu->InsertMenu(1, MF_BYPOSITION | MF_STRING, SC_SIZE, szSize);
		pSysMenu->InsertMenu(0, MF_BYPOSITION | MF_STRING, SC_RESTORE, szRestore);
	}

	DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
	if ((dwStyle & WS_THICKFRAME) == 0)
	{
		SetFlag(xtpResizeNoSizeIcon);
	}

	CXTPResize::Init();

	// Check which buttons are available in sheet or wizard
	if (IsWizard())
	{
		SetResize(ID_WIZBACK, XTP_ATTR_REPOS(1));
		SetResize(ID_WIZNEXT, XTP_ATTR_REPOS(1));
		SetResize(ID_WIZFINISH, XTP_ATTR_REPOS(1));
		SetResize(ID_WIZLINE, XTP_ANCHOR_BOTTOMLEFT, XTP_ANCHOR_BOTTOMRIGHT);
	}
	else
	{
		SetResize(IDOK, XTP_ATTR_REPOS(1));
		SetResize(ID_APPLY_NOW, XTP_ATTR_REPOS(1));
		SetResize(AFX_IDC_TAB_CONTROL, XTP_ATTR_RESIZE(1));
	}
	SetResize(IDCANCEL, XTP_ATTR_REPOS(1));
	SetResize(IDHELP, XTP_ATTR_REPOS(1));

	// set page sizings
	CRect rcPage;
	GetActivePage()->GetWindowRect(rcPage);
	ScreenToClient(rcPage);
	int i;
	for (i = 0; i <GetPageCount(); i++)
	{
		SetResize(GetPage(i), XTP_ATTR_RESIZE(1), rcPage);
	}


	return TRUE;
}
Example #24
0
void CFavMenu::LoadFavorites(HMENU &fav_menu, char type)
{
	max_height = GetSystemMetrics(SM_CYSCREEN) - 64;
	item_height = GetSystemMetrics(SM_CYMENU);

	MENUITEMINFO mi;	mi.cbSize = sizeof(mi);	mi.fMask = MIIM_DATA;	mi.dwItemData = 0;
	int last = GetMenuItemCount(fav_menu) - 1;
	CString _add_to_fav("a"), _open_all("o"), _org_fav("e");
	add_to_home = "h";
	if (GetMenuItemInfo(fav_menu, last, TRUE, &mi) && mi.dwItemData)
	{
		last = bbs_fav.GetSize() - 1;
		add_to_home = bbs_fav[last--];
		_org_fav = bbs_fav[last--];
		_open_all = bbs_fav[last--];
		_add_to_fav = bbs_fav[last];
		DestroyMenu(fav_menu);
	}
	else
	{
		CMenu tmp;	tmp.Attach(fav_menu);	CString str;
		tmp.GetMenuString(last--, str, MF_BYPOSITION);	add_to_home += str;
		tmp.GetMenuString(last--, str, MF_BYPOSITION);	_org_fav += str;
		tmp.GetMenuString(last--, str, MF_BYPOSITION);	_open_all += str;
		tmp.GetMenuString(last, str, MF_BYPOSITION);		_add_to_fav += str;
	}

//  Favorite 內容經過修改後,menu 必須重建,而原來的 favorite menu 會被刪除,
//  所以先前建立的 menu 都已經無效,必須從 CFavMenu 的 array 中移除掉。
//	favmenus.RemoveAll();
//	錯誤,這樣會把其他favorite和history的CFavMenu <-> HMENU對應刪除
//	改成下列方式,因為上面已經 DestroyMenu( fav_menu ),所以可以很投機取巧的
//	利用 IsMenu 來檢查,移除 favmenu 中已經無效的 Handles
	int i;	//	此 i 在稍後的程式還有使用
	for (i = favmenus.GetSize() - 1;i >= 0;i--)	//搜尋看是否為CFavMenu
		if (!IsMenu(reinterpret_cast<HMENU>(favmenus[i])))
			favmenus.RemoveAt(i);
	//	刪除特定位置第i個 item 後,其後的array都會往前 shift 1,
	//	但是不用管他,因為是由後往前檢查,所以i後面的都已經檢查過

	if ((i = _add_to_fav.Find('\t')) >= 0)
		add_to_fav = _add_to_fav.Left(i);
	else
		add_to_fav = _add_to_fav;

	if ((i = _open_all.Find('\t')) >= 0)
		open_all = _open_all.Left(i);
	else
		open_all = _open_all;

	if ((i = _org_fav.Find('\t')) >= 0)
		org_fav = _org_fav.Left(i);
	else
		org_fav = _org_fav;

	CFile file;
#if defined(_COMBO_)
	if (file.Open(ConfigPath + (type == 's' ?
								BBS_FAVORITE_FILENAME : WWW_FAVORITE_FILENAME), CFile::modeRead))
#else
	if (file.Open(ConfigPath + BBS_FAVORITE_FILENAME, CFile::modeRead))
#endif
	{
		UINT id;
#if defined(_COMBO_)
		CStringArray* data;
		if (type == 's')
		{
			data = &bbs_fav;
			id = ID_FIRST_BBS_FAVORITE;
		}
		else
		{
			data = &web_fav;
			id = ID_FIRST_WEB_FAVORITE;
		}
#else
		CStringArray* data = &bbs_fav;
		id = ID_FIRST_BBS_FAVORITE;
#endif
		data->RemoveAll();

		CArchive ar(&file, CArchive::load);
		int menu_height = 0;
		fav_menu = DoLoadFavorites(ar, *data, id, menu_height);
		data->Add(_add_to_fav);
		AppendMenu(fav_menu, MF_OWNERDRAW, ID_ADDTOFAVORITE, LPCTSTR(id), menu_height);
		++id;

		data->Add(_open_all);
		AppendMenu(fav_menu, MF_OWNERDRAW, id/*ID_FAVORITE_OPENALL*/, LPCTSTR(id), menu_height);
		++id;

		data->Add(_org_fav);
		AppendMenu(fav_menu, MF_OWNERDRAW, id/*ID_FAVORITE_EDIT*/, LPCTSTR(id), menu_height);
		++id;

		data->Add(add_to_home);
		AppendMenu(fav_menu, MF_OWNERDRAW, ID_ADDTOHOME, LPCTSTR(id), menu_height);
	}
}