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

📄 playlisteditor.cpp

📁 一个播放器 使用了evc 大家可以参考下 哦
💻 CPP
📖 第 1 页 / 共 2 页
字号:
 /***************************************************************************************
 *This program is free software; you can redistribute it and/or modify					*
 * it under the terms of the GNU General Public License as published by					*
 * the Free Software Foundation; either version 2 of the License, or					*
 * (at your option) any later version.													*
 *																						*
 * The GPL can be found at: http://www.gnu.org/copyleft/gpl.html						*
 *																						*
 *																						*	
 ****************************************************************************************
 * Authors:																			  *
 *          Marc Dukette                                                              *
 **************************************************************************************/

#include "stdafx.h"
#include "PlaylistEditor.h"
#include <commctrl.h>
#include <commdlg.h>
#if (_WIN32_WCE >= 300 && !defined(HPC))
#include <aygshell.h>
#include <sipapi.h>
	#define SHCMBM_GETMENU      (WM_USER + 402)
	#define SHGetMenu( hWndMB )  ( HMENU )SendMessage( ( hWndMB ), SHCMBM_GETMENU, ( WPARAM )0, ( LPARAM )0 )
	#define CommandBar_GetMenu( hWndMB, x )		( HMENU )SendMessage( ( hWndMB ), SHCMBM_GETMENU, ( WPARAM )0, ( LPARAM )0 )
	typedef BOOL (CALLBACK* paygshell_SHCreateMenuBar)( SHMENUBARINFO *pmb );
	paygshell_SHCreateMenuBar aygshell_SHCreateMenuBar;
#endif
#ifdef GAPI
	#include "gx.h"
	GXKeyList g_gxk;
#endif

	LPTSTR ToolTips[9]={_T(""),_T("Open Playlist"),_T("Save"),_T("Add Item"),_T("Add Item URL"),_T("Delete Item"),_T("Play"),_T("Move Up"),_T("Move Down")};


#define MAX_LOADSTRING 100
extern int fnGetFileName(HWND Parent,LPTSTR Filter, LPTSTR initialDir, LPTSTR OutFileName, int MaxFilName,LPTSTR* szMultiBuff,unsigned int vk,int URL);

// Global Variables:
HINSTANCE			hInst;			// The current instance
HWND				hwndCB;			// The command bar handle
OPENFILENAME ofn;
HWND hwndList;
// Forward declarations of functions included in this code module:
ATOM				MyRegisterClass	(HINSTANCE, LPTSTR);
BOOL				InitInstance	(HINSTANCE, int);
LRESULT CALLBACK	WndProc			(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK	About			(HWND, UINT, WPARAM, LPARAM);
//TCHAR file[200]={L"/my documents/untiltled.pdl"};
TCHAR		szFile[MAX_PATH] = TEXT("");
TCHAR		szPDLFile[MAX_PATH] = TEXT(".pdl\0");
TCHAR temp[200];
bool Edited=false;
#define REG_BASE_FMT			L"software\\PocketMVP\\plugins\\format"
TCHAR tfile[MAX_PATH];// = TEXT(".pdl\0");
/*
int LoadDecoder()
{
	HKEY hKey = 0;
	DWORD dwSize = 0;
	DWORD dwType = 0;
	DWORD dwTmp;
	TCHAR temp[10];
	TCHAR value[200];
	int n=0;
	if (hdivx) FreeLibrary((HINSTANCE)hdivx);
	if (ha) FreeLibrary((HINSTANCE)ha);
	hdivx=NULL;
	ha=NULL;
	DropTwo=1;
	if (vidinfo->a_fmt>1)
	{
		RawAudio=false;
		if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_BASE_AUDIO, 0, 0, &hKey ) )
		{
			dwTmp = 0;
			wcscpy(temp,_T(""));
			dwSize =sizeof(value);
			TCHAR fmt[10];
			_itow(vidinfo->a_fmt,fmt,10);
			wcscat(temp,fmt);
			if ( ERROR_SUCCESS == RegQueryValueEx( hKey, temp, 0, &dwType, ( LPBYTE )value, &dwSize ) )
			{
				if (wcsicmp(value,_T("")))
				{
					ha=LoadLibrary(value);
					if (!ha)
					{
						return -1;
					}		
				}
				else
				{
					ha=NULL;
				}
			}
			else
			{
				MessageBox(hWndMain,_T("This file contains an incompatible audio format"),_T("Audio Error"),MB_OK);
				vidinfo->audio_bytes = 0;
//				return -1;
			}
			RegCloseKey( hKey );
		}
		else
		{
			MessageBox(hWndMain,_T("This file contains an incompatible audio format"),_T("Audio Error"),MB_OK);
			vidinfo->audio_bytes = 0;
		}
	}	
	else
	{
		RawAudio=true;
	}
	if (strcmp(vidinfo->compressor,""))
	{
		if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_BASE_VIDEO, 0, 0, &hKey ) )
		{
			dwTmp = 0;
			wcscpy(temp,_T(""));
			dwSize =sizeof(value);
			TCHAR hold[5];
			MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,vidinfo->compressor,-1,hold,5);
			wcslwr(hold);
			wcscat(temp,hold);
			if ( ERROR_SUCCESS == RegQueryValueEx( hKey, temp, 0, &dwType, ( LPBYTE )value, &dwSize ) )
			{
				if (wcsicmp(value,_T("")))
				{
					hdivx=LoadLibrary(value);
					if (!hdivx)
					{
						return -1;
					}		
					DecodeMessage=(pdecode_msg)GetProcAddress((HINSTANCE)hdivx,_T("DecodeInit"));
					DecodeFrame=(pdecode_frame)GetProcAddress((HINSTANCE)hdivx,_T("DecodeFrame"));
				}
				else
				{
					hdivx=NULL;
					DropTwo=0;
				}
			}
			else
			{
				MessageBox(hWndMain,_T("This file contains an incompatible video format 1"),_T("Video Error"),MB_OK);
				vidinfo->video_frames = 0;
			}
			RegCloseKey( hKey );
		}
		else
		{
				MessageBox(hWndMain,_T("This file contains an incompatible video format 2"),_T("Video Error"),MB_OK);
				vidinfo->video_frames = 0;
		}
	}	
	if (vidinfo->video_frames==0&&(vidinfo->audio_bytes==0))
		return -1;
	if (hdivx==NULL)
	{
		DecodeMessage=(pdecode_msg)dummy_decore; 
		DecodeFrame=(pdecode_frame)dummy_decore_frame;
	}

	return 0;
}

int LoadReader()
{
	static HANDLE hmp3=NULL;
	HKEY hKey = 0;
	DWORD dwSize = 0;
	DWORD dwType = 0;
	DWORD dwTmp;
	TCHAR temp[10];
	TCHAR value[200];


	NoIndex=0;
	if (hmp3)
	{
		FreeLibrary((HINSTANCE)hmp3);
		hmp3=NULL;
	}
	GetFileExt(FileName,temp);
	if (!wcscmp(FileName,_T("Broadcast")))
	{
		hmp3=LoadLibrary(_T("BroadcastReader.dll"));
	}
	else if (wcsstr(FileName,_T(".avi"))||(wcsstr(FileName,_T(".AVI")))||(wcsstr(FileName,_T(".divx"))||(wcsstr(FileName,_T(".DIVX")))))
	{
		if (Stream||(PlayerOptions.NoIndex))
		{
			hmp3=LoadLibrary(_T("avistream.dll"));
			NoIndex=1;
		}
		else
		{
			READER_InitializeReader=InitializeReader;
			READER_InitializeReader(&rd);
			return 0;
		}
	}
	else if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_BASE_FMT, 0, 0, &hKey ) )
	{
			dwTmp = 0;
			dwSize =sizeof(value);
			wcslwr(temp);
			if ( ERROR_SUCCESS == RegQueryValueEx( hKey, temp, 0, &dwType, ( LPBYTE )value, &dwSize ) )
			{
				if (wcsicmp(value,_T("")))
				{
					hmp3=LoadLibrary(value);
				}
				else
				{
					hmp3=NULL;
					RegCloseKey( hKey );
				}
			}
			else
			{
				MessageBox(hWndMain,_T("This file is of an unknown format"),_T("Video Error"),MB_OK);
				return -1;
			}
			RegCloseKey( hKey );
	}
	else
	{
			MessageBox(hWndMain,_T("This file is of an unknown format"),_T("Video Error"),MB_OK);
			return -1;
	}
	
	
	
	
	
	if (hmp3!=NULL)
	{
		READER_InitializeReader=(pInitializeReader) GetProcAddress((HINSTANCE)hmp3,_T("InitializeReader"));
		READER_InitializeReader(&rd);
		return 0;
	}
	else
	{
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),0,(LPTSTR) &lpMsgBuf, 0, NULL );
		MessageBox( NULL, (LPCTSTR)lpMsgBuf, _T("Error loading file reader"), MB_OK | MB_ICONINFORMATION );
		LocalFree( lpMsgBuf );
		return -1;
	}
}
*/

void AddEntry(LPTSTR FileName, int pos)
{
	LVITEM lv;
	lv.mask=LVIF_TEXT;
	lv.pszText=_T("");
	lv.cchTextMax=1;
	lv.iSubItem=0;
	LPTSTR temp=FileName+wcslen(FileName);
	if (pos<0) lv.iItem=ListView_GetItemCount(hwndList);	
	else lv.iItem=pos;
	ListView_InsertItem(hwndList,&lv);
	while (temp[0]!='.')
	{
		temp--;
	}
	ListView_SetItemText(hwndList,lv.iItem,2,FileName);
	*temp=0;
	temp++;
	ListView_SetItemText(hwndList,lv.iItem,1,temp);
	while (temp[0]!='\\'&&(temp[0]!='/'))
	{
		temp--;
	}
	temp++;
	ListView_SetItemText(hwndList,lv.iItem,0,temp);
}

int WINAPI WinMain(	HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPTSTR    lpCmdLine,
					int       nCmdShow)
{
	MSG msg;
	HACCEL hAccelTable;

	// Perform application initialization:

	if (!InitInstance (hInstance, nCmdShow)) 
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_PLAYLISTEDITOR);
	if (lpCmdLine)
	{
		if (wcscmp(lpCmdLine,_T("")))
		{
			wcscpy(szPDLFile,lpCmdLine);
			if (wcsstr(szPDLFile,_T(".pdl")))
			{
				//wcscpy(file,ofn.lpstrFile);
				HANDLE h=CreateFile((LPCTSTR)szPDLFile,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
				int size=GetFileSize(h,NULL);
				unsigned long t;
				TCHAR* temp=(TCHAR*)malloc(size);
				TCHAR* EndPos=0;
				TCHAR* BeginPos=0;
				ReadFile(h,temp,size,&t,NULL);
				CloseHandle(h);
				BeginPos=temp;
				ListView_DeleteAllItems(hwndList);
				while(BeginPos<(temp+size) &&((EndPos=wcsstr(BeginPos,_T("\r")))!=NULL))
				{
					*EndPos=0;
					//SendMessage(hwndList,LB_ADDSTRING,0,(LPARAM)BeginPos);
					AddEntry(BeginPos,-1);
					BeginPos=EndPos+2;
				}
				free(temp);
			}
		}
	}

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
#ifdef GAPI
GXCloseInput();
#endif
	return msg.wParam;
}

//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    It is important to call this function so that the application 
//    will get 'well formed' small icons associated with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
{
	WNDCLASS	wc;

    wc.style			= CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc		= (WNDPROC) WndProc;
    wc.cbClsExtra		= 0;
    wc.cbWndExtra		= 0;
    wc.hInstance		= hInstance;
    wc.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_PLAYLISTEDITOR));
    wc.hCursor			= 0;
    wc.hbrBackground	= (HBRUSH) GetStockObject(WHITE_BRUSH);
    wc.lpszMenuName		= 0;
    wc.lpszClassName	= szWindowClass;

	return RegisterClass(&wc);
}

//
//  FUNCTION: InitInstance(HANDLE, int)
//
//  PURPOSE: Saves instance handle and creates main window
//
//  COMMENTS:
//
//    In this function, we save the instance handle in a global variable and
//    create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HWND	hWnd;
	TCHAR	szTitle[MAX_LOADSTRING];			// The title bar text
	TCHAR	szWindowClass[MAX_LOADSTRING];		// The window class name

	hInst = hInstance;		// Store instance handle in our global variable
	// Initialize global strings
	LoadString(hInstance, IDC_PLAYLISTEDITOR, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance, szWindowClass);

	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	if (FindWindow(szWindowClass, szTitle))
	{
	   SetForegroundWindow(FindWindow(szWindowClass, szTitle));
	   return FALSE;

⌨️ 快捷键说明

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