⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 播放器源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:

			playlist->AddItem(arg1);
		}

		token++;
	}
}

/**************************************************************************************
 *                                                                                    *
 * - ReBuildRecentFilesMenu():                                                        *
 *                                                                                    *
 *   -- Parses the command line and override options                                  *
 *                                                                                    *
 **************************************************************************************/

void ReBuildRecentFilesMenu()
{
   HMENU             menu;
   MENUITEMINFO      itemInfo;
   DWORD             i,count;
   char              buffer[MAX_PATH + 4];

   menu = GetSubMenu(popupMenu, 0);
   menu = GetSubMenu(menu, 5);

   if(RecentFiles[0] != NULL) {

	   count = GetMenuItemCount(menu);

	   for(i=0; i<count; i++)
		   RemoveMenu(menu, 0, MF_BYPOSITION);
   
	   /*
		 * Now add the files
		 */
   
	   for(i=0; i < 5; i++) {
	   
		   if(RecentFiles[i] != NULL) {

				sprintf(buffer, "%d - ", i+1);
				strcat(buffer, RecentFiles[i]);

			   itemInfo.cbSize = sizeof(MENUITEMINFO);
			   itemInfo.fMask  = MIIM_DATA | MIIM_TYPE | MIIM_ID;
			   itemInfo.fType  = MFT_STRING;
			   itemInfo.dwTypeData = buffer;
			   itemInfo.cch = strlen(buffer);
			   itemInfo.wID = ID_RECENT_FILE1 + i;
		   
			   InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &itemInfo);
			}
	   }
    itemInfo.cbSize = sizeof(MENUITEMINFO);
    itemInfo.fMask  = MIIM_DATA | MIIM_TYPE | MIIM_ID;
    itemInfo.fType  = MFT_SEPARATOR;
    itemInfo.dwTypeData = "";
    itemInfo.cch = strlen("");
    itemInfo.wID = ID_RECENT_FILE1 + i;
		   
	InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &itemInfo);

    itemInfo.cbSize = sizeof(MENUITEMINFO);
    itemInfo.fMask  = MIIM_DATA | MIIM_TYPE | MIIM_ID;
    itemInfo.fType  = MFT_STRING;
    itemInfo.dwTypeData = "Clear list";
	itemInfo.cch = strlen("Clear list");
	itemInfo.wID = ID_CLEAR_LIST;
		   
	InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &itemInfo);

   }
   else {

	   count = GetMenuItemCount(menu);

	   for(i=0; i<count; i++)
		   RemoveMenu(menu, 0, MF_BYPOSITION);

	   itemInfo.cbSize = sizeof(MENUITEMINFO);
	itemInfo.fMask  = MIIM_DATA | MIIM_TYPE | MIIM_ID;
    itemInfo.fType  = MFT_STRING;
    itemInfo.dwTypeData = "No recent files...";
    itemInfo.cch = strlen("No recent files...");
    itemInfo.wID = ID_RECENT_FILE1;
		   
	InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &itemInfo);
	EnableMenuItem(menu, ID_RECENT_FILE1, MF_GRAYED);
   }

}

/**************************************************************************************
 *                                                                                    *
 * - UpdateRecentFilesMenu():                                                         *
 *                                                                                    *
 *   -- Add (if OK) an entry to the file list                                         *
 *                                                                                    *
 **************************************************************************************/

void UpdateRecentFilesMenu(char *filename)
{
	DWORD i;
	DWORD insert = 1;

	for(i=0; i < 5; i++) {
				
		if(RecentFiles[i] != NULL && strcmp(RecentFiles[i], filename) == 0) {
			insert = 0;
		}
	}

	if(insert) {
		
		for(i=4; i > 0; i--) {
				
			RecentFiles[i] = RecentFiles[i - 1];
		}

		RecentFiles[0] = (char *) new char[(strlen(filename) + 1)];
		strncpy(RecentFiles[0], filename, strlen(filename));
		RecentFiles[0][strlen(filename)] = '\0';
	}
}


/**************************************************************************************
 *                                                                                    *
 * - PreparesDesktopMode():                                                           *
 *                                                                                    *
 *   -- Do the setup for the desktop mode                                             *
 *                                                                                    *
 **************************************************************************************/

void PrepareDesktopMode() {

	HRESULT hr;
	IActiveDesktop *pActiveDesktop;

	/*
	 * Active Desktop Stuff
	 * --------------------
	 */

	hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
					      IID_IActiveDesktop, (void**)&pActiveDesktop);


	if(hr == S_OK) {

		wchar_t *wstr;

		pActiveDesktop->GetWallpaper((LPWSTR) &wallpaper, MAX_PATH, 0);
		pActiveDesktop->GetPattern((LPWSTR) &pattern, MAX_PATH, 0);

		wstr = (wchar_t *) new char[2*MAX_PATH];
		mbtowc(wstr, "None", MAX_PATH);
		pActiveDesktop->SetWallpaper((WCHAR *) wstr, 0);
		pActiveDesktop->SetPattern((WCHAR *) wstr, 0);
	
		pActiveDesktop->ApplyChanges(AD_APPLY_ALL);

		pActiveDesktop->Release();
	}

	/*
	 * Standard Stuff
	 * --------------
	 */

	COLORREF colorref;
	INT      background;

	background = COLOR_DESKTOP;
	colorref   = DD_OVERLAY_COLORREF;

	/*
	 * Get the Settings
	 */

	backColor = GetSysColor(COLOR_DESKTOP);
				
	/*
	 * And set ours
	 */

	SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "", 0);
	SetSysColors(1, &background, &colorref);
}

/**************************************************************************************
 *                                                                                    *
 * - UnPreparesDesktopMode():                                                         *
 *                                                                                    *
 *   -- UnDo the setup for the desktop mode                                           *
 *                                                                                    *
 **************************************************************************************/

void UnPrepareDesktopMode() {

	HRESULT hr;
	IActiveDesktop *pActiveDesktop;

	/*
	 * Active Desktop Stuff
	 * --------------------
	 */

	hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
					      IID_IActiveDesktop, (void**)&pActiveDesktop);


	if(hr == S_OK) {

		pActiveDesktop->SetWallpaper(wallpaper, 0);
		pActiveDesktop->SetPattern(pattern, 0);
	
		pActiveDesktop->ApplyChanges(AD_APPLY_ALL);

		pActiveDesktop->Release();
	}

	/*
	 * API stuff
	 */

	INT background = COLOR_DESKTOP;
		
	SetSysColors(1, &background, &backColor);
	SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, 0);

	playback->SetDesktopMode(FALSE);
}

/**************************************************************************************
 *                                                                                    *
 * - PrepareCompactMode():                                                            *
 *                                                                                    *
 *   -- Do the setup for the desktop mode                                             *
 *                                                                                    *
 **************************************************************************************/

void PrepareCompactMode() {

	HMENU        menu;
	MENUITEMINFO itemInfo;

	menu = GetSubMenu(popupMenu, 0);

	memset(&itemInfo, 0, sizeof(MENUITEMINFO));
	
	itemInfo.cbSize     = sizeof(MENUITEMINFO);
	itemInfo.fType      = MFT_STRING;
	itemInfo.fMask      = MIIM_TYPE;
	itemInfo.dwTypeData = "&Standard Mode\tAlt+C";
		
	SetMenuItemInfo(menu, ID_COMPACT, FALSE, &itemInfo);
}

/**************************************************************************************
 *                                                                                    *
 * - UnPrepareCompactMode():                                                          *
 *                                                                                    *
 *   -- UnDo the setup for the desktop mode                                           *
 *                                                                                    *
 **************************************************************************************/

void UnPrepareCompactMode() {

	HMENU        menu;
	MENUITEMINFO itemInfo;
	
	compact_mode = 0;
	skin->SetCompact(FALSE);

	/*
	 * Change the menu item text
	 */	

	menu = GetSubMenu(popupMenu, 0);

	memset(&itemInfo, 0, sizeof(MENUITEMINFO));

	itemInfo.cbSize     = sizeof(MENUITEMINFO);
	itemInfo.fType      = MFT_STRING;
	itemInfo.fMask      = MIIM_TYPE;
	itemInfo.dwTypeData = "&Compact Mode\tAlt+C";

	SetMenuItemInfo(menu, ID_COMPACT, FALSE, &itemInfo);

	/*
	 * And resize the window
	 */

	GetWindowRect(hwnd, &windowRect);
	
	MoveWindow( hwnd, windowRect.left - 7, 
				windowRect.top - 22, 
				cwindowRect.right - cwindowRect.left, 
				cwindowRect.bottom - cwindowRect.top, TRUE);
				
	playback->SetVideoRect(skin->GetVideoRect());
}

/**************************************************************************************
 *                                                                                    *
 * - ChangeMenuForNormalMode():                                                       *
 *                                                                                    *
 *   -- Re-Creates the playlist popup menu                                            *
 *                                                                                    *
 **************************************************************************************/

void ChangeMenuForNormalMode() 
{
	HMENU menu;

	menu = GetSubMenu(popupMenu, 0);

	/*
	 * The subtitles and Properties menus
	 */

	MENUITEMINFO itemInfo;
				
	/*
	 * Re-update the menu items
	 */

	EnableMenuItem(popupMenu, ID_COMPACT, MF_ENABLED);
	EnableMenuItem(popupMenu, ID_FULLSCREEN, MF_ENABLED);

	EnableMenuItem(popupMenu, (UINT)ID_ON_TOP,      MF_ENABLED);

	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_ORIGINAL, MF_ENABLED);
	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_FREE,     MF_ENABLED);
	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_43,       MF_ENABLED);
	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_169,      MF_ENABLED);
	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_CUSTOM,   MF_ENABLED);

	menu = GetSubMenu(popupMenu, 0);

	memset(&itemInfo, 0, sizeof(MENUITEMINFO));
	
	itemInfo.cbSize     = sizeof(MENUITEMINFO);
	itemInfo.fType      = MFT_STRING;
	itemInfo.fMask      = MIIM_TYPE;
	itemInfo.dwTypeData = "&Desktop mode\tAlt+D";
		
	SetMenuItemInfo(menu, ID_DESKTOP, FALSE, &itemInfo);

	EnableMenuItem(popupMenu, (UINT)ID_PROPERTIES,      MF_ENABLED);
	EnableMenuItem(popupMenu, (UINT)ID_DESKTOP,         MF_ENABLED);
}

/**************************************************************************************
 *                                                                                    *
 * - ChangeMenuForFullscreenlMode():                                                  *
 *                                                                                    *
 *   -- Re-Creates the playlist popup menu                                            *
 *                                                                                    *
 **************************************************************************************/

void ChangeMenuForFullscreenMode() 
{
	HMENU        menu;
	MENUITEMINFO itemInfo;

	GetWindowRect(hwnd, &fullwindowRect);

	/*
	 * Disbale some menu items
	 */

	EnableMenuItem(popupMenu, ID_COMPACT, MF_GRAYED);
	EnableMenuItem(popupMenu, ID_FULLSCREEN, MF_GRAYED);
	
	EnableMenuItem(popupMenu, (UINT)ID_ON_TOP,      MF_GRAYED);

	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_ORIGINAL, MF_GRAYED);
	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_FREE,     MF_GRAYED);
	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_43,       MF_GRAYED);
	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_169,      MF_GRAYED);
	EnableMenuItem(popupMenu, (UINT)ID_ASPECT_CUSTOM,   MF_GRAYED);

	menu = GetSubMenu(popupMenu, 0);

	memset(&itemInfo, 0, sizeof(MENUITEMINFO));
	
	itemInfo.cbSize     = sizeof(MENUITEMINFO);
	itemInfo.fType      = MFT_STRING;
	itemInfo.fMask      = MIIM_TYPE;
	itemInfo.dwTypeData = "Go back to normal mode\tAlt+Enter";
		
	SetMenuItemInfo(menu, ID_DESKTOP, FALSE, &itemInfo);
}

/**************************************************************************************
 *                                                                                    *
 * - ReBuildPlaylistMenu():                                                           *
 *                                                                                    *
 *   -- Re-Creates the playlist popup menu                                            *
 *                                                                                    *
 **************************************************************************************/

void ReBuildPlaylistMenu()
{
	HMENU menu;
	DWORD i;
	DWORD count;
	MENUITEMINFO itemInfo;

	menu = GetSubMenu(GetSubMenu(GetSubMenu(popupMenu, 0), 9), 0);

	count = GetMenuItemCount(menu);

	for(i=0; i < count; i++) {
						
		RemoveMenu(menu, 0, MF_BYPOSITION);				
	}

	/*
	 * Add the normal items
	 *
	 */

	itemInfo.cbSize = sizeof(MENUITEMINFO);
	itemInfo.fMask  = MIIM_DATA | MIIM_TYPE | MIIM_ID;
	itemInfo.fType  = MFT_STRING;
	itemInfo.dwTypeData = "Add Files...\tAlt+A";
	itemInfo.cch = strlen("Add Files...\tAlt+A");
	itemInfo.wID = ID_MENU_PLAYBACK_FILES_ADDFILES;
		   
	InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &itemInfo);

	itemInfo.cbSize = sizeof(MENUITEMINFO);
	itemInfo.fMask  = MIIM_DATA | MIIM_TYPE | MIIM_ID;
	itemInfo.fType  = MFT_SEPARATOR;
	itemInfo.dwTypeData = "-";
	itemInfo.cch = strlen("-");
	itemInfo.wID = 0;
		   
	InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &itemInfo);


	/*
	 * Now add the files
	 */
   
    for(i=0; i < playlist->GetItemCount(); i++) {
	   
		char *name;

		if(strrchr(playlist->GetItemAt(i)->filename, '\\') != NULL) {

			name = strrchr(playlist->GetItemAt(i)->filename, '\\') + 1;
		}
		else {

			name = playlist->GetItemAt(i)->filename;
		}

	  itemInfo.cbSize     = sizeof(MENUITEMINFO);
	  itemInfo.fMask      = MIIM_DATA | MIIM_TYPE | MIIM_ID;
	  itemInfo.fType      = MFT_STRING;
	  itemInfo.dwTypeData = name;
	  itemInfo.cch        = strlen(name);
	  itemInfo.wID        = ID_PLAYLIST1 + i;
	  itemInfo.dwItemData = i;
		   
	  InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &itemInfo);
   }

	/*
	 * And select the current one
	 *
	 */

	CheckMenuItem(menu, ID_PLAYLIST1 + playlist->GetCurrentPosition(), MF_CHECKED);
}

/**************************************************************************************
 *                                                                                    *
 * - UpdateMainWindow():                                                              *
 *                                                                                    *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -