Beispiel #1
0
short FitToScreen(HWND hWnd, BRDATA lpBrData)
{
    HMENU hMenu;
    WORD wRes;

    hMenu = GetMenu(hWnd);
    wRes = GetMenuState(hMenu, IDM_FIT, MF_BYCOMMAND);

    /* If item currently checked, uncheck it. Otherwise check it */
    if (wRes & MF_CHECKED)
        UpdateFitMenu(hWnd, lpBrData, FALSE);
    else
        UpdateFitMenu(hWnd, lpBrData, TRUE);

    /* Fix up the scroll bars */
    if (lpBrData->bFitToScreen)
    {
        SetScrollPos(hWnd, SB_VERT, MINPOS, TRUE);
        SetScrollPos(hWnd, SB_HORZ, MINPOS, TRUE);
    }
    else
    {
        SetScrollPos(hWnd, SB_VERT, lpBrData->vThumb, TRUE);
        SetScrollPos(hWnd, SB_HORZ, lpBrData->hThumb, TRUE);
    }

    /* Cause a repaint */
    UPDATE_SCREEN(hWnd);

    return TRUE;
}
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;
}
Beispiel #3
0
/*
 * 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 */
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);
				}
			}
		}
	}
}
Beispiel #5
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);
}
Beispiel #6
0
/*
 * IEIsMenuIDValid
 */
static BOOL IEIsMenuIDValid( HMENU menu, unsigned id )
{
    UINT st;

    if( !ImgEdEnableMenuInput ) {
        return( FALSE );
    }

    if( menu == (HMENU)NULL ) {
        return( TRUE );
    }

    // put any menu identifiers that you would like forced here
    switch( id ) {
    case IMGED_CLOSEALL:
        if( ImgedIsDDE ) {
            return( TRUE );
        }
        break;
    }

    st = GetMenuState( menu, id, MF_BYCOMMAND );

    if( st == -1 || (st & MF_GRAYED) == MF_GRAYED ) {
        return( FALSE );
    }

    return( TRUE );

} /* IEIsMenuIDValid */
Beispiel #7
0
LRESULT
DefWndNCLButtonDblClk(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
  ULONG Style;

  Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
  switch(wParam)
  {
    case HTCAPTION:
    {
      /* Maximize/Restore the window */
      if((Style & WS_CAPTION) == WS_CAPTION && (Style & WS_MAXIMIZEBOX))
      {
        SendMessageW(hWnd, WM_SYSCOMMAND, ((Style & (WS_MINIMIZE | WS_MAXIMIZE)) ? SC_RESTORE : SC_MAXIMIZE), 0);
      }
      break;
    }
    case HTSYSMENU:
    {
      HMENU hSysMenu = GetSystemMenu(hWnd, FALSE);
      UINT state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
                  
      /* If the close item of the sysmenu is disabled or not present do nothing */
      if ((state & (MF_DISABLED | MF_GRAYED)) || (state == 0xFFFFFFFF))
          break;

      SendMessageW(hWnd, WM_SYSCOMMAND, SC_CLOSE, lParam);
      break;
    }
    default:
      return DefWndNCLButtonDown(hWnd, wParam, lParam);
  }
  return(0);
}
Beispiel #8
0
void TaskManager_OnOptionsShow16BitTasks(void)
{
    HMENU    hMenu;
    HMENU    hOptionsMenu;

    hMenu = GetMenu(hMainWnd);
    hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);

    /*
     * FIXME: Currently this is useless because the
     * current implementation doesn't list the 16-bit
     * processes. I believe that would require querying
     * each ntvdm.exe process for it's children.
     */

    /*
     * Check or uncheck the show 16-bit tasks menu item
     */
    if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED)
    {
        CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
        TaskManagerSettings.Show16BitTasks = FALSE;
    }
    else
    {
        CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
        TaskManagerSettings.Show16BitTasks = TRUE;
    }

    /*
     * Refresh the list of processes.
     */
    RefreshProcessPage();
}
Beispiel #9
0
static char* winItemGetValueAttrib(Ihandle* ih)
{
  if (GetMenuState((HMENU)ih->handle, (UINT)ih->serial, MF_BYCOMMAND) & MF_CHECKED)
    return "ON";
  else
    return "OFF";
}
Beispiel #10
0
static char* winItemGetActiveAttrib(Ihandle* ih)
{
  if (ih->handle == (InativeHandle*)-1) /* check if submenu is actually created */
    return NULL;

  return iupStrReturnBoolean(!(GetMenuState((HMENU)ih->handle, (UINT)ih->serial, MF_BYCOMMAND) & MF_GRAYED));
}
Beispiel #11
0
static char* winItemGetActiveAttrib(Ihandle* ih)
{
  /* check if the submenu handle was created in winSubmenuAddToParent */
  if (ih->handle == (InativeHandle*)-1)
    return NULL;

  return iupStrReturnBoolean(!(GetMenuState((HMENU)ih->handle, (UINT)ih->serial, MF_BYCOMMAND) & MF_GRAYED));
}
Beispiel #12
0
void Accelerator::updateMenuItemByCommand(CommandShortcut csc) {
	int cmdID = (int)csc.getID();
	
	//  Ensure that the menu item checks set prior to this update remain in affect.
	UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND );
	cmdFlags = MF_BYCOMMAND | (cmdFlags&MF_CHECKED) ? ( MF_CHECKED ) : ( MF_UNCHECKED );
	::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, csc.toMenuItemString().c_str());
}
Beispiel #13
0
bool IsMenuNonEmpty(HMENU menu) {
	unsigned n,m=GetMenuItemCount(menu);
	for(n=0;n<m;n++) {
		if (GetSubMenu(menu,n)) return true;
		if (!(GetMenuState(menu,n,MF_BYPOSITION)&MF_SEPARATOR)) return true;
	}
	return false;
}
Beispiel #14
0
void menu_check_autorun()
{
	UINT state = GetMenuState(menu_tray, IDM_AUTORUN, MF_BYCOMMAND);
	bool to_check = !(state & MF_CHECKED); // revert

	menu_check(IDM_AUTORUN, to_check);

	if (to_check) { autorun_enable(); }
	else { autorun_cancel(); }
}
Beispiel #15
0
static char* winItemGetActiveAttrib(Ihandle* ih)
{
  if (ih->handle == (InativeHandle*)-1) /* check if submenu is actually created */
    return NULL;

  if (GetMenuState((HMENU)ih->handle, (UINT)ih->serial, MF_BYCOMMAND) & MF_GRAYED)
    return "NO";
  else
    return "YES";
}
Beispiel #16
0
void Menuer::checkAutorunMenu()
{
    UINT state = GetMenuState(trayMenu_, IDM_AUTORUN, MF_BYCOMMAND);
    bool toCheck = !(state & MF_CHECKED); // revert

    checkMenu(IDM_AUTORUN, toCheck);

    if (toCheck) { autorun_enable(); }
    else { autorun_cancel(); }
}
Beispiel #17
0
int get_menu(HMENU hMenu, int ctrlID)
{
	if (GetMenuState(hMenu,ctrlID,MF_BYCOMMAND)&MF_CHECKED) {
		CheckMenuItem(hMenu,ctrlID,MF_UNCHECKED|MF_BYCOMMAND);
		return 0;
	}
	else {
		CheckMenuItem(hMenu,ctrlID,MF_CHECKED|MF_BYCOMMAND);
		return 1;
	}
}
Beispiel #18
0
BOOL GetLyricStatus()
{
	HMENU menu = GetMenu(main_wnd.hWnd);
	if (menu != NULL)
	{
		if (GetMenuState(menu, IDM_MENU_LYRIC_STATUS, MF_BYCOMMAND | MF_CHECKED) > 0)
			return TRUE;
	}

	return FALSE;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, 
    WPARAM wParam, LPARAM lParam) {
    
    UINT state;

    switch(msg) {
    
      case WM_CREATE:
      
          AddMenus(hwnd);          
          InitCommonControls();

          ghSb = CreateWindowExW(0, STATUSCLASSNAMEW, NULL, 
              WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd, 
              (HMENU) 1, GetModuleHandle(NULL), NULL);

          break;

      case WM_COMMAND:
          
          switch(LOWORD(wParam)) {
          
              case IDM_VIEW_STB:                                    
                  
                  state = GetMenuState(ghMenu, IDM_VIEW_STB, MF_BYCOMMAND); 

                  if (state == MF_CHECKED) {
                  
                      ShowWindow(ghSb, SW_HIDE);
                      CheckMenuItem(ghMenu, IDM_VIEW_STB, MF_UNCHECKED);  
                  } else {
                  
                      ShowWindow(ghSb, SW_SHOWNA);
                      CheckMenuItem(ghMenu, IDM_VIEW_STB, MF_CHECKED);  
                  }
                  
                  break;
          }
          
          break;

      case WM_SIZE:
      
          SendMessage(ghSb, WM_SIZE, wParam, lParam);          
          break;

      case WM_DESTROY:
      
          PostQuitMessage(0);
          break;
    }

    return DefWindowProcW(hwnd, msg, wParam, lParam);
}
Beispiel #20
0
static void hugsprim_GetMenuState_10(HugsStackPtr hugs_root)
{
    HsPtr arg1;
    HsWord32 arg2;
    HsWord32 arg3;
    HsWord32 res1;
    arg1 = hugs->getPtr();
    arg2 = hugs->getWord32();
    arg3 = hugs->getWord32();
    res1 = GetMenuState(arg1, arg2, arg3);
    hugs->putWord32(res1);
    hugs->returnIO(hugs_root,1);
}
Beispiel #21
0
wyBool
EditorBase::ShowResultWindow()
{
	wyInt32	      lstyle;
	wyUInt32	  menustate;
	wyUInt32	  ret;
	HMENU	      hmenu, hsubmenu;

	TabMgmt				*ptabmgmt;	
	TabEditorSplitter	*ptesplitter;
	MDIWindow	*	pCQueryWnd =(MDIWindow*)GetActiveWin();

	if (pCQueryWnd->GetActiveTabEditor()->m_isresultwnd)
		return wyTrue;

	VERIFY(hmenu = GetMenu(pGlobals->m_pcmainwin->m_hwndmain));

	lstyle = GetWindowLongPtr(pCQueryWnd->m_hwnd, GWL_STYLE);

	if ((lstyle & WS_MAXIMIZE) && wyTheme::IsSysmenuEnabled(pCQueryWnd->m_hwnd))
		VERIFY(hsubmenu = GetSubMenu(hmenu, 2));
	else
		VERIFY(hsubmenu = GetSubMenu(hmenu, 1));

	menustate = GetMenuState(hsubmenu, IDC_EDIT_SHOWRESULT, MF_BYCOMMAND);

	ret = CheckMenuItem(hsubmenu, IDC_EDIT_SHOWRESULT, MF_BYCOMMAND | MF_UNCHECKED);
	pCQueryWnd->GetActiveTabEditor()->m_isresultwnd = wyTrue;

	ptesplitter = pCQueryWnd->GetActiveTabEditor()->m_pcetsplitter;
	
	if(ptesplitter->m_leftortoppercent == ptesplitter->m_lasttoppercent && 
           ptesplitter->m_leftortoppercent == 100 && 
           ptesplitter->m_lasttoppercent == 100)
        {
            ptesplitter->m_lasttoppercent = 50;
            ptesplitter->m_leftortoppercent = ptesplitter->m_lasttoppercent;
        }
		else
            ptesplitter->m_leftortoppercent = ptesplitter->m_lasttoppercent;
		
	pCQueryWnd->m_pctabmodule->Resize();

	ptabmgmt = pCQueryWnd->GetActiveTabEditor()->m_pctabmgmt;

	VERIFY(UpdateWindow(ptabmgmt->m_hwnd));
	//VERIFY(UpdateWindow(ptabmgmt->m_pcdataviewquery->m_hwndgrid));

    return wyTrue;
}
Beispiel #22
0
/*-----------------------------------------------------------------------------*/
BOOL OpenToolBox(HWND hWnd) {
	HMENU hMenu;

	hMenu = GetMenu(ghWndMain);

	// Make sure the window isn't already open
	if (!GetWindow(ghWndToolBox,GW_HWNDFIRST)) {
		ghWndToolBox = CreateDialog(ghInst, MAKEINTRESOURCE(IDD_DLG_TOOLBOX), ghWndCanvas, (DLGPROC)ToolBoxDlg);
		ShowWindow(ghWndToolBox, SW_SHOW);

		CheckMenuItem(hMenu, ID_FORMAT_TOOLBOX, MF_CHECKED);

		// Make sure the correct radio button is checked
		if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) {
			Button_SetCheck(GetDlgItem(ghWndToolBox, IDC_RAD_LINE), TRUE);
		}
		else if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) {
			Button_SetCheck(GetDlgItem(ghWndToolBox, IDC_RAD_RECTANGLE), TRUE);
		}
		else if (GetMenuState(hMenu, ID_TOOLS_POLYGON, MF_BYCOMMAND) == MF_CHECKED) {
			Button_SetCheck(GetDlgItem(ghWndToolBox, IDC_RAD_POLYGON), TRUE);
		}
		else if (GetMenuState(hMenu, ID_TOOLS_SELECT, MF_BYCOMMAND) == MF_CHECKED) {
			Button_SetCheck(GetDlgItem(ghWndToolBox, IDC_RAD_SELECT), TRUE);
		}
	}
	else {
		// Close the window if it was already open
		DestroyWindow(ghWndToolBox);

		CheckMenuItem(hMenu, ID_FORMAT_TOOLBOX, MF_UNCHECKED);
	}



	return TRUE;
}
Beispiel #23
0
BOOL CMainFrame::OnCommand(WPARAM wParam_, LPARAM lParam_) 
{
	// TODO: Add your specialized code here and/or call the base class
	UINT _uCmd = LOWORD(wParam_);
	if ((_uCmd >= IDM_View_Default) && (_uCmd <= IDM_View_Default + 49))
	{
		// 改变语言
		if (((MF_CHECKED & GetMenuState(this->GetMenu()->m_hMenu, _uCmd, MF_BYCOMMAND)) != MF_CHECKED))
		{
			OnViewLanguage(_uCmd);
		}
		return 0;
	}

	return CFrameWnd::OnCommand(wParam_, lParam_);
}
Beispiel #24
0
BOOL	onTopMostMenuCommand(HWND hWnd)
{
	HMENU hMenu = GetSystemMenu(hWnd, FALSE);

	UINT uState = GetMenuState( hMenu, IDM_TOPMOST, MF_BYCOMMAND);
	DWORD dwExStyle = GetWindowLong(hWnd,GWL_EXSTYLE);
	if( uState & MFS_CHECKED )
	{
		SetWindowPos(hWnd, HWND_NOTOPMOST,NULL,NULL,NULL,NULL,SWP_NOMOVE | SWP_NOSIZE); 
	}else{
		SetWindowPos(hWnd, HWND_TOPMOST,NULL,NULL,NULL,NULL,SWP_NOMOVE | SWP_NOSIZE); 
	}

	changeStateTopMostMenu(hWnd, hMenu);

	return(TRUE);
}
void CElcSkinFrameBase::InitButtons()
{
	m_arrButton.clear();

	LONG style = ::GetWindowLong(m_hDerive, GWL_STYLE);
	if ((style & WS_SYSMENU) == 0 || _tcslen(m_skin.szStyle) <= 0)
		return;

	HMENU hMenu = ::GetSystemMenu(m_hDerive, 0);
	if (!::IsMenu(hMenu))
		return;
	BOOL bCloseEnable = TRUE;
	UINT nCloseItemState = GetMenuState(hMenu, SC_CLOSE, MF_BYCOMMAND);
	if ((nCloseItemState & MF_GRAYED) != 0
		|| nCloseItemState == 0xFFFFFFFF)
		bCloseEnable = FALSE;

	ELC_SKINFRAME_NWBUTTON item;

	if ((style & WS_MINIMIZEBOX) == 0
		&& (style & WS_MAXIMIZEBOX) == 0) 
	{
		item.type = ESNWT_CLOSE;
		item.pButton = &m_skin.singleclose;
		item.bEnable = bCloseEnable;
		m_arrButton.push_back(item);
	}
	else {
		item.type = ESNWT_MINIMIZE;
		item.pButton = &m_skin.minimize;
		item.bEnable = (style & WS_MINIMIZEBOX) != 0;
		m_arrButton.push_back(item);

		item.type = ESNWT_MAXIMIZE;
		item.pButton = &m_skin.maximize;
		item.bEnable = (style & WS_MAXIMIZEBOX) != 0;
		m_arrButton.push_back(item);

		item.type = ESNWT_CLOSE;
		item.pButton = &m_skin.close;
		item.bEnable = bCloseEnable;
		m_arrButton.push_back(item);
	}
}
Beispiel #26
0
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
		case WM_CONTEXTMENU:
			TrackPopupMenu(GetSubMenu(GetMenu(hwnd),0),TPM_LEFTALIGN,GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam),0,hwnd,NULL);
		break;
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case ID_EXIT:
					DestroyWindow(hwnd);
				break;
				case 11:
				case 12:
				case 13:
				case 14:
				case 15:
				case 16:
				case 17:
				case 18:
				case 19:
				case 20:
					if (GetMenuState(GetMenu(hwnd), LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED)
						CheckMenuItem(GetMenu(hwnd), LOWORD(wParam), MF_BYCOMMAND | MF_UNCHECKED);
					else
						CheckMenuItem(GetMenu(hwnd),LOWORD(wParam),MF_BYCOMMAND|MF_CHECKED);
				break;
			}
		break;
		case WM_DESTROY:
			WritePrivateProfileInt("window","height",height,configfile);
			WritePrivateProfileInt("window","width",width,configfile);
			PostQuitMessage(0);
		break;
		case WM_SIZE:
			width = LOWORD(lParam);
			height = HIWORD(lParam);
		break;
		default:
			return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}
    void HandleToggleCheckBoxCommand(WORD wParam)
    {
        if(m_CheckMenuItemLookup.ContainsKey(wParam))
        {
            UINT state = GetMenuState(m_CheckMenuItemLookup[wParam], wParam, MF_BYCOMMAND);
            if (state != -1)
            {
                if(state & MFS_CHECKED)
                {
                    state &= ~MFS_CHECKED;
                }
                else
                {
                    state |= MFS_CHECKED;
                }

                CheckMenuItem(m_CheckMenuItemLookup[wParam], wParam, state);
            }
        }
    }
Beispiel #28
0
static void winItemCheckToggle(Ihandle* ih)
{
  if (iupAttribGetBoolean(ih->parent, "RADIO"))
  {
    int last_pos, pos;
    winMenuGetLastPos(ih, &last_pos, &pos);
    CheckMenuRadioItem((HMENU)ih->handle, 0, last_pos, pos, MF_BYPOSITION);

    winMenuUpdateBar(ih);
  }
  else if (iupAttribGetBoolean(ih, "AUTOTOGGLE"))
  {
    if (GetMenuState((HMENU)ih->handle, (UINT)ih->serial, MF_BYCOMMAND) & MF_CHECKED)
      CheckMenuItem((HMENU)ih->handle, (UINT)ih->serial, MF_UNCHECKED|MF_BYCOMMAND);
    else
      CheckMenuItem((HMENU)ih->handle, (UINT)ih->serial, MF_CHECKED|MF_BYCOMMAND);

    winMenuUpdateBar(ih);
  }
}
//
/// Extracts the group counts from the loaded menu bar by counting the number of
/// menus between separator items. After the group counts are extracted, the
/// separators are removed.
//
bool
TMenuDescr::ExtractGroups()
{
  if (!Handle)
    return false;  // no menu to extract from...

  // walk menu & remove separators, setting up count as we go.
  //
  int itemCount = GetMenuItemCount();
  int g = 0;
  int count = 0;
  for (int i = 0; i < itemCount; ) {
    uint s = GetMenuState(i, MF_BYPOSITION);
    if ((s & MF_SEPARATOR) && !(s & MF_POPUP)) {
      if (g < NumGroups)
        GroupCount[g++] = count;
      count = 0;
      RemoveMenu(i, MF_BYPOSITION);
      itemCount--;
    }
    else {
      i++;
      count++;
    }
  }
  // Leave if no separators were found
  //
  if (!g)
    return false;

  // Get trailing group
  //
  if (g < NumGroups)
    GroupCount[g++] = count;

  // Finish zeroing groups
  //
  for (; g < NumGroups; g++)
    GroupCount[g] = 0;
  return true;
}
Beispiel #30
0
BOOL WINAPI
ShowHideMenuCtl (HWND hwnd, UINT_PTR uFlags, LPINT lpInfo)
{
    LPINT lpMenuId;

    TRACE("%p, %lx, %p\n", hwnd, uFlags, lpInfo);

    if (lpInfo == NULL)
	return FALSE;

    if (!(lpInfo[0]) || !(lpInfo[1]))
	return FALSE;

    /* search for control */
    lpMenuId = &lpInfo[2];
    while (*lpMenuId != uFlags)
	lpMenuId += 2;

    if (GetMenuState ((HMENU)(DWORD_PTR)lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
	/* uncheck menu item */
	CheckMenuItem ((HMENU)(DWORD_PTR)lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);

	/* hide control */
	lpMenuId++;
	SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
			SWP_HIDEWINDOW);
    }
    else {
	/* check menu item */
	CheckMenuItem ((HMENU)(DWORD_PTR)lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);

	/* show control */
	lpMenuId++;
	SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
			SWP_SHOWWINDOW);
    }

    return TRUE;
}