예제 #1
0
BOOL DisplayTimebaseMenu(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
    RECT rect;

    // Get the coordinates of the button

    SendMessage(((LPNMHDR)lParam)->hwndFrom, TB_GETRECT,
    		(WPARAM)((LPNMTOOLBAR)lParam)->iItem, (LPARAM)&rect);

    // Convert to screen coordinates

    MapWindowPoints(((LPNMHDR)lParam)->hwndFrom,
    		    HWND_DESKTOP, (LPPOINT)&rect, 2);

    HMENU menu = CreatePopupMenu();

    MENUINFO info =
	{sizeof(MENUINFO),
	 MIM_STYLE,
	 MNS_NOTIFYBYPOS};

    SetMenuInfo(menu, &info);

    for (int i = 0; i < Length(timebase.strings); i++)
    	AppendMenu(menu, (i == timebase.index)? MF_STRING | MF_CHECKED:
		   MF_STRING, i, timebase.strings[i]);

    TrackPopupMenu(menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON,
		   rect.left, rect.bottom,
		   0, hWnd, NULL);
}
예제 #2
0
/*************************************************************************
 * FileMenu_Create				[SHELL32.114]
 *
 * NOTES
 *  for non-root menus values are
 *  (ffffffff,00000000,00000000,00000000,00000000)
 */
HMENU WINAPI FileMenu_Create (
	COLORREF crBorderColor,
	int nBorderWidth,
	HBITMAP hBorderBmp,
	int nSelHeight,
	UINT uFlags)
{
	MENUINFO	MenuInfo;
	LPFMINFO	menudata;

	HMENU hMenu = CreatePopupMenu();

	TRACE("0x%08x 0x%08x %p 0x%08x 0x%08x  hMenu=%p\n",
	crBorderColor, nBorderWidth, hBorderBmp, nSelHeight, uFlags, hMenu);

	menudata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO));
	menudata->crBorderColor = crBorderColor;
	menudata->nBorderWidth = nBorderWidth;
	menudata->hBorderBmp = hBorderBmp;

	MenuInfo.cbSize = sizeof(MENUINFO);
	MenuInfo.fMask = MIM_MENUDATA;
	MenuInfo.dwMenuData = (ULONG_PTR) menudata;
	SetMenuInfo (hMenu, &MenuInfo);

	return hMenu;
}
예제 #3
0
HMENU MainWindow::createMenu()
{
	HMENU menu = GetSubMenu(LoadMenu(nullptr, MAKEINTRESOURCE(IDR_MENU)), 0);
	auto items = settings::settings()[L"menu"];
	size_t count = 0;
	Table* table = nullptr;
	for (auto t : m_tables)
	{
		if (t->isVisible())
		{
			table = t;
			break;
		}
	}
	m_menuItems.clear();
	for (auto item : items)
	{
		auto name = item[L"name"].asString();
		auto path = item[L"path"].asString();
		auto args = item[L"args"].asString();
		auto verb = item[L"verb"].asString();
		auto hidden = item[L"hidden"].asNumber() != 0;
		if (table)
		{
			name = table->expandString(name);
			path = table->expandString(path);
			args = table->expandString(args);
		}
		findFiles(name, L"MenuItem", path, false, [&](const std::wstring& name, const std::wstring& path) {
			MenuItem menuItem = { path, args, verb, hidden };
			m_menuItems.push_back(menuItem);
			MENUITEMINFO item = { 0 };
			item.cbSize = sizeof(item);
			item.fMask = MIIM_STRING | MIIM_ID | MIIM_DATA;
			item.fType = MFT_STRING;
			item.wID = ID_USER_MENU;
			item.dwItemData = DWORD(m_menuItems.size() - 1);
			item.dwTypeData = const_cast<LPWSTR>(name.c_str());
			item.cch = path.length();
			InsertMenuItem(menu, count++, TRUE, &item);
		});
	}
	if (count)
	{
		MENUITEMINFO item = { 0 };
		item.cbSize = sizeof(item);
		item.fMask = MIIM_FTYPE;
		item.fType = MFT_SEPARATOR;
		InsertMenuItem(menu, count, TRUE, &item);
	}

	MENUINFO mi;
	memset(&mi, 0, sizeof(mi));
	mi.cbSize = sizeof(mi);
	mi.fMask = MIM_STYLE;
	mi.dwStyle = MNS_NOTIFYBYPOS;
	SetMenuInfo(menu, &mi);

	return menu;
}
예제 #4
0
/**
 * Converts an EMENU to a Windows menu object.
 *
 * \param Menu The menu item to convert.
 * \param Flags A combination of the following:
 * \li \c PH_EMENU_CONVERT_ID Automatically assigns a unique identifier to each converted menu item.
 * The resulting mappings are placed in \a Data.
 * \param Data Additional data resulting from the conversion. The data structure must be initialized
 * by PhInitializeEMenuData() prior to calling this function.
 *
 * \return A menu handle. The menu object must be destroyed using DestroyMenu() when it is no longer
 * needed.
 */
HMENU PhEMenuToHMenu(
    _In_ PPH_EMENU_ITEM Menu,
    _In_ ULONG Flags,
    _Inout_opt_ PPH_EMENU_DATA Data
    )
{
    HMENU menuHandle;

    menuHandle = CreatePopupMenu();

    if (!menuHandle)
        return NULL;

    PhEMenuToHMenu2(menuHandle, Menu, Flags, Data);

    if (!(Menu->Flags & PH_EMENU_SEPARATECHECKSPACE))
    {
        MENUINFO menuInfo;

        memset(&menuInfo, 0, sizeof(MENUINFO));
        menuInfo.cbSize = sizeof(MENUINFO);
        menuInfo.fMask = MIM_STYLE;
        menuInfo.dwStyle = MNS_CHECKORBMP;
        SetMenuInfo(menuHandle, &menuInfo);
    }

    return menuHandle;
}
예제 #5
0
	BOOL Show(HINSTANCE hInstance, int nCmdShow)
	{
		hInst = hInstance; // Store instance handle in our global variable

		int zoom = g_Config.iWindowZoom;
		if (zoom < 1) zoom = 1;
		if (zoom > 4) zoom = 4;
		
		RECT rc, rcOrig;
		GetWindowRectAtZoom(zoom, rcOrig, rc);

		u32 style = WS_OVERLAPPEDWINDOW;

		hwndMain = CreateWindowEx(0,szWindowClass, "", style,
			rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
		if (!hwndMain)
			return FALSE;

		hwndDisplay = CreateWindowEx(0, szDisplayClass, TEXT(""), WS_CHILD | WS_VISIBLE,
			rcOrig.left, rcOrig.top, rcOrig.right - rcOrig.left, rcOrig.bottom - rcOrig.top, hwndMain, 0, hInstance, 0);
		if (!hwndDisplay)
			return FALSE;

		menu = GetMenu(hwndMain);
#ifdef FINAL
		RemoveMenu(menu,2,MF_BYPOSITION);
		RemoveMenu(menu,2,MF_BYPOSITION);
#endif
		MENUINFO info;
		ZeroMemory(&info,sizeof(MENUINFO));
		info.cbSize = sizeof(MENUINFO);
		info.cyMax = 0;
		info.dwStyle = MNS_CHECKORBMP;
		info.fMask = MIM_STYLE;
		for (int i = 0; i < GetMenuItemCount(menu); i++)
		{
			SetMenuInfo(GetSubMenu(menu,i),&info);
		}
		UpdateMenus();

		//accept dragged files
		DragAcceptFiles(hwndMain, TRUE);

		hideCursor = true;
		SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0);

		Update();
		SetPlaying(0);
		
		ShowWindow(hwndMain, nCmdShow);

#if ENABLE_TOUCH
		RegisterTouchWindow(hwndDisplay, TWF_WANTPALM);
#endif

		SetFocus(hwndDisplay);

		return TRUE;
	}
예제 #6
0
BOOL createMenu() {
    hTrayMenu = CreatePopupMenu();
    MENUINFO menuInfo;
    menuInfo.cbSize = sizeof(MENUINFO);
    menuInfo.fMask = MIM_APPLYTOSUBMENUS | MIM_STYLE;
    menuInfo.dwStyle = MNS_NOTIFYBYPOS;
    return SetMenuInfo(hTrayMenu, &menuInfo);
}
예제 #7
0
파일: iupwin_menu.c 프로젝트: Archs/iup-aio
static int winMenuMapMethod(Ihandle* ih)
{
  MENUINFO menuinfo;

  if (iupMenuIsMenuBar(ih))
  {
    /* top level menu used for MENU attribute in IupDialog (a menu bar) */

    ih->handle = (InativeHandle*)CreateMenu();
    if (!ih->handle)
      return IUP_ERROR;

    SetMenu(ih->parent->handle, (HMENU)ih->handle);
  }
  else
  {
    if (ih->parent)
    {
      /* parent is a submenu, it is created here */

      ih->handle = (InativeHandle*)CreatePopupMenu();
      if (!ih->handle)
        return IUP_ERROR;

      if (winMenuAddParentSubmenu(ih->parent) == IUP_ERROR)
      {
        DestroyMenu((HMENU)ih->handle);
        return IUP_ERROR;
      }
    }
    else  
    {
      /* top level menu used for IupPopup */

      ih->handle = (InativeHandle*)CreatePopupMenu();
      if (!ih->handle)
        return IUP_ERROR;

      iupAttribSetStr(ih, "_IUPWIN_POPUP_MENU", "1");
    }
  }

  menuinfo.cbSize = sizeof(MENUINFO);
  menuinfo.fMask = MIM_MENUDATA;
  menuinfo.dwMenuData = (ULONG_PTR)ih;

  if (!iupAttribGetInherit(ih, "_IUPWIN_POPUP_MENU"))   /* check in the top level menu using inheritance */
  {
    menuinfo.fMask |= MIM_STYLE;
    menuinfo.dwStyle = MNS_NOTIFYBYPOS;
  }

  SetMenuInfo((HMENU)ih->handle, &menuinfo);

  winMenuUpdateBar(ih);

  return IUP_NOERROR;
}
예제 #8
0
void ShellExt::tweakMenu(HMENU menu)
{
    MENUINFO MenuInfo;
    MenuInfo.cbSize  = sizeof(MenuInfo);
    MenuInfo.fMask   = MIM_STYLE | MIM_APPLYTOSUBMENUS;
    MenuInfo.dwStyle = MNS_CHECKORBMP;

    SetMenuInfo(menu, &MenuInfo);
}
예제 #9
0
	BOOL Show(HINSTANCE hInstance) {
		hInst = hInstance; // Store instance handle in our global variable.
		RECT rc = DetermineWindowRectangle();
		SavePosition();

		u32 style = WS_OVERLAPPEDWINDOW;

		hwndMain = CreateWindowEx(0,szWindowClass, L"", style,
			rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
		if (!hwndMain)
			return FALSE;

		SetWindowLong(hwndMain, GWL_EXSTYLE, WS_EX_APPWINDOW);

		RECT rcClient;
		GetClientRect(hwndMain, &rcClient);

		hwndDisplay = CreateWindowEx(0, szDisplayClass, L"", WS_CHILD | WS_VISIBLE,
			0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hwndMain, 0, hInstance, 0);
		if (!hwndDisplay)
			return FALSE;

		menu = GetMenu(hwndMain);

		MENUINFO info;
		ZeroMemory(&info,sizeof(MENUINFO));
		info.cbSize = sizeof(MENUINFO);
		info.cyMax = 0;
		info.dwStyle = MNS_CHECKORBMP;
		info.fMask = MIM_STYLE;
		for (int i = 0; i < GetMenuItemCount(menu); i++) {
			SetMenuInfo(GetSubMenu(menu,i), &info);
		}

		// Always translate first: translating resets the menu.
		TranslateMenus(hwndMain, menu);
		UpdateMenus();

		// Accept dragged files.
		DragAcceptFiles(hwndMain, TRUE);

		hideCursor = true;
		SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0);

		ToggleFullscreen(hwndMain, g_Config.bFullScreen);

		W32Util::MakeTopMost(hwndMain, g_Config.bTopMost);

		touchHandler.registerTouchWindow(hwndDisplay);

		WindowsRawInput::Init();

		SetFocus(hwndMain);

		return TRUE;
	}
예제 #10
0
void RemoveCheckmarkSpace(HMENU HMENU)
{
	if (!bIsVistaPlus)
		return;

	MENUINFO mi;
	mi.cbSize = sizeof(mi);
	mi.fMask = MIM_STYLE;
	mi.dwStyle = MNS_CHECKORBMP;
	SetMenuInfo(HMENU, &mi);
}
예제 #11
0
void PopupMenu::createPlatformMenu()
{
   mData->mMenu = mIsPopup ? CreatePopupMenu() : CreateMenu();
   AssertFatal(mData->mMenu, "Unable to create menu");

   MENUINFO mi;
   mi.cbSize = sizeof(mi);
   mi.fMask = MIM_MENUDATA;
   mi.dwMenuData = (ULONG_PTR)this;
   SetMenuInfo(mData->mMenu, &mi);
}
예제 #12
0
BOOL CIconMenu::SetMenuStyle(void)
{
	MENUINFO MenuInfo = { 0 };

	MenuInfo.cbSize  = sizeof(MenuInfo);
	MenuInfo.fMask   = MIM_STYLE | MIM_APPLYTOSUBMENUS;
	MenuInfo.dwStyle = MNS_CHECKORBMP;

	SetMenuInfo(&MenuInfo);

	return TRUE;
}
예제 #13
0
/*static*/
void MenuWin::ApplyNotifyByPositionStyleToNativeMenu(HMENU nativeMenu)
{
    MENUINFO menuInfo;
    ZeroMemory(&menuInfo, sizeof(MENUINFO)); 
    menuInfo.cbSize = sizeof(MENUINFO);
    menuInfo.fMask = MIM_APPLYTOSUBMENUS | MIM_STYLE;
    menuInfo.dwStyle = MNS_CHECKORBMP | MNS_NOTIFYBYPOS; 
    BOOL success = SetMenuInfo(nativeMenu, &menuInfo);

    if (!success) {
        string error = Win32Utils::QuickFormatMessage(GetLastError());
        throw ValueException::FromString("Could not set native menu style: " + error);
    }
}
예제 #14
0
파일: iupwin_menu.c 프로젝트: Archs/iup-aio
static int winMenuSetBgColorAttrib(Ihandle* ih, const char* value)
{
  unsigned char r, g, b;
  /* must use IupGetAttribute to use inheritance */
  if (iupStrToRGB(value, &r, &g, &b))
  {
    MENUINFO menuinfo;
    menuinfo.cbSize = sizeof(MENUINFO);
    menuinfo.fMask = MIM_BACKGROUND;
    menuinfo.hbrBack = iupwinBrushGet(RGB(r,g,b)); 
    SetMenuInfo((HMENU)ih->handle, &menuinfo);
    winMenuUpdateBar(ih);
  }
  return 1;
}
예제 #15
0
BOOL CIconMenu::SetMenuStyle(void)
{
	if (!SysInfo::Instance().IsVistaOrLater())
		return FALSE;

	MENUINFO MenuInfo;

	memset(&MenuInfo, 0, sizeof(MenuInfo));

	MenuInfo.cbSize  = sizeof(MenuInfo);
	MenuInfo.fMask   = MIM_STYLE | MIM_APPLYTOSUBMENUS;
	MenuInfo.dwStyle = MNS_CHECKORBMP;

	SetMenuInfo(&MenuInfo);

	return TRUE;
}
예제 #16
0
파일: utils.cpp 프로젝트: plerup/LaunchBar
void InitPopupMenu(HMENU hMenu, BOOL useMenuCom)
{
   // Force update of a popup menu not connected to any window
   HMENU dummy = CreateMenu();
   AppendMenu(dummy, MF_POPUP, (UINT)hMenu, EMPTY_STR);
   RemoveMenu(dummy, 0, MF_BYPOSITION);
   DestroyMenu(dummy);

   if (useMenuCom)
   {
      // Setup to get WM_MENUCOMMAND instead of WM_COMMAND
      MENUINFO menuInf;
      ZeroMemory(&menuInf, sizeof(menuInf));
      menuInf.cbSize = sizeof(menuInf);
      menuInf.fMask = MIM_STYLE | MIM_APPLYTOSUBMENUS;
      menuInf.dwStyle = MNS_NOTIFYBYPOS;
      SetMenuInfo(hMenu, &menuInf);
   }
}
예제 #17
0
파일: xmenubar.cpp 프로젝트: dlsocool/dcx
/*
 * Sets the menubar into the mIRC window, and automatically destroys the old menubar
 * if it isnt the original mIRC menubar.
 */
void XMenuBar::setMenuBar(HMENU oldMenuBar, HMENU newMenuBar) {
	if (newMenuBar != g_OriginalMenuBar) {
		MENUINFO mi;

		ZeroMemory(&mi, sizeof(MENUINFO));
		mi.cbSize = sizeof(MENUINFO);
		mi.fMask = MIM_BACKGROUND | MIM_HELPID | MIM_MAXHEIGHT | MIM_MENUDATA | MIM_STYLE;

		GetMenuInfo(oldMenuBar, &mi);
		SetMenuInfo(newMenuBar, &mi);
	}

	SetMenu(Dcx::mIRC.getHWND(), newMenuBar);

	// Go through old menubar items and detach them
	VectorOfXPopupMenu temp;
	VectorOfXPopupMenu::iterator itStart = this->m_vpXMenuBar.begin();
	VectorOfXPopupMenu::iterator itEnd = this->m_vpXMenuBar.end();

	// Add menus to a temporary list to prevent errors in looping
	while (itStart != itEnd) {
		temp.push_back(*itStart);
		++itStart;
	}

	itStart = temp.begin();
	itEnd = temp.end();

	// Begin detaching ...
	while (itStart != itEnd) {
		(*itStart)->detachFromMenuBar(oldMenuBar);
		++itStart;
	}

	// Destroy the menu if it isnt the original mIRC menubar.
	if (g_OriginalMenuBar == NULL)
		g_OriginalMenuBar = oldMenuBar;
	else
		DestroyMenu(oldMenuBar);

	DrawMenuBar(Dcx::mIRC.getHWND());
}
예제 #18
0
BEGIN_GUI_NAMESPACE

Menu::Menu( const std::string& root, HWND hwnd /*= NULL*/ )
    : Subscriber( root ), hwnd_( hwnd )
{
    if( hwnd_ )
    {
        hmenu_ = GetMenu( hwnd_ );
        if( hmenu_ )
        {
            while( GetMenuItemCount( hmenu_ ) != 0 )
                DeleteMenu( hmenu_, 0, MF_BYPOSITION );
        }
    }
    else
        hmenu_ = CreatePopupMenu();
    MENUINFO info = { sizeof( info ), MIM_BACKGROUND };
    info.hbrBack = GetSysColorBrush( COLOR_MENUBAR );
    SetMenuInfo( hmenu_, &info );
}
예제 #19
0
CEditor::CEditor(HWND nppHandle):CComDispatch(),m_Accelerators(nppHandle){
	AcceleratorHook::getInstance()->add(&m_Accelerators);

	// 3.) set our wndproc to have WM_MENUCOMMAND instead WM_COMMAND
	// see 1.) and 2.)
	m_NppHandle = nppHandle;

	WNDPROC oldWndProc = (WNDPROC)SetWindowLong(nppHandle, GWL_WNDPROC, (LPARAM)CEditor::WndProc);
	SetProp(m_NppHandle, SUBCLASSING, oldWndProc);

	m_Listener = NULL;
	
	// get main menu handle
	m_mainMenu = (HMENU)NPPM(GETMENUHANDLE,1,0);
	if (!m_mainMenu){
		VARIANT_BOOL hidden;

		get_menuHidden(&hidden);

		if (!hidden){
			m_mainMenu = GetMenu(nppData._nppHandle);
		}else{
			put_menuHidden(VARIANT_FALSE); 
			m_mainMenu = GetMenu(nppData._nppHandle);
			put_menuHidden(VARIANT_TRUE);
		}
	}
	// create views
	for(int i=0; i<m_ViewsNumber; i++){
		m_Views[i] = new CEditorView(i+1);
	}

	
	MENUINFO mi;
	memset(&mi, 0, sizeof(mi));
	mi.cbSize = sizeof(mi);
	mi.fMask = MIM_STYLE | MIM_APPLYTOSUBMENUS;
	mi.dwStyle = MNS_NOTIFYBYPOS;
	BOOL res = SetMenuInfo( m_mainMenu, &mi);	
}
예제 #20
0
	BOOL Show(HINSTANCE hInstance, int nCmdShow) {
		hInst = hInstance; // Store instance handle in our global variable.

		int zoom = g_Config.iWindowZoom;
		if (zoom < 1) zoom = 1;
		if (zoom > 4) zoom = 4;
		
		RECT rc, rcOrig;
		GetWindowRectAtZoom(zoom, rcOrig, rc);

		u32 style = WS_OVERLAPPEDWINDOW;

		hwndMain = CreateWindowEx(0,szWindowClass, "", style,
			rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
		if (!hwndMain)
			return FALSE;

		hwndDisplay = CreateWindowEx(0, szDisplayClass, TEXT(""), WS_CHILD | WS_VISIBLE,
			rcOrig.left, rcOrig.top, rcOrig.right - rcOrig.left, rcOrig.bottom - rcOrig.top, hwndMain, 0, hInstance, 0);
		if (!hwndDisplay)
			return FALSE;

		menu = GetMenu(hwndMain);
#ifdef FINAL
		RemoveMenu(menu,2,MF_BYPOSITION);
		RemoveMenu(menu,2,MF_BYPOSITION);
#endif
		MENUINFO info;
		ZeroMemory(&info,sizeof(MENUINFO));
		info.cbSize = sizeof(MENUINFO);
		info.cyMax = 0;
		info.dwStyle = MNS_CHECKORBMP;
		info.fMask = MIM_STYLE;
		for (int i = 0; i < GetMenuItemCount(menu); i++) {
			SetMenuInfo(GetSubMenu(menu,i),&info);
		}
		UpdateMenus();

		// Accept dragged files.
		DragAcceptFiles(hwndMain, TRUE);

		hideCursor = true;
		SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0);

		Update();
		SetPlaying(0);

		if(g_Config.bFullScreenOnLaunch)
			_ViewFullScreen(hwndMain);
		
		ShowWindow(hwndMain, nCmdShow);

		W32Util::MakeTopMost(hwndMain, g_Config.bTopMost);

#if ENABLE_TOUCH
		RegisterTouchWindow(hwndDisplay, TWF_WANTPALM);
#endif

		RAWINPUTDEVICE dev[2];
		memset(dev, 0, sizeof(dev));

		dev[0].usUsagePage = 1;
		dev[0].usUsage = 6;
		dev[0].dwFlags = 0;

		dev[1].usUsagePage = HID_USAGE_PAGE_GENERIC;
		dev[1].usUsage = HID_USAGE_GENERIC_MOUSE;
		dev[1].dwFlags = 0;
		RegisterRawInputDevices(dev, 2, sizeof(RAWINPUTDEVICE));

		SetFocus(hwndDisplay);

		return TRUE;
	}
예제 #21
0
파일: startmenu.c 프로젝트: Dimillian/wine
void do_startmenu(HWND hwnd)
{
    LPITEMIDLIST pidl;
    MENUINFO mi;
    MENUITEMINFOW mii;
    RECT rc={0,0,0,0};
    TPMPARAMS tpm;
    WCHAR run_label[50];

    destroy_menus();

    WINE_TRACE("creating start menu\n");

    root_menu.menuhandle = public_startmenu.menuhandle = user_startmenu.menuhandle = CreatePopupMenu();
    if (!root_menu.menuhandle)
    {
        return;
    }

    user_startmenu.parent = public_startmenu.parent = &root_menu;
    user_startmenu.base = &public_startmenu;
    user_startmenu.menu_filled = public_startmenu.menu_filled = FALSE;

    if (!user_startmenu.pidl)
        SHGetSpecialFolderLocation(NULL, CSIDL_STARTMENU, &user_startmenu.pidl);

    if (!user_startmenu.folder)
        pidl_to_shellfolder(user_startmenu.pidl, NULL, &user_startmenu.folder);

    if (!public_startmenu.pidl)
        SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_STARTMENU, &public_startmenu.pidl);

    if (!public_startmenu.folder)
        pidl_to_shellfolder(public_startmenu.pidl, NULL, &public_startmenu.folder);

    fill_menu(&user_startmenu);

    AppendMenuW(root_menu.menuhandle, MF_SEPARATOR, 0, NULL);

    if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_CONTROLS, &pidl)))
        add_shell_item(&root_menu, pidl);

    LoadStringW(NULL, IDS_RUN, run_label, sizeof(run_label)/sizeof(run_label[0]));

    mii.cbSize = sizeof(mii);
    mii.fMask = MIIM_STRING|MIIM_ID;
    mii.dwTypeData = run_label;
    mii.wID = MENU_ID_RUN;

    InsertMenuItemW(root_menu.menuhandle, -1, TRUE, &mii);

    mi.cbSize = sizeof(mi);
    mi.fMask = MIM_STYLE;
    mi.dwStyle = MNS_NOTIFYBYPOS;
    SetMenuInfo(root_menu.menuhandle, &mi);

    GetWindowRect(hwnd, &rc);

    tpm.cbSize = sizeof(tpm);
    tpm.rcExclude = rc;

    if (!TrackPopupMenuEx(root_menu.menuhandle,
        TPM_LEFTALIGN|TPM_BOTTOMALIGN|TPM_VERTICAL,
        rc.left, rc.top, hwnd, &tpm))
    {
        WINE_ERR("couldn't display menu\n");
    }
}
예제 #22
0
파일: startmenu.c 프로젝트: Dimillian/wine
/* add an individual file or folder to the menu, takes ownership of pidl */
static struct menu_item* add_shell_item(struct menu_item* parent, LPITEMIDLIST pidl)
{
    struct menu_item* item;
    MENUITEMINFOW mii;
    HMENU parent_menu;
    int existing_item_count, i;
    BOOL match = FALSE;
    SFGAOF flags;

    item = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct menu_item));

    if (parent->pidl == NULL)
    {
        pidl_to_shellfolder(pidl, &item->displayname, &item->folder);
    }
    else
    {
        STRRET strret;

        IShellFolder_GetDisplayNameOf(parent->folder, pidl, SHGDN_INFOLDER, &strret);
        StrRetToStrW(&strret, NULL, &item->displayname);

        flags = SFGAO_FOLDER;
        IShellFolder_GetAttributesOf(parent->folder, 1, (LPCITEMIDLIST*)&pidl, &flags);

        if (flags & SFGAO_FOLDER)
            IShellFolder_BindToObject(parent->folder, pidl, NULL, &IID_IShellFolder, (void *)&item->folder);
    }

    parent_menu = parent->menuhandle;

    item->parent = parent;
    item->pidl = pidl;

    existing_item_count = GetMenuItemCount(parent_menu);
    mii.cbSize = sizeof(mii);
    mii.fMask = MIIM_SUBMENU|MIIM_DATA;

    /* search for an existing menu item with this name or the spot to insert this item */
    if (parent->pidl != NULL)
    {
        for (i=0; i<existing_item_count; i++)
        {
            struct menu_item* existing_item;
            int cmp;

            GetMenuItemInfoW(parent_menu, i, TRUE, &mii);
            existing_item = ((struct menu_item*)mii.dwItemData);

            if (!existing_item)
                continue;

            /* folders before files */
            if (existing_item->folder && !item->folder)
                continue;
            if (!existing_item->folder && item->folder)
                break;

            cmp = CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, item->displayname, -1, existing_item->displayname, -1);

            if (cmp == CSTR_LESS_THAN)
                break;

            if (cmp == CSTR_EQUAL)
            {
                match = TRUE;
                break;
            }
        }
    }
    else
        /* This item manually added to the root menu, so put it at the end */
        i = existing_item_count;

    if (!match)
    {
        /* no existing item with the same name; just add it */
        mii.fMask = MIIM_STRING|MIIM_DATA;
        mii.dwTypeData = item->displayname;
        mii.dwItemData = (ULONG_PTR)item;

        if (item->folder)
        {
            MENUINFO mi;
            item->menuhandle = CreatePopupMenu();
            mii.fMask |= MIIM_SUBMENU;
            mii.hSubMenu = item->menuhandle;

            mi.cbSize = sizeof(mi);
            mi.fMask = MIM_MENUDATA;
            mi.dwMenuData = (ULONG_PTR)item;
            SetMenuInfo(item->menuhandle, &mi);
        }

        InsertMenuItemW(parent->menuhandle, i, TRUE, &mii);

        list_add_tail(&items, &item->entry);
    }
    else if (item->folder)
    {
        /* there is an existing folder with the same name, combine them */
        MENUINFO mi;

        item->base = (struct menu_item*)mii.dwItemData;
        item->menuhandle = item->base->menuhandle;

        mii.dwItemData = (ULONG_PTR)item;
        SetMenuItemInfoW(parent_menu, i, TRUE, &mii);

        mi.cbSize = sizeof(mi);
        mi.fMask = MIM_MENUDATA;
        mi.dwMenuData = (ULONG_PTR)item;
        SetMenuInfo(item->menuhandle, &mi);

        list_add_tail(&items, &item->entry);
    }
    else {
        /* duplicate shortcut, do nothing */
        HeapFree(GetProcessHeap(), 0, item->displayname);
        HeapFree(GetProcessHeap(), 0, item);
        CoTaskMemFree(pidl);
        item = NULL;
    }

    return item;
}
예제 #23
0
파일: NppShell.cpp 프로젝트: Tanjas5/npp
// *** IContextMenu methods ***
STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/) {
	UINT idCmd = idCmdFirst;

	FORMATETC fmte = {
		CF_HDROP,
		(DVTARGETDEVICE FAR *)NULL,
		DVASPECT_CONTENT,
		-1,
		TYMED_HGLOBAL
	};

	HRESULT hres = m_pDataObj->GetData(&fmte, &m_stgMedium);

	if (SUCCEEDED(hres)) {
		if (m_stgMedium.hGlobal)
			m_cbFiles = DragQueryFile((HDROP)m_stgMedium.hGlobal, (UINT)-1, 0, 0);
	}

	UINT nIndex = indexMenu++;

	InsertMenu(hMenu, nIndex, MF_STRING|MF_BYPOSITION, idCmd++, m_szMenuTitle);

	if (m_showIcon) {
		HBITMAP icon = NULL;
		if (m_winVer >= WINVER_VISTA) {
			icon = NULL;
			HICON hicon;
			DWORD menuIconWidth = GetSystemMetrics(SM_CXMENUCHECK);
			DWORD menuIconHeight = GetSystemMetrics(SM_CYMENUCHECK);
			HRESULT hr = LoadShellIcon(menuIconWidth, menuIconHeight, &hicon);
			if (SUCCEEDED(hr)) {
				icon = IconToBitmapPARGB32(hicon, menuIconWidth, menuIconHeight);
				DestroyIcon(hicon);
			}
		} else {
			icon = HBMMENU_CALLBACK;
		}

		if (icon != NULL) {
			MENUITEMINFO mii;
			ZeroMemory(&mii, sizeof(mii));
			mii.cbSize = sizeof(mii);
			mii.fMask = MIIM_BITMAP;
			mii.hbmpItem = icon;
			//mii.hbmpChecked = icon;
			//mii.hbmpUnchecked = icon;

			SetMenuItemInfo(hMenu, nIndex, MF_BYPOSITION, &mii);

			if (m_winVer >= WINVER_VISTA) {
				MENUINFO MenuInfo;
				MenuInfo.cbSize = sizeof(MenuInfo);
				MenuInfo.fMask = MIM_STYLE;
				MenuInfo.dwStyle = MNS_CHECKORBMP;

				SetMenuInfo(hMenu, &MenuInfo);
			}

		}
	}

	m_hMenu = hMenu;
	m_menuID = idCmd;

	return ResultFromShort(idCmd-idCmdFirst);
}
예제 #24
0
/*************************************************************************
 * FileMenu_AppendItem			[SHELL32.115]
 *
 */
static BOOL FileMenu_AppendItemW(
	HMENU hMenu,
	LPCWSTR lpText,
	UINT uID,
	int icon,
	HMENU hMenuPopup,
	int nItemHeight)
{
	MENUITEMINFOW	mii;
	LPFMITEM	myItem;
	LPFMINFO	menudata;
	MENUINFO        MenuInfo;


	TRACE("%p %s 0x%08x 0x%08x %p 0x%08x\n",
	  hMenu, (lpText!=FM_SEPARATOR) ? debugstr_w(lpText) : NULL,
	  uID, icon, hMenuPopup, nItemHeight);

	ZeroMemory (&mii, sizeof(MENUITEMINFOW));

	mii.cbSize = sizeof(MENUITEMINFOW);

	if (lpText != FM_SEPARATOR)
	{
	  int len = strlenW (lpText);
          myItem = SHAlloc(sizeof(FMITEM) + len*sizeof(WCHAR));
	  strcpyW (myItem->szItemText, lpText);
	  myItem->cchItemText = len;
	  myItem->iIconIndex = icon;
	  myItem->hMenu = hMenu;
	  mii.fMask = MIIM_DATA;
	  mii.dwItemData = (ULONG_PTR) myItem;
	}

	if ( hMenuPopup )
	{ /* sub menu */
	  mii.fMask |= MIIM_TYPE | MIIM_SUBMENU;
	  mii.fType = MFT_OWNERDRAW;
	  mii.hSubMenu = hMenuPopup;
	}
	else if (lpText == FM_SEPARATOR )
	{ mii.fMask |= MIIM_ID | MIIM_TYPE;
	  mii.fType = MFT_SEPARATOR;
	}
	else
	{ /* normal item */
	  mii.fMask |= MIIM_ID | MIIM_TYPE | MIIM_STATE;
	  mii.fState = MFS_ENABLED | MFS_DEFAULT;
	  mii.fType = MFT_OWNERDRAW;
	}
	mii.wID = uID;

	InsertMenuItemW (hMenu, (UINT)-1, TRUE, &mii);

	/* set bFixedItems to true */
	MenuInfo.cbSize = sizeof(MENUINFO);
	MenuInfo.fMask = MIM_MENUDATA;

	if (! GetMenuInfo(hMenu, &MenuInfo))
	  return FALSE;

	menudata = (LPFMINFO)MenuInfo.dwMenuData;
	if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO)))
	{
	  ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize);
	  return 0;
	}

	menudata->bFixedItems = TRUE;
	SetMenuInfo(hMenu, &MenuInfo);

	return TRUE;

}
예제 #25
0
/*************************************************************************
 * FM_InitMenuPopup				[internal]
 *
 */
static int FM_InitMenuPopup(HMENU hmenu, LPCITEMIDLIST pAlternatePidl)
{	IShellFolder	*lpsf, *lpsf2;
	ULONG		ulItemAttr = SFGAO_FOLDER;
	UINT		uID, uEnumFlags;
	LPFNFMCALLBACK	lpfnCallback;
	LPCITEMIDLIST	pidl;
	WCHAR		sTemp[MAX_PATH];
	int		NumberOfItems = 0, iIcon;
	MENUINFO	MenuInfo;
	LPFMINFO	menudata;

	TRACE("%p %p\n", hmenu, pAlternatePidl);

	MenuInfo.cbSize = sizeof(MENUINFO);
	MenuInfo.fMask = MIM_MENUDATA;

	if (! GetMenuInfo(hmenu, &MenuInfo))
	  return FALSE;

	menudata = (LPFMINFO)MenuInfo.dwMenuData;

	if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO)))
	{
	  ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize);
	  return 0;
	}

	if (menudata->bInitialized)
	  return 0;

	pidl = (pAlternatePidl? pAlternatePidl: menudata->pidl);
	if (!pidl)
	  return 0;

	uID = menudata->uID;
	uEnumFlags = menudata->uEnumFlags;
	lpfnCallback = menudata->lpfnCallback;
	menudata->bInitialized = FALSE;

	SetMenuInfo(hmenu, &MenuInfo);

	if (SUCCEEDED (SHGetDesktopFolder(&lpsf)))
	{
	  if (SUCCEEDED(IShellFolder_BindToObject(lpsf, pidl,0,(REFIID)&IID_IShellFolder,(LPVOID *)&lpsf2)))
	  {
	    IEnumIDList	*lpe = NULL;

	    if (SUCCEEDED (IShellFolder_EnumObjects(lpsf2, 0, uEnumFlags, &lpe )))
	    {

	      LPITEMIDLIST pidlTemp = NULL;
	      ULONG ulFetched;

	      while ((!bAbortInit) && (NOERROR == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched)))
	      {
		if (SUCCEEDED (IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulItemAttr)))
		{
		  ILGetDisplayNameExW(NULL, pidlTemp, sTemp, ILGDN_FORPARSING);
		  if (! (PidlToSicIndex(lpsf, pidlTemp, FALSE, 0, &iIcon)))
		    iIcon = FM_BLANK_ICON;
		  if ( SFGAO_FOLDER & ulItemAttr)
		  {
		    LPFMINFO lpFmMi;
		    MENUINFO MenuInfo;
		    HMENU hMenuPopup = CreatePopupMenu();

		    lpFmMi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO));

		    lpFmMi->pidl = ILCombine(pidl, pidlTemp);
		    lpFmMi->uEnumFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS;

		    MenuInfo.cbSize = sizeof(MENUINFO);
		    MenuInfo.fMask = MIM_MENUDATA;
		    MenuInfo.dwMenuData = (ULONG_PTR) lpFmMi;
		    SetMenuInfo (hMenuPopup, &MenuInfo);

		    FileMenu_AppendItemW (hmenu, sTemp, uID, iIcon, hMenuPopup, FM_DEFAULT_HEIGHT);
		  }
		  else
		  {
		    LPWSTR pExt = PathFindExtensionW(sTemp);
		    if (pExt)
		      *pExt = 0;
		    FileMenu_AppendItemW (hmenu, sTemp, uID, iIcon, 0, FM_DEFAULT_HEIGHT);
		  }
		}

		if (lpfnCallback)
		{
		  TRACE("enter callback\n");
		  lpfnCallback ( pidl, pidlTemp);
		  TRACE("leave callback\n");
		}

		NumberOfItems++;
	      }
	      IEnumIDList_Release (lpe);
	    }
	    IShellFolder_Release(lpsf2);
	  }
	  IShellFolder_Release(lpsf);
	}

	if ( GetMenuItemCount (hmenu) == 0 )
	{
          static const WCHAR szEmpty[] = { '(','e','m','p','t','y',')',0 };
	  FileMenu_AppendItemW (hmenu, szEmpty, uID, FM_BLANK_ICON, 0, FM_DEFAULT_HEIGHT);
	  NumberOfItems++;
	}

	menudata->bInitialized = TRUE;
	SetMenuInfo(hmenu, &MenuInfo);

	return NumberOfItems;
}
예제 #26
0
BOOL GLWindow::createGLWindow(char* title, WNDPROC WndProc)
{
	WNDCLASS	wc;
	DWORD		dwExStyle;	
	DWORD		dwStyle;
	RECT		WindowRect;

	int	width = isFullscreen?videoModes[fullscreenMode].width:videoModes[windowedMode].width;
	int	height = isFullscreen?videoModes[fullscreenMode].height:videoModes[windowedMode].height;
	int	bits = isFullscreen?videoModes[fullscreenMode].bpp:videoModes[windowedMode].bpp;

	windowPosition = Point(nativeMode.dmPelsWidth/2 - width/2, nativeMode.dmPelsHeight/2 - height/2);

	int	x = isFullscreen?0:windowPosition.x;
	int	y = isFullscreen?0:windowPosition.y;

	WindowRect.left = (long) x;
	WindowRect.right = (long) x + width;
	WindowRect.top = (long) y;	
	WindowRect.bottom = (long) y + height;

	hInstance			= GetModuleHandle(NULL);
	wc.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc		= (WNDPROC) WndProc;
	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 0;
	wc.hInstance		= hInstance;
	wc.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground	= NULL;	
	wc.lpszMenuName		= NULL;	
	wc.lpszClassName	= __TEXT("OGL");  

	RegisterClass(&wc);

	if (isFullscreen)
	{
		DEVMODE dm;								
		memset(&dm,0,sizeof(dm));
		dm.dmSize=sizeof(dm);
		dm.dmPelsWidth	= width;
		dm.dmPelsHeight	= height;
		dm.dmBitsPerPel	= bits;	
		dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
		ChangeDisplaySettings(&dm,CDS_FULLSCREEN);		
		dwExStyle = WS_EX_APPWINDOW;
		dwStyle = WS_POPUP;
	}
	else
	{
		dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
		dwStyle = WS_OVERLAPPEDWINDOW | WS_MINIMIZEBOX  | WS_SYSMENU | WS_VISIBLE;
	}

	AdjustWindowRectEx(&WindowRect, dwStyle, false, dwExStyle);

	HMENU		hMenu;
	hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(ID_MENU));

	HBRUSH hBrush = CreateSolidBrush(RGB(150, 150, 150)); 
	MENUINFO mi = { 0 }; 
	mi.cbSize = sizeof(mi); 
	mi.fMask = MIM_BACKGROUND|MIM_APPLYTOSUBMENUS; 
	mi.hbrBack = hBrush;
	SetMenuInfo(hMenu, &mi);

	hWnd=CreateWindowEx(	dwExStyle,
		__TEXT("OGL"),
		title,
		dwStyle |
		WS_CLIPSIBLINGS |
		WS_CLIPCHILDREN,
		WindowRect.left, WindowRect.top,
		WindowRect.right-WindowRect.left,
		WindowRect.bottom-WindowRect.top,
		NULL,
		hMenu,
		hInstance,
		NULL);	

	if(!isFullscreen)
	{
		dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;	
		dwStyle = WS_OVERLAPPEDWINDOW | WS_MINIMIZEBOX  | WS_SYSMENU | WS_VISIBLE;
		SetWindowLongPtr(hWnd, GWL_EXSTYLE,  dwExStyle);
		SetWindowLongPtr(hWnd, GWL_STYLE, dwStyle);
	}
	
	SetWindowTheme(hWnd, L" ", L" ");

	RECT rcClient,rcWind;
	GetClientRect(hWnd, &rcClient); 
	GetWindowRect(hWnd, &rcWind); 
	borderWidth = 2*((rcWind.right - rcWind.left) - rcClient.right)/2; 
	borderHeight = 2*((rcWind.bottom - rcWind.top) - rcClient.bottom)/2; 

	initGL(bits);

	SetForegroundWindow(hWnd);
	SetFocus(hWnd);
	return true;
}
예제 #27
0
//-----------------------------------------------------------------------------
HMENU Win32OptionMenu::createMenu (COptionMenu* _menu, int32_t& offsetIdx)
{
	HMENU menu = CreatePopupMenu ();

	bool multipleCheck = _menu->getStyle () & (kMultipleCheckStyle & ~kCheckStyle);

#if 0
	if (!multipleCheck && !(_menu->getStyle () & kCheckStyle))
	{
		MENUINFO mi = {0};
		mi.cbSize = sizeof (MENUINFO);
		mi.fMask = MIM_STYLE;
		mi.dwStyle = MNS_NOCHECK;
		SetMenuInfo (menu, &mi);
	}
#endif

	MENUINFO mi = {0};
	mi.cbSize = sizeof (MENUINFO);
	mi.dwStyle = MNS_CHECKORBMP;
	SetMenuInfo (menu, &mi);

	int flags = 0;
	int32_t offset = offsetIdx;
	int32_t nbEntries = _menu->getNbEntries ();
	offsetIdx += nbEntries;
	int32_t inc = 0;
	CMenuItemIterator it = _menu->getItems ()->begin ();
	while (it != _menu->getItems ()->end ())
	{
		CMenuItem* item = (*it);
		if (item->isSeparator ())
		{
			AppendMenu (menu, MF_SEPARATOR, 0, 0);
		}
		else
		{
			char* titleWithPrefixNumbers = 0;
			if (_menu->getPrefixNumbers ())
			{
				titleWithPrefixNumbers = (char*)std::malloc (strlen (item->getTitle ()) + 50);
				switch (_menu->getPrefixNumbers ())
				{
					case 2:
					{
						sprintf (titleWithPrefixNumbers, "%1d %s", inc+1, item->getTitle ());
						break;
					}
					case 3:
					{
						sprintf (titleWithPrefixNumbers, "%02d %s", inc+1, item->getTitle ());
						break;
					}
					case 4:
					{
						sprintf (titleWithPrefixNumbers, "%03d %s", inc+1, item->getTitle ());
						break;
					}
				}
			}
			UTF8StringHelper entryText (titleWithPrefixNumbers ? titleWithPrefixNumbers : item->getTitle ());
			flags = MF_STRING;
			if (nbEntries < 160 && _menu->getNbItemsPerColumn () > 0 && inc && !(inc % _menu->getNbItemsPerColumn ()))
				flags |= MF_MENUBARBREAK;

			if (item->getSubmenu ())
			{
				HMENU submenu = createMenu (item->getSubmenu (), offsetIdx);
				if (submenu)
				{
					AppendMenu (menu, flags|MF_POPUP|MF_ENABLED, (UINT_PTR)submenu, (const TCHAR*)entryText);
				}
			}
			else
			{
				if (item->isEnabled ())
					flags |= MF_ENABLED;
				else
					flags |= MF_GRAYED;
				if (item->isTitle ())
					flags |= MF_DISABLED;
				if (multipleCheck && item->isChecked ())
					flags |= MF_CHECKED;
				if (_menu->getStyle () & kCheckStyle && inc == _menu->getCurrentIndex ())
					flags |= MF_CHECKED;
				if (!(flags & MF_CHECKED))
					flags |= MF_UNCHECKED;
				AppendMenu (menu, flags, offset + inc, entryText);
				IPlatformBitmap* platformBitmap = item->getIcon () ? item->getIcon ()->getPlatformBitmap () : 0;
				if (platformBitmap)
				{
					Win32BitmapBase* win32Bitmap = dynamic_cast<Win32BitmapBase*> (platformBitmap);
					if (win32Bitmap)
					{
						MENUITEMINFO mInfo = {0};
						mInfo.cbSize = sizeof (MENUITEMINFO);
						mInfo.fMask = MIIM_BITMAP;
						HBITMAP hBmp = win32Bitmap->createHBitmap ();
						if (hBmp)
						{
							mInfo.hbmpItem = hBmp;
							SetMenuItemInfo (menu, offset + inc, TRUE, &mInfo);
							bitmaps.push_back (hBmp);
						}
					}
				}
			}
			if (titleWithPrefixNumbers)
				std::free (titleWithPrefixNumbers);
		}
		inc++;
		it++;
	}
	return menu;
}