Archived
Massive structure rework
This commit is contained in:
1 parent
bd651ef400
commit
1e765e6306
3 files changed
+185
-117
No files matched your search
Binary file not shown.
+2
-3
@@ -12,13 +12,12 @@
|
|||||||
#define IDC_CLICKPLAY 109
|
#define IDC_CLICKPLAY 109
|
||||||
#define IDR_MAINFRAME 128
|
#define IDR_MAINFRAME 128
|
||||||
#define IDC_MENU 200
|
#define IDC_MENU 200
|
||||||
#define ID_PLIK_OD32774 32774
|
|
||||||
#define ID_REFRESH 32775
|
#define ID_REFRESH 32775
|
||||||
#define ID_OPCJE_POWTARZAJ 32777
|
#define ID_OPCJE_POWTARZAJ 32777
|
||||||
#define ID_OPCJE_ONCLICK 32778
|
#define ID_OPCJE_ONCLICK 32778
|
||||||
#define ID_OPCJE_LOOP 32779
|
#define ID_OPCJE_LOOP 32779
|
||||||
#define ID_POMOC_SKR32782 32782
|
|
||||||
#define ID_POMOC_KBSHR 32783
|
#define ID_POMOC_KBSHR 32783
|
||||||
|
#define ID_PLIK_CLOSEDIR 32786
|
||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NO_MFC 1
|
#define _APS_NO_MFC 1
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 130
|
#define _APS_NEXT_RESOURCE_VALUE 130
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32785
|
#define _APS_NEXT_COMMAND_VALUE 32789
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||||
#define _APS_NEXT_SYMED_VALUE 110
|
#define _APS_NEXT_SYMED_VALUE 110
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ using std::wstring;
|
|||||||
#define NOT_PLAYING_LABEL L"Nic nie jest odtwarzane"
|
#define NOT_PLAYING_LABEL L"Nic nie jest odtwarzane"
|
||||||
#define PLAY_LABEL L"Odtwarzaj"
|
#define PLAY_LABEL L"Odtwarzaj"
|
||||||
#define PAUSE_LABEL L"Pauza"
|
#define PAUSE_LABEL L"Pauza"
|
||||||
|
#define NO_DIR_LOADED_LABEL L"Nie wybrano folderu"
|
||||||
|
|
||||||
//GLOBAL VARS
|
//GLOBAL VARS
|
||||||
HFONT hFont = CreateFont(18, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Segoe UI"));
|
HFONT hFont = CreateFont(18, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Segoe UI"));
|
||||||
@@ -37,14 +38,15 @@ wstring selected;
|
|||||||
|
|
||||||
//STATE VARS
|
//STATE VARS
|
||||||
/*
|
/*
|
||||||
* -1 - not loaded
|
* -1 - not ready
|
||||||
* 0 - nothing is playing
|
* 0 - ready
|
||||||
* 1 - playback active
|
* 1 - playback active
|
||||||
* 2 - playback paused
|
* 2 - playback paused
|
||||||
*/
|
*/
|
||||||
int currentState = -1;
|
int currentState = -1;
|
||||||
BOOL isAutoPlayEnabled = TRUE;
|
BOOL isAutoPlayEnabled = TRUE;
|
||||||
BOOL isLoopEnabled = FALSE;
|
BOOL isLoopEnabled = FALSE;
|
||||||
|
BOOL isQueued = FALSE;
|
||||||
|
|
||||||
//CONTROLS
|
//CONTROLS
|
||||||
HWND mainWindow;
|
HWND mainWindow;
|
||||||
@@ -104,7 +106,7 @@ int WINAPI WinMain(HINSTANCE currentInst, HINSTANCE previousInst, LPSTR lpCmdLin
|
|||||||
|
|
||||||
//CREATE CONTROLS
|
//CREATE CONTROLS
|
||||||
void CreateControls(HWND window) {
|
void CreateControls(HWND window) {
|
||||||
dirLabel = CreateWindowEx(0, L"STATIC", L"Nie wybrano folderu", WS_CHILD | WS_VISIBLE, 10, 10, 250, 40, window, (HMENU)IDC_DIRLABEL, globalInstance, NULL);
|
dirLabel = CreateWindowEx(0, L"STATIC", NO_DIR_LOADED_LABEL, WS_CHILD | WS_VISIBLE, 10, 10, 250, 40, window, (HMENU)IDC_DIRLABEL, globalInstance, NULL);
|
||||||
SendMessage(dirLabel, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendMessage(dirLabel, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
browseButton = CreateWindowEx(0, L"BUTTON", L"Przegl¹daj", WS_CHILD | WS_VISIBLE, 275, 10, 100, 30, window, (HMENU)IDC_BROWSEBTN, globalInstance, NULL);
|
browseButton = CreateWindowEx(0, L"BUTTON", L"Przegl¹daj", WS_CHILD | WS_VISIBLE, 275, 10, 100, 30, window, (HMENU)IDC_BROWSEBTN, globalInstance, NULL);
|
||||||
SendMessage(browseButton, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendMessage(browseButton, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
@@ -118,21 +120,108 @@ void CreateControls(HWND window) {
|
|||||||
SendMessage(stopButton, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendMessage(stopButton, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//GET FILES FROM DIRECTORY
|
//GET SELECTED INDEX
|
||||||
void GetFiles(wstring path, wstring ext) {
|
int GetIndex() {
|
||||||
if (path[0] != NULL) {
|
LRESULT listItemsCount = SendMessage(filesListCtrl, LB_GETCOUNT, NULL, NULL);
|
||||||
wstring findPathS = path + L"\\*." + ext;
|
for (int i = 0; i < listItemsCount; i++) {
|
||||||
LPCWSTR findPath = findPathS.c_str();
|
if (SendMessage(filesListCtrl, LB_GETSEL, (WPARAM)i, NULL) > 0) {
|
||||||
WIN32_FIND_DATA data;
|
return i;
|
||||||
HANDLE hFind = FindFirstFile(findPath, &data);
|
|
||||||
|
|
||||||
if (hFind != INVALID_HANDLE_VALUE) {
|
|
||||||
do {
|
|
||||||
SendMessage(filesListCtrl, LB_ADDSTRING, NULL, (LPARAM)data.cFileName);
|
|
||||||
} while (FindNextFile(hFind, &data));
|
|
||||||
EnableWindow(filesListCtrl, TRUE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//REMOVE SELECTION
|
||||||
|
void UnloadSelection() {
|
||||||
|
mciSendString(L"close mp3", NULL, 0, mainWindow);
|
||||||
|
selected.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//LOAD SELECTION
|
||||||
|
/*
|
||||||
|
* ERROR CODES
|
||||||
|
* -1 - invalid index
|
||||||
|
* -2 - file not found
|
||||||
|
* -3 - path not loaded
|
||||||
|
*/
|
||||||
|
int LoadSelection(int index) {
|
||||||
|
UnloadSelection();
|
||||||
|
if (index != -1) {
|
||||||
|
LRESULT selectedLength = SendMessage(filesListCtrl, LB_GETTEXTLEN, (WPARAM)index, NULL);
|
||||||
|
TCHAR* selectionBuffer = new TCHAR[selectedLength];
|
||||||
|
SendMessage(filesListCtrl, LB_GETTEXT, (WPARAM)index, (LPARAM)selectionBuffer);
|
||||||
|
if (!path.empty()) {
|
||||||
|
wstring fullPath = path + L"\\" + selectionBuffer;
|
||||||
|
WIN32_FIND_DATA fileData;
|
||||||
|
HANDLE fileExist = FindFirstFile(fullPath.c_str(), &fileData);
|
||||||
|
if (fileExist == INVALID_HANDLE_VALUE) {
|
||||||
|
MessageBox(mainWindow, L"Wskazany plik nie zosta³ odnaleziony. Upewnij siê, ¿e nie zosta³ przeniesiony lub naciœnij klawisz F5, aby pozbyæ siê niedzia³aj¹cych pozycji.", L"Nie znaleziono pliku", MB_ICONERROR);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wstring fullCommandS = L"open \"" + fullPath + L"\" type mpegvideo alias mp3";
|
||||||
|
LPCWSTR fullCommand = fullCommandS.c_str();
|
||||||
|
|
||||||
|
mciSendString(fullCommand, NULL, 0, mainWindow);
|
||||||
|
selected = wstring(selectionBuffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox(mainWindow, L"Naruszenie dostêpu do stanu programu. Proces zostanie zakoñczony.", L"B³¹d krytyczny", MB_ICONERROR);
|
||||||
|
ExitProcess(0);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//UNLOAD DIRECTORY
|
||||||
|
void UnloadDir() {
|
||||||
|
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
||||||
|
path.clear();
|
||||||
|
if (!selected.empty()) {
|
||||||
|
UnloadSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//LOAD DIRECTORY
|
||||||
|
/*
|
||||||
|
* ERROR CODES
|
||||||
|
* -1 - empty string
|
||||||
|
* -2 - invalid directory
|
||||||
|
*/
|
||||||
|
int LoadDir(wstring dir) {
|
||||||
|
UnloadDir();
|
||||||
|
if (!dir.empty()) {
|
||||||
|
DWORD dirA = GetFileAttributes(dir.c_str());
|
||||||
|
if (dirA & FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
|
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
||||||
|
for (int i = 0; i < EXT_LENGTH; i++) {
|
||||||
|
wstring findPathS = dir + L"\\*." + ext[i];
|
||||||
|
LPCWSTR findPath = findPathS.c_str();
|
||||||
|
WIN32_FIND_DATA dirData;
|
||||||
|
HANDLE finder = FindFirstFile(findPath, &dirData);
|
||||||
|
if (finder != INVALID_HANDLE_VALUE) {
|
||||||
|
do {
|
||||||
|
SendMessage(filesListCtrl, LB_ADDSTRING, NULL, (LPARAM)dirData.cFileName);
|
||||||
|
} while (FindNextFile(finder, &dirData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
path = dir;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox(mainWindow, L"Program nie mo¿e uzyskaæ dostêpu do wskazanego katalogu.", L"Nieprawid³owy katalog", MB_ICONERROR);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox(mainWindow, L"Nie za³adowano folderu. U¿yj przycisku PRZEGL¥DAJ, aby za³adaowaæ katalog.", L"Brak katalogu", MB_ICONERROR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//INITALIZE FOLDER PICKER
|
//INITALIZE FOLDER PICKER
|
||||||
@@ -145,52 +234,20 @@ BOOL FolderBrowseDialog(HWND window) {
|
|||||||
TCHAR currentPath[MAX_PATH];
|
TCHAR currentPath[MAX_PATH];
|
||||||
if (pid != 0) {
|
if (pid != 0) {
|
||||||
SHGetPathFromIDList(pid, currentPath);
|
SHGetPathFromIDList(pid, currentPath);
|
||||||
path = wstring(currentPath);
|
if (LoadDir((wstring)currentPath) == 0) {
|
||||||
SetCurrentDirectory(path.c_str());
|
SetCurrentDirectory(path.c_str());
|
||||||
SetWindowText(dirLabel, path.c_str());
|
SetWindowText(dirLabel, path.c_str());
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MCI PROCESSOR
|
|
||||||
void Play(wstring path, wstring fileName) {
|
|
||||||
if (path[0] != NULL && selected.empty() == false) {
|
|
||||||
//STOP PREVIOUS PLAYBACKS
|
|
||||||
mciSendString(L"close mp3", NULL, 0, NULL);
|
|
||||||
|
|
||||||
//GET PATH
|
|
||||||
wstring fullPath = path + L"\\" + selected;
|
|
||||||
WIN32_FIND_DATA fileData;
|
|
||||||
HANDLE fileExist = FindFirstFile(fullPath.c_str(), &fileData);
|
|
||||||
if (fileExist == INVALID_HANDLE_VALUE) {
|
|
||||||
MessageBox(mainWindow, L"Podany plik nie zosta³ odnaleziony. Upewnij siê, ¿e plik istnieje lub nie zosta³ przeniesiony.", L"Nie znaleziono pliku", MB_ICONERROR);
|
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//PROCESS COMMAND
|
|
||||||
wstring fullCommandS = L"open \"" + fullPath + L"\" type mpegvideo alias mp3";
|
|
||||||
LPCWSTR fullCommand = fullCommandS.c_str();
|
|
||||||
|
|
||||||
//PLAY THE SOUND
|
|
||||||
mciSendString(fullCommand, NULL, 0, NULL);
|
|
||||||
if (isLoopEnabled) {
|
|
||||||
mciSendString(L"play mp3 repeat", NULL, 0, mainWindow);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mciSendString(L"play mp3 notify", NULL, 0, mainWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox(mainWindow, L"Podczas odtwarzania wyst¹pi³ b³¹d. SprawdŸ czy podany plik istnieje.", L"Wyst¹pi³ b³¹d", MB_ICONERROR);
|
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//MESSAGE LOOP
|
//MESSAGE LOOP
|
||||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
int windowId, windowEvent;
|
int windowId, windowEvent;
|
||||||
@@ -211,58 +268,40 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||||||
switch (windowId) {
|
switch (windowId) {
|
||||||
case IDC_BROWSEBTN:
|
case IDC_BROWSEBTN:
|
||||||
if (FolderBrowseDialog(mainWindow) == TRUE) {
|
if (FolderBrowseDialog(mainWindow) == TRUE) {
|
||||||
mciSendString(L"close mp3", NULL, 0, NULL);
|
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
||||||
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
|
||||||
for (int i = 0; i < EXT_LENGTH; i++) {
|
|
||||||
GetFiles(path, ext[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDC_LIST:
|
case IDC_LIST:
|
||||||
if (windowEvent == LBN_SELCHANGE) {
|
if (windowEvent == LBN_SELCHANGE) {
|
||||||
LRESULT listItemsCount = SendMessage(filesListCtrl, LB_GETCOUNT, NULL, NULL);
|
if (currentState == 1 || currentState == 2) { currentState = 1; isQueued = TRUE; }
|
||||||
int selectedItemIndex = -1;
|
if (LoadSelection(GetIndex()) == 0) {
|
||||||
for (int i = 0; i < listItemsCount; i++) {
|
if (isAutoPlayEnabled == TRUE) {
|
||||||
if (SendMessage(filesListCtrl, LB_GETSEL, (WPARAM)i, NULL) > 0) {
|
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
||||||
selectedItemIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectedItemIndex != -1) {
|
|
||||||
LRESULT selectedLength = SendMessage(filesListCtrl, LB_GETTEXTLEN, (WPARAM)selectedItemIndex, NULL);
|
|
||||||
TCHAR* selectionBuffer = new TCHAR[selectedLength];
|
|
||||||
SendMessage(filesListCtrl, LB_GETTEXT, (WPARAM)selectedItemIndex, (LPARAM)selectionBuffer);
|
|
||||||
selected = wstring(selectionBuffer);
|
|
||||||
}
|
|
||||||
if (isAutoPlayEnabled == TRUE) {
|
|
||||||
Play(path, selected);
|
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (windowEvent == LBN_SELCANCEL) {
|
|
||||||
selected.clear();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDC_PLAYBTN:
|
case IDC_PLAYBTN:
|
||||||
switch (currentState) {
|
switch (currentState) {
|
||||||
case 0:
|
case 0:
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
if (LoadSelection(GetIndex()) == 0) {
|
||||||
Play(path, selected);
|
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox(mainWindow, L"Podczas odtwarzania wyst¹pi³ b³¹d", L"B³¹d odtwarzacza", MB_ICONERROR);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 2, NULL);
|
SendMessage(mainWindow, STATE_CHANGE, 2, NULL);
|
||||||
mciSendString(L"pause mp3", NULL, 0, NULL);
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
||||||
mciSendString(L"resume mp3", NULL, 0, NULL);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDC_STOPBTN:
|
case IDC_STOPBTN:
|
||||||
mciSendString(L"close mp3", NULL, 0, NULL);
|
isQueued = FALSE;
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
SendMessage(mainWindow, MM_MCINOTIFY, 0, 0);
|
||||||
break;
|
break;
|
||||||
case IDM_EXIT:
|
case IDM_EXIT:
|
||||||
SendMessage(mainWindow, WM_CLOSE, NULL, NULL);
|
SendMessage(mainWindow, WM_CLOSE, NULL, NULL);
|
||||||
@@ -271,15 +310,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||||||
DialogBox(globalInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), mainWindow, About);
|
DialogBox(globalInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), mainWindow, About);
|
||||||
break;
|
break;
|
||||||
case ID_REFRESH:
|
case ID_REFRESH:
|
||||||
if (path[0] != NULL) {
|
LoadDir(path);
|
||||||
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
|
||||||
for (int i = 0; i < EXT_LENGTH; i++) {
|
|
||||||
GetFiles(path, ext[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MessageBox(mainWindow, L"Nie za³adowano folderu. Naciœnij przycisk PRZEGL¥DAJ, aby wczytaæ katalog.", L"Brak katalogu", MB_ICONERROR);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ID_OPCJE_ONCLICK:
|
case ID_OPCJE_ONCLICK:
|
||||||
if (isAutoPlayEnabled) {
|
if (isAutoPlayEnabled) {
|
||||||
@@ -304,44 +335,81 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||||||
case ID_POMOC_KBSHR:
|
case ID_POMOC_KBSHR:
|
||||||
MessageBox(mainWindow, L"F1 = ekran skrótów klawiszowych\nF2 = ekran Informacje\nF5 = odœwie¿ listê plików", L"Skróty klawiszowe", MB_ICONASTERISK);
|
MessageBox(mainWindow, L"F1 = ekran skrótów klawiszowych\nF2 = ekran Informacje\nF5 = odœwie¿ listê plików", L"Skróty klawiszowe", MB_ICONASTERISK);
|
||||||
break;
|
break;
|
||||||
|
case ID_PLIK_CLOSEDIR:
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, -1, NULL);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MM_MCINOTIFY:
|
case MM_MCINOTIFY:
|
||||||
mciSendString(L"close mp3", NULL, 0, NULL);
|
if (!isQueued) {
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
UnloadSelection();
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isQueued = FALSE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_CHANGE:
|
case STATE_CHANGE:
|
||||||
currentState = (int)wParam;
|
switch ((int)wParam) {
|
||||||
switch (currentState) {
|
|
||||||
case -1:
|
case -1:
|
||||||
|
UnloadSelection();
|
||||||
|
UnloadDir();
|
||||||
|
|
||||||
EnableWindow(filesListCtrl, FALSE);
|
EnableWindow(filesListCtrl, FALSE);
|
||||||
EnableWindow(playButton, FALSE);
|
EnableWindow(playButton, FALSE);
|
||||||
EnableWindow(stopButton, FALSE);
|
EnableWindow(stopButton, FALSE);
|
||||||
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
||||||
|
SetWindowText(dirLabel, NO_DIR_LOADED_LABEL);
|
||||||
SetWindowText(npLabel, L"-");
|
SetWindowText(npLabel, L"-");
|
||||||
SetWindowText(playButton, PLAY_LABEL);
|
SetWindowText(playButton, PLAY_LABEL);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
EnableWindow(filesListCtrl, TRUE);
|
if (!path.empty()) {
|
||||||
EnableWindow(playButton, TRUE);
|
EnableWindow(filesListCtrl, TRUE);
|
||||||
EnableWindow(stopButton, TRUE);
|
EnableWindow(playButton, TRUE);
|
||||||
EnableMenuItem(menuBar, ID_REFRESH, MF_ENABLED);
|
EnableWindow(stopButton, TRUE);
|
||||||
SetWindowText(npLabel, NOT_PLAYING_LABEL);
|
EnableMenuItem(menuBar, ID_REFRESH, MF_ENABLED);
|
||||||
SetWindowText(playButton, PLAY_LABEL);
|
SetWindowText(npLabel, NOT_PLAYING_LABEL);
|
||||||
break;
|
SetWindowText(playButton, PLAY_LABEL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, -1, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 1:
|
case 1:
|
||||||
EnableWindow(filesListCtrl, FALSE);
|
if (!path.empty() && !selected.empty()) {
|
||||||
EnableWindow(playButton, TRUE);
|
if (currentState == 2) {
|
||||||
EnableWindow(stopButton, TRUE);
|
mciSendString(L"resume mp3", NULL, 0, mainWindow);
|
||||||
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
}
|
||||||
SetWindowText(npLabel, selected.c_str());
|
else {
|
||||||
SetWindowText(playButton, PAUSE_LABEL);
|
if (isLoopEnabled) {
|
||||||
break;
|
mciSendString(L"play mp3 repeat", NULL, 0, mainWindow);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mciSendString(L"play mp3 notify", NULL, 0, mainWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableWindow(filesListCtrl, TRUE);
|
||||||
|
EnableWindow(playButton, TRUE);
|
||||||
|
EnableWindow(stopButton, TRUE);
|
||||||
|
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
||||||
|
SetWindowText(npLabel, selected.c_str());
|
||||||
|
SetWindowText(playButton, PAUSE_LABEL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 2:
|
case 2:
|
||||||
|
mciSendString(L"pause mp3", NULL, 0, mainWindow);
|
||||||
|
|
||||||
wstring pauseStringWS = selected + L" [PAUZA]";
|
wstring pauseStringWS = selected + L" [PAUZA]";
|
||||||
LPCWSTR pauseString = pauseStringWS.c_str();
|
LPCWSTR pauseString = pauseStringWS.c_str();
|
||||||
|
|
||||||
EnableWindow(filesListCtrl, FALSE);
|
EnableWindow(filesListCtrl, TRUE);
|
||||||
EnableWindow(playButton, TRUE);
|
EnableWindow(playButton, TRUE);
|
||||||
EnableWindow(stopButton, TRUE);
|
EnableWindow(stopButton, TRUE);
|
||||||
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
||||||
@@ -349,6 +417,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||||||
SetWindowText(playButton, L"Wznów");
|
SetWindowText(playButton, L"Wznów");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
currentState = (int)wParam;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
|||||||
Reference in new issue
Block a user