예제 #1
0
/******************************************************************************
 *  void SetMruMenu(HWND hwnd)
 * 
 *  update the mru menu items according to the changed mru list
 *
 *  parameters:
 *      hwnd           - window handle of window with mru menu items
 *
 * notes:
 *      The mru list appears in the File menu for the window's menu bar.
 *      The file menu can be the first (0th) or second (1th) by_position
 *      depending on whether the mdi child is maximized (see mmenu.c MenuStatus()).
 *
 *      Assumes the file menu last two items initially are a separator followed
 *      by a menu item (exit).  Inserts mru items following the separator followed
 *      by a new separator.
 ******************************************************************************/
static void SetMruMenu(HWND hwnd)
{
    char sz[sizeof("&1 ") + _MAX_PATH];
    char *psz;
    HMENU hMenu = GetMenu(hwnd);
    int i;
    int nExit;

    /* find the File menu */
    assert(hMenu != 0);
    if ( hMenu == 0 )
        return;
    GetMenuString(hMenu, 1, sz, sizeof(sz), MF_BYPOSITION);
    if ( stricmp(sz, "&File") == 0 )
        hMenu = GetSubMenu(hMenu, 1);
    else
        hMenu = GetSubMenu(hMenu, 0);        
    assert(hMenu != 0);
    if ( hMenu == 0 )
        return;

    /* delete any mru items presently in the file menu */
    for ( i = 0; i < MAX_MRUFILES; i++ )
        DeleteMenu(hMenu, IDM_FILE_MRUFILE1 + i, MF_BYCOMMAND);

    /* if the 3rd entry from the bottom is a separator, then we assume it's
        the one we inserted for the mru section, and delete it (to be reinserted below) */
    i = GetMenuItemCount(hMenu);
    nExit = GetMenuItemID(hMenu, i - 1);
    if ( GetMenuItemID(hMenu, i - 3) == 0 )
        DeleteMenu(hMenu, i - 3, MF_BYPOSITION);

    if ( arszMruFilenames[0][0] != '\0' )
        {
        /* insert mru file names */
        for ( i = 0; i < MAX_MRUFILES && *arszMruFilenames[i] != '\0'; i++ )
            {
            wsprintf(sz, "&%d ", i + 1);
            psz = sz + strlen(sz);
            MiscShortFilename(
                arszMruFilenames[i],
                psz,
                sizeof("C:\\...\\PATHNAME.EXT\\FILENAME.EXT") - 1);
            InsertMenu(
                hMenu,
                nExit,
                MF_BYCOMMAND | MF_STRING,
                IDM_FILE_MRUFILE1 + i,
                sz
                );
            }

        /* (re)insert separator preceding File/Exit */
        InsertMenu(hMenu, nExit, MF_BYCOMMAND | MF_SEPARATOR, 0, 0);
        }
}
예제 #2
0
WORD playermenu_find_unique_id( )
{
   WORD id = 1024; // Client menu IDs are well below this number.
   for (vector<MODULE*>::const_iterator i = g_modules.begin( ); i != g_modules.end( ); ++i)
   {
      const int count = GetMenuItemCount( (*i)->menu );
      for (int j = 0; j < count; ++j)
      {
         if ((WORD) GetMenuItemID( (*i)->menu, j ) == id)
            id = (WORD) GetMenuItemID( (*i)->menu, j ) + 1;
      }
   }
   return id;
}
예제 #3
0
파일: MainWnd.cpp 프로젝트: Yonsm/RawPlayer
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 弹出菜单初始化
VOID CMainWnd::OnMenuPopup(WPARAM wParam, LPARAM lParam)
{
	HWND hWnd;
	DWORD dwSize;
	TCHAR tzTemp[512];
	TCHAR tzPath[512];

	switch (GetMenuItemID((HMENU) wParam, 0))
	{
	case IDM_Help_Desktop:
		// 判断快捷方式是否存在
		CheckCommand(IDM_Help_Desktop, CShortcut::Exist(CSIDL_DESKTOP));
		CheckCommand(IDM_Help_StartMenu, CShortcut::Exist(CSIDL_STARTMENU));
		CheckCommand(IDM_Help_ProgramMenu, CShortcut::Exist(CSIDL_PROGRAMS));
		CheckCommand(IDM_Help_QuickLaunch, CShortcut::Exist(CSIDL_APPDATA));
		CheckCommand(IDM_Help_VisualStudio, CVSTool::Exist());
		break;

	case IDM_Play_Play:
		hWnd = CClientWnd::GetActive();
		_ExIf(hWnd, SendMessage(hWnd, WM_INITMENUPOPUP, wParam, lParam));
		break;

	case IDM_View_Toolbar:
		GetModuleFileName(NULL, tzTemp, MAX_PATH);
		wsprintf(tzPath, TEXT("\"%s\" \"%%1\""), tzTemp);
		dwSize = _NumOf(tzTemp);
		SHGetValue(HKEY_CLASSES_ROOT, STR_AppName TEXT("\\shell\\open\\command"), NULL, NULL, tzTemp, &dwSize);
		CheckCommand(IDM_View_AssociateFile, lstrcmpi(tzTemp, tzPath) == 0);			
		break;
	}
}
예제 #4
0
파일: wmdisim.c 프로젝트: hubei/open-watcom
/*
 * CheckForMessage - check for a WM_COMMAND message that needs to be
 *                   sent to the maximized window
 */
static bool CheckForMessage( HMENU menu, HWND currentWindow,
                             WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    int         num;
    int         i;
    UINT        id;
    UINT        flags;

    if( menu != NULL ) {
        num = (int)_wpi_getmenuitemcount( menu );
        for( i = 0; i < num; i++ ) {
            flags = GetMenuState( menu, i, MF_BYPOSITION );
            if( flags & MF_POPUP ) {
                if( CheckForMessage( GetSubMenu( menu, i ), currentWindow,
                                     wparam, lparam ) ) {
                    return( TRUE );
                }
            } else {
                id = GetMenuItemID( menu, i );
                if( id == wparam ) {
                    _wpi_sendmessage( currentWindow, WM_COMMAND, wparam, lparam );
                    return( TRUE );
                }
            }
        }
    }
    return( FALSE );

} /* CheckForMessage */
예제 #5
0
void menu_helpers::win32_auto_mnemonics(HMENU menu)
{
	mnemonic_manager mgr;
	unsigned n, m = GetMenuItemCount(menu);
	pfc::string8_fastalloc temp,temp2;
	for(n=0;n<m;n++)//first pass, check existing mnemonics
	{
		unsigned type = uGetMenuItemType(menu,n);
		if (type==MFT_STRING)
		{
			uGetMenuString(menu,n,temp,MF_BYPOSITION);
			mgr.check_string(temp);
		}
	}

	for(n=0;n<m;n++)
	{
		HMENU submenu = GetSubMenu(menu,n);
		if (submenu) win32_auto_mnemonics(submenu);

		{
			unsigned type = uGetMenuItemType(menu,n);
			if (type==MFT_STRING)
			{
				unsigned state = submenu ? 0 : GetMenuState(menu,n,MF_BYPOSITION);
				unsigned id = GetMenuItemID(menu,n);
				uGetMenuString(menu,n,temp,MF_BYPOSITION);
				if (mgr.process_string(temp,temp2))
				{
					uModifyMenu(menu,n,MF_BYPOSITION|MF_STRING|state,id,temp2);
				}
			}
		}
	}
}
예제 #6
0
///////////////////////////////////////////////////////////////////////////////
//// Event Handle
//
LRESULT CTrayIcon::OnTrayNotification( WPARAM wID, LPARAM lEvent )
{
	if ( wID!=m_nid.uID ||
		( lEvent!=WM_RBUTTONUP && lEvent!=WM_LBUTTONDBLCLK ) )
		return 0;

	HMENU pSubMenu = GetSubMenu( m_hMenu , 0 );	
	ASSERT( pSubMenu );
	if ( !pSubMenu ) 
		return 0;

	if( m_nDefMenuItem == 0 )
	{
		m_nDefMenuItem = GetMenuItemID( m_hMenu, 0 );
	}

	if ( lEvent==WM_RBUTTONUP )
	{

		// Make 'm_nDefMenuItem' menu item the default (bold font)
		ASSERT( SetMenuDefaultItem( pSubMenu, m_nDefMenuItem, FALSE ) != 0 );


		POINT mouse;
		GetCursorPos( &mouse );
		SetForegroundWindow( m_nid.hWnd );	
		TrackPopupMenu( pSubMenu, 0, mouse.x, mouse.y, 0, m_nid.hWnd, NULL );

	}
	else  // execute default menu item
		SendMessage( m_nid.hWnd, WM_COMMAND, m_nDefMenuItem, 0 );

	return 1; // handled
}
예제 #7
0
void CFrameWnd::OnShowMenuPopupHint(HMENU hMenu)
{
	// Get ID of first item in menu.
	int iFirstID = GetMenuItemID(hMenu, 0);
    
    // Is a first item?
    if (iFirstID != -1)
    {
		CString strHint;
		
		// Get application object.
		CTask* pApp = CTask::This();
		ASSERT(pApp);
	
		// Calculate menu hint and load.
		// The hint is always a multiple of 100.
		int iHintID = iFirstID - (iFirstID % 10);

		strHint.LoadRsc(iHintID);

		// Show hint.
		if (m_pStatusBar)
			m_pStatusBar->HintBar()->Hint(strHint);
	}
	else
	{
		// Show dummy hint.
		if (m_pStatusBar)
			m_pStatusBar->HintBar()->Hint("");
	}
}
예제 #8
0
	static uint32_t LuaGuiGetMenuItemId(void *hMenu, uint32_t position)
	{
		return GetMenuItemID(
			reinterpret_cast<HMENU>(hMenu),
			position
			);
	}
예제 #9
0
파일: shlmenu.c 프로젝트: AlexSteel/wine
static HRESULT WINAPI CompositeCMenu_HandleMenuMsg(IContextMenu3 *iface, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    CompositeCMenu *This = impl_from_IContextMenu3(iface);
    HMENU menu;
    UINT id;
    UINT index;
    IContextMenu2 *handler;
    HRESULT hres;
    TRACE("(%p)->(%x,%lx,%lx)\n",iface,uMsg,wParam,lParam);
    switch(uMsg)
    {
    case WM_INITMENUPOPUP:
        menu = (HMENU)wParam;
        id = GetMenuItemID(menu,LOWORD(lParam));
        break;
    case WM_DRAWITEM:
        id = ((DRAWITEMSTRUCT*)lParam)->itemID;
        break;
    case WM_MEASUREITEM:
        id = ((MEASUREITEMSTRUCT*)lParam)->itemID;
        break;
    default:
        WARN("Unimplemented uMsg: 0x%x\n",uMsg);
        return E_NOTIMPL;
    }
    index = CompositeCMenu_GetIndexForCommandId(This,id);
    hres = IContextMenu_QueryInterface(This->menus[index],&IID_IContextMenu2,
                                       (void**)&handler);
    if(SUCCEEDED(hres))
        return IContextMenu2_HandleMenuMsg(handler,uMsg,wParam,lParam);
    return S_OK;
}
예제 #10
0
void menucpy(HMENU hTargetMenu, HMENU hSourceMenu)
{
	int			n, id, nMn;
	TCHAR *		strBuf;
	HMENU		hSubMenu;

	nMn = GetMenuItemCount(hSourceMenu);
	strBuf = (TCHAR *)LocalAlloc(LPTR, 80);
	for (n=0; n<nMn; n++)
	{
		if (0 == (id = GetMenuItemID(hSourceMenu, n)))
			AppendMenu(hTargetMenu, MF_SEPARATOR, 0, 0L);
		else
		{
			GetMenuString(hSourceMenu, n, strBuf, 80, MF_BYPOSITION);
			if (id != -1)
				AppendMenu(hTargetMenu, GetMenuState(hSourceMenu, n, MF_BYPOSITION), id, strBuf);
			else
			{
				hSubMenu = CreatePopupMenu();
				AppendMenu(hTargetMenu, MF_POPUP | MF_STRING, (uint)hSubMenu, strBuf);
				menucpy(hSubMenu, GetSubMenu(hSourceMenu, n));
			}
		}
	}
	LocalFree((HLOCAL)strBuf);
}
예제 #11
0
파일: winmdi.cpp 프로젝트: AeonAxan/mpc-hc
HMENU CMDIFrameWnd::GetWindowMenuPopup(HMENU hMenuBar)
	// find which popup is the "Window" menu
{
	if (hMenuBar == NULL)
		return NULL;

	ASSERT(::IsMenu(hMenuBar));

	int iItem = ::GetMenuItemCount(hMenuBar);
	while (iItem--)
	{
		HMENU hMenuPop = ::GetSubMenu(hMenuBar, iItem);
		if (hMenuPop != NULL)
		{
			int iItemMax = ::GetMenuItemCount(hMenuPop);
			for (int iItemPop = 0; iItemPop < iItemMax; iItemPop++)
			{
				UINT nID = GetMenuItemID(hMenuPop, iItemPop);
				if (nID >= AFX_IDM_WINDOW_FIRST && nID <= AFX_IDM_WINDOW_LAST)
					return hMenuPop;
			}
		}
	}

	// no default menu found
	TRACE(traceAppMsg, 0, "Warning: GetWindowMenuPopup failed!\n");
	return NULL;
}
예제 #12
0
파일: wfinit.c 프로젝트: mingpen/OpenNT
VOID NEAR PASCAL BiasMenu(HMENU hMenu, INT Bias)
{
        INT pos, id, count;
        HMENU hSubMenu;
        CHAR szMenuString[80];

        ENTER("BiasMenu");

        count = GetMenuItemCount(hMenu);

        if (count < 0)
                return;

        for (pos = 0; pos < count; pos++) {

                id = GetMenuItemID(hMenu, pos);

                if (id < 0) {
                        // must be a popup, recurse and update all ID's here
                        if (hSubMenu = GetSubMenu(hMenu, pos))
                                BiasMenu(hSubMenu, Bias);
                } else if (id) {
                        // replace the item that was there with a new
                        // one with the id adjusted

                        GetMenuString(hMenu, (WORD)pos, szMenuString, sizeof(szMenuString), MF_BYPOSITION);
                        DeleteMenu(hMenu, pos, MF_BYPOSITION);
                        InsertMenu(hMenu, (WORD)pos, MF_BYPOSITION | MF_STRING, id + Bias, szMenuString);
                }
        }
        LEAVE("BiasMenu");
}
HMENU fsODMenu::CopyMenu(HMENU hMenu)
{
	HMENU hCopy = CreateMenu ();

	for (int i = 0; i < GetMenuItemCount (hMenu); i++)
	{
		UINT uState = GetMenuState (hMenu, i, MF_BYPOSITION);
		UINT nID;
		char szMenuText [100];

		if (uState & MF_POPUP)
		{
			nID = (UINT) CopyMenu (GetSubMenu (hMenu, i));
			uState = MF_POPUP | MF_STRING;
		}
		else
			nID = GetMenuItemID (hMenu, i);

		GetMenuString (hMenu, i, szMenuText, sizeof (szMenuText), MF_BYPOSITION);

		
		AppendMenu (hCopy, uState, nID, szMenuText);
	}

	return hCopy;
}
예제 #14
0
// 增加窗口弹出的代码开始
///////////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CFloatingWnd::OnInitMenuPopup(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled)
{
	int nPos;
	UINT uId;
	// Call CCoolContextMenu's implementation
	CCoolContextMenu<CFloatingWnd>::OnInitMenuPopup(uMsg, wParam, lParam, bHandled);
	// Set the cursor shape to an arrow
	m_hCursor = ::LoadCursor(NULL, IDC_ARROW);
	ATLASSERT(m_hCursor);
	::SetCursor(m_hCursor);
	CMenuHandle menuPopup = (HMENU)wParam;
	ATLASSERT(menuPopup.m_hMenu != NULL);
	for (nPos = 0; nPos < menuPopup.GetMenuItemCount(); nPos++)
	{ 
		uId = GetMenuItemID(menuPopup, nPos);
		switch (uId) 
		{ 
		case ID_EDIT_SELECT_ALL:
			EnableMenuItem(menuPopup, uId, (GetWindowTextLength() > 0) ? MF_BYCOMMAND | MF_ENABLED : MF_BYCOMMAND | MF_GRAYED);
			break;
		case ID_EDIT_CUT: 
		case ID_EDIT_COPY: 
		case ID_EDIT_PASTE: 
			EnableMenuItem(menuPopup, uId, IsClipboardFormatAvailable(CF_TEXT) ? MF_BYCOMMAND | MF_ENABLED : MF_BYCOMMAND | MF_GRAYED);
			break;
		default:
			break;
		}
	}
	return 0;
}
예제 #15
0
BOOL CRecBinViewer::ExecCommand (LPCONTEXTMENU pCtxMenu,  LPCTSTR lpszCommand)
{
	UINT uiID = UINT (-1);
	UINT uiCommand = 0;
	UINT uiMenuFirst = 1;
	UINT uiMenuLast = 0x00007FFF;
	HMENU hmenuCtx;
	int iMenuPos = 0;
	int iMenuMax = 0;
	TCHAR szMenuItem[MAX_PATH];	
	TCHAR verb[MAX_PATH] ;

	hmenuCtx = CreatePopupMenu();
	HRESULT hr = pCtxMenu->QueryContextMenu(hmenuCtx, 0, uiMenuFirst, uiMenuLast, CMF_NORMAL);

	iMenuMax = GetMenuItemCount(hmenuCtx);
	
	for (iMenuPos = 0 ; iMenuPos < iMenuMax; iMenuPos++)
	{
		GetMenuString(hmenuCtx, iMenuPos, szMenuItem, MAX_PATH, MF_BYPOSITION) ;
	
		uiID = GetMenuItemID(hmenuCtx, iMenuPos) ;
		
		if ((uiID == -1) || (uiID == 0))
		{
			
		}
		else
		{
			hr = pCtxMenu->GetCommandString(uiID - 1, GCS_VERB, NULL, (LPSTR)verb, MAX_PATH);
			if (FAILED (hr))
			{
				verb[0] = TCHAR ('\0') ;
			}
			else
			{
				if (0 == _tcsicmp (verb, lpszCommand))				
					uiCommand = uiID - 1;				
			}			
		}
	}
	
	if ((UINT)-1 != uiCommand)
	{
		CMINVOKECOMMANDINFO cmi;			
		ZeroMemory(&cmi, sizeof(CMINVOKECOMMANDINFO));
		cmi.cbSize			= sizeof(CMINVOKECOMMANDINFO);
		cmi.fMask			= CMIC_MASK_FLAG_NO_UI;
		cmi.hwnd			= m_hWnd;				
		cmi.lpVerb			= (LPSTR)MAKEINTRESOURCE (uiCommand);
		cmi.nShow			= SW_SHOWNORMAL;		
		hr = pCtxMenu->InvokeCommand(&cmi);			
		if (SUCCEEDED (hr))		
			return TRUE;		
	}

	return false;
}
예제 #16
0
static void InitMenuPopup(HMENU hMenu, LPARAM index)
{
    if ((GetMenuItemID(hMenu, 0) == CMD_DELETE) || (GetMenuItemID(hMenu, 1) == CMD_SAVE_AS))
    {
        if (CountClipboardFormats() == 0)
        {
            EnableMenuItem(hMenu, CMD_DELETE, MF_GRAYED);
            EnableMenuItem(hMenu, CMD_SAVE_AS, MF_GRAYED);
        }
        else
        {
            EnableMenuItem(hMenu, CMD_DELETE, MF_ENABLED);
            EnableMenuItem(hMenu, CMD_SAVE_AS, MF_ENABLED);
        }
    }

    DrawMenuBar(Globals.hMainWnd);
}
예제 #17
0
static void set_visible(int i) {

    visible=i; /* setup global variable */
    CheckMenuItem(hpopup, GetMenuItemID(hpopup, 1),
        visible?MF_CHECKED:MF_UNCHECKED); /* check or uncheck menu item */
    if(visible) {
        ShowWindow(hwnd, SW_SHOWNORMAL); /* show window */
        SetForegroundWindow(hwnd); /* bring on top */
    } else
        ShowWindow(hwnd, SW_HIDE); /* hide window */
}
예제 #18
0
파일: Menu.c 프로젝트: xpika/winhugs
static void hugsprim_GetMenuItemID_14(HugsStackPtr hugs_root)
{
    HsPtr arg1;
    HsWord32 arg2;
    HsWord32 res1;
    arg1 = hugs->getPtr();
    arg2 = hugs->getWord32();
    res1 = GetMenuItemID(arg1, arg2);
    hugs->putWord32(res1);
    hugs->returnIO(hugs_root,1);
}
예제 #19
0
파일: hook.cpp 프로젝트: Eun/MoveToDesktop
INT GetIndexOfItem(HMENU menu, UINT id)
{
	for (int i = GetMenuItemCount(menu) - 1; i >= 0; i--)
	{
		int x = GetMenuItemID(menu, i);
		if (id == x)
		{
			return i;
		}
	}
	return -1;
}
예제 #20
0
unsigned int Win32Popup::findInsertionPoint( unsigned int pos ) const
{
    // For this simple algorithm, we rely on the fact that in the final state
    // of the menu, the ID of each item is equal to its position in the menu
    int i = 0;
    while( i < GetMenuItemCount( m_hMenu ) &&
           GetMenuItemID( m_hMenu, i ) < pos )
    {
        i++;
    }
    return i;
}
예제 #21
0
파일: rbtray.c 프로젝트: shelt/RBXTray
BOOL CALLBACK
UpdMenu(HWND  hwnd,LPARAM lParam)
{
    int i;
    BOOL flag=lParam;
    //    int Checked;
    HMENU hSysMenu=GetSystemMenu(hwnd, FALSE);
    for(i=0;i<GetMenuItemCount(hSysMenu) && hSysMenu;i++)
        if(GetMenuItemID(hSysMenu,i)==IDM_TRAY) hSysMenu = 0;
    if (hSysMenu && lParam)
    {
        InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_SEPARATOR,IDM_SEPARATOR, NULL) ;
        if(GetWindowLong(hwnd,GWL_EXSTYLE)&WS_EX_TOPMOST)
            InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_STRING|MF_CHECKED,IDM_ONTOP,"Always on top");
        else
            InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_STRING,IDM_ONTOP,"Always on top");
        InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_STRING,IDM_TRAY,"Minimize in tray");
        InsertMenu (hSysMenu, GetMenuItemID(hSysMenu,0),MF_STRING,IDM_SIZE,"My size");
    }
    if (hSysMenu && lParam==FALSE)
    {
        DeleteMenu (hSysMenu,IDM_TRAY,MF_BYCOMMAND);
        DeleteMenu (hSysMenu,IDM_ONTOP,MF_BYCOMMAND);
        DeleteMenu (hSysMenu,IDM_SEPARATOR,MF_BYCOMMAND);
        DeleteMenu (hSysMenu,IDM_SIZE,MF_BYCOMMAND);

    }
    return TRUE;
}
	/*static*/
	int Win32MenuItem::GetNativeMenuItemPosition(NativeItemBits* bits)
	{
		int count = GetMenuItemCount(bits->parentMenu);
		for (int i = 0; i < count; i++)
		{

			if ((bits->submenu && GetSubMenu(bits->parentMenu, i) == bits->submenu) ||
				(bits->id == GetMenuItemID(bits->parentMenu, i)))
				return i;
		}

		throw ValueException::FromString("Could not find native item index in native menu.");
	}
예제 #23
0
/*--------------------------------------------------
  HMENU is start menu ?
----------------------------------------------------*/
BOOL IsStartMenu(HMENU hmenu)
{
	int i, count, id;
	
	count = GetMenuItemCount(hmenu);
	for(i = 0; i < count; i++)
	{
		id = GetMenuItemID(hmenu, i);
		// "Help" item
		if(id == 503) return TRUE;
	}
	return FALSE;
}
void InitMenu(HMENU menu,CString KeyName) 
{ 
    if ( menu==NULL || ( !::IsMenu(menu))) 
        return ; 
    CString tempname(_T(""));
	tempname=KeyName;
    CString szText; 
    int nCount,subCount, id; 
 
    nCount =GetMenuItemCount(menu);// menu->GetMenuItemCount();   //获取该层菜单数 
    for(int i=0;i<nCount;i++)                //遍历所有菜单项 
    { 
        //查看子菜单   如果有子菜单,返回0,否则返回子菜单项数目,如果是子菜单项,返回资源中的菜单COMMAND ID 
		 KeyName=_T("");
		 KeyName=tempname;
        id= GetMenuItemID(menu,i); 
             
         if (id!=-1)
         {
		   
		    szText.Format(_T("_%d"),id);
			 KeyName+=szText;
			//ModifyMenu(menu, i, MF_BYPOSITION|MF_STRING, id, gLoadString(KeyName));
         } 
		 else
		 {
		 
		  szText.Format(_T("_%d"),i);
		   KeyName+=szText;
		 // ModifyMenu(menu, i, MF_BYPOSITION|MF_STRING, i, gLoadString(KeyName));
		 }
        CString name=gLoadString(KeyName);
		if (name.CompareNoCase(_T("Not found"))!=0)
		{
		  ModifyMenu(menu, i, MF_BYPOSITION|MF_STRING, id, name);
		}
	  
		 

		 


		//ModifyMenu(menu, i, MF_BYPOSITION|MF_STRING, i, gLoadString(KeyName));
        if( id==-1 ) 
        { 
            subCount =GetMenuItemCount(GetSubMenu(menu,i)); 
            if ( subCount>0 ) 
                InitMenu(GetSubMenu(menu,i),KeyName); 
        } 
    } 
} 
예제 #25
0
void updateSoundOption()
{
	MENUITEMINFO checkInfo = {};
	checkInfo.cbSize = sizeof(MENUITEMINFO);
	checkInfo.fMask = MIIM_STATE;

	HMENU soundOptions = GetSubMenu(popupMenu, 0);
	UINT count = GetMenuItemCount(soundOptions);

	for (UINT i = 0; i < count; i++)
	{
		if (GetMenuItemID(soundOptions, i) == soundOption)
		{
			checkInfo.fState = MFS_CHECKED;
			SetMenuItemInfo(popupMenu, GetMenuItemID(soundOptions, i), 0, &checkInfo);
		}
		else
		{
			checkInfo.fState = MFS_UNCHECKED;
			SetMenuItemInfo(popupMenu, GetMenuItemID(soundOptions, i), 0, &checkInfo);
		}
	}
}
예제 #26
0
void GenerateSystemCommandMap(HWND handle) {
  HMENU systemMenu = GetSystemMenu(handle, FALSE);
  if (!systemMenu)
    return;
  for (int i = 0; i < GetMenuItemCount(systemMenu); i++) {
    UINT id = GetMenuItemID(systemMenu, i);
    MENUITEMINFO mii;
    ZeroMemory(&mii, sizeof mii);
    mii.cbSize = sizeof mii;
    mii.fMask = MIIM_ID | MIIM_STRING | MIIM_BITMAP;
    WCHAR data[MAX_PATH];
    mii.dwTypeData = data;
    mii.cch = _countof(data);

    switch (id) {
      case SC_RESTORE:
        GetMenuItemInfo(systemMenu, id, FALSE, &mii);
        menuItemInfoMap[RESTORE] = mii;
        menuItemStringMap[RESTORE] = mii.dwTypeData;
        break;
      case SC_MAXIMIZE:
        GetMenuItemInfo(systemMenu, id, FALSE, &mii);
        menuItemInfoMap[MAXIMIZE] = mii;
        menuItemStringMap[MAXIMIZE] = mii.dwTypeData;
        break;
      case SC_MINIMIZE:
        GetMenuItemInfo(systemMenu, id, FALSE, &mii);
        menuItemInfoMap[MINIMIZE] = mii;
        menuItemStringMap[MINIMIZE] = mii.dwTypeData;
        break;
      case SC_MOVE:
        GetMenuItemInfo(systemMenu, id, FALSE, &mii);
        menuItemInfoMap[MOVE] = mii;
        menuItemStringMap[MOVE] = mii.dwTypeData;
        break;
      case SC_SIZE:
        GetMenuItemInfo(systemMenu, id, FALSE, &mii);
        menuItemInfoMap[SIZE] = mii;
        menuItemStringMap[SIZE] = mii.dwTypeData;
        break;
      case SC_CLOSE:
        GetMenuItemInfo(systemMenu, id, FALSE, &mii);
        menuItemInfoMap[CLOSE] = mii;
        menuItemStringMap[CLOSE] = mii.dwTypeData;
        break;
      default:
        break;
    }
  }
}
예제 #27
0
/*
 * MenuSpellChosen:  The spell with the given command id in the spell menu was chosen.
 */
void MenuSpellChosen(int id)
{
   int len, num=0, index=0, i;
   char item_name[MAXRSCSTRING + 1];
   spell *sp;
   HMENU submenu = NULL;

   if (spell_menu == NULL)
      return;


   for (i=0; i < num_schools; i++)
   {
      submenu = submenus[i];
      if (submenu)
      {
	 num = GetMenuItemCount(submenu);

	 // Look for menu item matching command id
	 for (index = 0; index < num; index++)
	 {
	    if (GetMenuItemID(submenu, index) == (UINT) id)
	    break;
	 }
	 if (index != num)
	    break;
      }
   }

   if (index == num)
   {
      debug(("MenuSpellChosen couldn't find menu id #%d\n", id));
      return;
   }

   len = GetMenuString(submenu, index, item_name, MAXRSCSTRING, MF_BYPOSITION);
   if (len == 0)
   {
      debug(("MenuSpellChosen get spell #%d from menu\n", index));
      return;
   }
   sp = FindSpellByName(item_name);
   if (sp == SPELL_NOMATCH || sp == SPELL_AMBIGUOUS)
   {
      debug(("MenuSpellChosen couldn't find spell %s\n", item_name));
      return;
   }

   PerformAction(A_CASTSPELL, sp);
}
예제 #28
0
// this one copies the menu without deleting the root
BOOL CSkinBase::CopyMenu(const HMENU hScr, HMENU hDest)
{
	ASSERT (::IsMenu(hDest));
	
	if (!::IsMenu(hDest))
		return FALSE;
	
	ASSERT (::IsMenu(hScr));
	
	if (!::IsMenu(hScr))
		return FALSE;
	
	// delete all the existing items
	while (GetMenuItemCount(hDest))
		DeleteMenu(hDest, 0, MF_BYPOSITION);
	
	// copy across
	int nNumItems = GetMenuItemCount(hScr);
	CString sLabel;
	
	MENUITEMINFO mii;
	ZeroMemory(&mii, sizeof(mii));
	mii.cbSize = sizeof(mii); // must fill up this field
	mii.fMask = MIIM_STATE | MIIM_DATA; 			// get the state of the menu item
				
	for (int nItem = 0; nItem < nNumItems; nItem++)
	{
		UINT uIDItem = GetMenuItemID(hScr, nItem);
		GetMenuString(hScr, nItem, sLabel, MF_BYPOSITION);
		UINT uFlags = (uIDItem == 0) ? MF_SEPARATOR : (uIDItem == (UINT)-1) ? MF_POPUP : MF_STRING;
		
		// special case: if a popup menu we must copy it too
		if (uFlags == MF_POPUP)
		{
			HMENU hPopup = MakeMenuCopy(GetSubMenu(hScr, nItem));
			ASSERT (hPopup);
			
			uIDItem = (UINT)hPopup;
		}
		
		AppendMenu(hDest, uFlags, uIDItem, sLabel);
		
		// make sure we copy the state too
		::GetMenuItemInfo(hSrc, nItem, TRUE, &mii);
		::SetMenuItemInfo(hDest, nItem, TRUE, &mii);
	}
	
	return TRUE;
}
예제 #29
0
파일: gui.c 프로젝트: OPSF/uClinux
static void set_visible(int i) {
    char *txt;

    visible=i; /* setup global variable */
    CheckMenuItem(hpopup, GetMenuItemID(hpopup, 1),
        visible?MF_CHECKED:MF_UNCHECKED); /* check or uncheck menu item */
    if(visible) {
        txt=log_txt();
        SetWindowText(EditControl, txt); /* setup window content */
        free(txt);
        ShowWindow(hwnd, SW_SHOWNORMAL); /* show window */
        SetForegroundWindow(hwnd); /* bring on top */
    } else
        ShowWindow(hwnd, SW_HIDE); /* hide window */
}
예제 #30
0
static LRESULT CALLBACK winDialogMDIFrameProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
    LRESULT result;
    HWND hWndClient = NULL;
    Ihandle *ih = iupwinHandleGet(hwnd);
    if (!ih)
    {
        /* the first time WM_GETMINMAXINFO is called, Ihandle is not associated yet */
        if (msg == WM_GETMINMAXINFO && winMinMaxHandle)
        {
            if (winDialogCheckMinMaxInfo(winMinMaxHandle, (MINMAXINFO*)lp))
                return 0;
        }

        return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
    }

    {
        Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
        if (client) hWndClient = client->handle;
    }

    if (winDialogBaseProc(ih, msg, wp, lp, &result))
        return result;

    if (msg == WM_MENUCOMMAND)
    {
        int menuId = GetMenuItemID((HMENU)lp, (int)wp);
        if (menuId >= IUP_MDI_FIRSTCHILD && hWndClient)
        {
            /* we manually activate the MDI child when its menu item is selected. */
            HWND hChild = GetDlgItem(hWndClient, menuId);
            if (hChild)
                SendMessage(hWndClient, WM_MDIACTIVATE, (WPARAM)hChild, 0);
        }
        else if (menuId >= SC_SIZE && menuId <= SC_CONTEXTHELP)
        {
            /* we manually forward the message to the MDI child */
            HWND hChild = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0);
            if (hChild)
                SendMessage(hChild, WM_SYSCOMMAND, (WPARAM)menuId, 0);
        }
    }

    return DefFrameProc(hwnd, hWndClient, msg, wp, lp);
}