?? main.cpp
字號:
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(): *
* *
* ———加入(如果可以)一個條目到文件鏈表 *
* *
**************************************************************************************/
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(): *
* *
* ———設(shè)置桌面模式 *
* *
**************************************************************************************/
void PrepareDesktopMode() {
HRESULT hr;
IActiveDesktop *pActiveDesktop;
/*
* 活動桌面填充
* --------------------
*/
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();
}
/*
* 標準填充
* --------------
*/
COLORREF colorref;
INT background;
background = COLOR_DESKTOP;
colorref = DD_OVERLAY_COLORREF;
/*
* 得到設(shè)置
*/
backColor = GetSysColor(COLOR_DESKTOP);
/*
* 設(shè)置
*/
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "", 0);
SetSysColors(1, &background, &colorref);
}
/**************************************************************************************
* *
* - UnPreparesDesktopMode(): *
* *
* ———取消桌面模式的設(shè)置 *
* *
**************************************************************************************/
void UnPrepareDesktopMode() {
HRESULT hr;
IActiveDesktop *pActiveDesktop;
/*
* 活動桌面填充
* --------------------
*/
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填充
*/
INT background = COLOR_DESKTOP;
SetSysColors(1, &background, &backColor);
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, 0);
playback->SetDesktopMode(FALSE);
}
/**************************************************************************************
* *
* - PrepareCompactMode(): *
* *
* ———設(shè)置桌面模型 *
* *
**************************************************************************************/
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(): *
* *
* ———取消桌面模式的設(shè)置 *
* *
**************************************************************************************/
void UnPrepareCompactMode() {
HMENU menu;
MENUITEMINFO itemInfo;
compact_mode = 0;
skin->SetCompact(FALSE);
/*
* 改變菜單項文本
*/
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);
/*
* 調(diào)整窗口大小
*/
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(): *
* *
* ———重新產(chǎn)生播放鏈表浮動菜單 *
* *
**************************************************************************************/
void ChangeMenuForNormalMode()
{
HMENU menu;
menu = GetSubMenu(popupMenu, 0);
/*
* 字幕及其屬性菜單
*/
MENUITEMINFO itemInfo;
/*
* 更新菜單項
*/
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(): *
* *
* ———重新產(chǎn)生播放鏈表浮動菜單 *
* *
**************************************************************************************/
void ChangeMenuForFullscreenMode()
{
HMENU menu;
MENUITEMINFO itemInfo;
GetWindowRect(hwnd, &fullwindowRect);
/*
* 使某些項無效
*/
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(): *
* *
* ———重新產(chǎn)生播放鏈表浮動菜單 *
* *
**************************************************************************************/
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);
}
/*
* 增加標準項
*
*/
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);
/*
* 增加文件
*/
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);
}
/*
* 選擇當前的項
*
*/
CheckMenuItem(menu, ID_PLAYLIST1 + playlist->GetCurrentPosition(), MF_CHECKED);
}
/**************************************************************************************
* *
* - UpdateMainWindow(): *
* *
* ———重新繪制主窗口 *
* *
**************************************************************************************/
void UpdateMainWindow()
{
RECT rect;
GetClientRect(hwnd, &rect);
InvalidateRect(hwnd, &rect, TRUE);
UpdateWindow(hwnd);
}
/**************************************************************************************
* *
* 退出 *
* -------- *
**************************************************************************************/
void Quit()
{
SaveOptions();
playback->Close();
if(playback->desktopMode) {
UnPrepareDesktopMode();
}
if(options.disable_screen_saver) {
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, screenSaverActive, NULL, 0);
}
Cleanup();
PostQuitMessage(0);
}
/**************************************************************************************
* *
* - WinMain(): *
* *
* ———程序入口 *
* *
**************************************************************************************/
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -