Archived
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f39765877 | ||
|
|
6a327c46f3 | ||
|
|
d8649831f8 | ||
|
|
4539a489a4 | ||
|
|
b66955d5b4 | ||
|
|
af56fe3338 | ||
|
|
d536b187ec | ||
|
|
699935c9f8 | ||
|
|
e463cdab73 | ||
|
|
5b6da80ec2 | ||
|
|
f44f57150b | ||
|
|
1a3b31ec9e | ||
|
|
a7daecd589 | ||
|
|
fe27bb453c | ||
|
|
7708e43b3d | ||
|
|
bf1d86772a | ||
|
|
7088df85e1 | ||
|
|
a8622f8ea4 | ||
|
|
1d4699a29b | ||
|
|
87c147685b | ||
|
|
b32774b6f1 | ||
|
|
cb02cddfb5 | ||
|
|
936e512859 | ||
|
|
1e765e6306 |
No files matched your search
Binary file not shown.
@@ -8,19 +8,13 @@ EndProject
|
|||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
Debug|x86 = Debug|x86
|
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
Release|x86 = Release|x86
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Debug|x64.ActiveCfg = Debug|x64
|
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Debug|x64.Build.0 = Debug|x64
|
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Debug|x64.Build.0 = Debug|x64
|
||||||
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Debug|x86.ActiveCfg = Debug|Win32
|
|
||||||
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Debug|x86.Build.0 = Debug|Win32
|
|
||||||
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Release|x64.ActiveCfg = Release|x64
|
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Release|x64.ActiveCfg = Release|x64
|
||||||
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Release|x64.Build.0 = Release|x64
|
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Release|x64.Build.0 = Release|x64
|
||||||
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Release|x86.ActiveCfg = Release|Win32
|
|
||||||
{C734FDA7-262E-4202-8F4E-5E3031CB9935}.Release|x86.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Visual C++ generated include file.
|
|
||||||
// Used by ClickPlay.rc
|
|
||||||
//
|
|
||||||
#define IDD_CLICKPLAY_DIALOG 102
|
|
||||||
#define IDS_APP_TITLE 103
|
|
||||||
#define IDD_ABOUTBOX 103
|
|
||||||
#define IDM_ABOUT 104
|
|
||||||
#define IDM_EXIT 105
|
|
||||||
#define IDI_CLICKPLAY 107
|
|
||||||
#define IDI_SMALL 108
|
|
||||||
#define IDC_CLICKPLAY 109
|
|
||||||
#define IDR_MAINFRAME 128
|
|
||||||
#define IDC_MENU 200
|
|
||||||
#define ID_PLIK_OD32774 32774
|
|
||||||
#define ID_REFRESH 32775
|
|
||||||
#define ID_OPCJE_POWTARZAJ 32777
|
|
||||||
#define ID_OPCJE_ONCLICK 32778
|
|
||||||
#define ID_OPCJE_LOOP 32779
|
|
||||||
#define ID_POMOC_SKR32782 32782
|
|
||||||
#define ID_POMOC_KBSHR 32783
|
|
||||||
#define IDC_STATIC -1
|
|
||||||
|
|
||||||
// Next default values for new objects
|
|
||||||
//
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
#define _APS_NO_MFC 1
|
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 130
|
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32785
|
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
|
||||||
#define _APS_NEXT_SYMED_VALUE 110
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@@ -3,17 +3,25 @@
|
|||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include <ShlObj.h>
|
#include <ShlObj.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cwctype>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
//IMPORTS
|
//IMPORTS
|
||||||
using std::wstring;
|
using std::wstring;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
//CONTROL IDS
|
//CONTROL IDS
|
||||||
#define IDC_DIRLABEL 201
|
#define IDC_DIRLABEL 201
|
||||||
#define IDC_BROWSEBTN 202
|
#define IDC_BROWSEBTN 202
|
||||||
#define IDC_LIST 203
|
#define IDC_LIST 203
|
||||||
#define IDC_NPLABEL 204
|
#define IDC_SEARCH 204
|
||||||
#define IDC_PLAYBTN 205
|
#define IDC_SEARCHBTN 205
|
||||||
#define IDC_STOPBTN 206
|
#define IDC_NPLABEL 206
|
||||||
|
#define IDC_PLAYBTN 207
|
||||||
|
#define IDC_STOPBTN 208
|
||||||
|
|
||||||
//STATIC DEFINES
|
//STATIC DEFINES
|
||||||
#define EXT_LENGTH 2
|
#define EXT_LENGTH 2
|
||||||
@@ -21,9 +29,10 @@ using std::wstring;
|
|||||||
|
|
||||||
//STRING TABLE
|
//STRING TABLE
|
||||||
#define PROGRAM_NAME L"ClickPlay"
|
#define PROGRAM_NAME L"ClickPlay"
|
||||||
#define NOT_PLAYING_LABEL L"Nic nie jest odtwarzane"
|
#define NOT_PLAYING_LABEL L"-"
|
||||||
#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"Brak katalogu"
|
||||||
|
|
||||||
//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"));
|
||||||
@@ -32,25 +41,31 @@ MSG msg;
|
|||||||
wstring ext[EXT_LENGTH] = { L"mp3", L"wav" };
|
wstring ext[EXT_LENGTH] = { L"mp3", L"wav" };
|
||||||
|
|
||||||
//PATH VARS
|
//PATH VARS
|
||||||
|
vector<WIN32_FIND_DATA> files;
|
||||||
wstring path;
|
wstring path;
|
||||||
wstring selected;
|
double selected = -1;
|
||||||
|
|
||||||
//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 isOnClickPlayEnabled = TRUE;
|
||||||
|
BOOL isAutoPlayEnabled = FALSE;
|
||||||
BOOL isLoopEnabled = FALSE;
|
BOOL isLoopEnabled = FALSE;
|
||||||
|
BOOL isQueued = FALSE;
|
||||||
|
BOOL showExtensions = FALSE;
|
||||||
|
|
||||||
//CONTROLS
|
//CONTROLS
|
||||||
HWND mainWindow;
|
HWND mainWindow;
|
||||||
HWND dirLabel;
|
HWND dirLabel;
|
||||||
HWND browseButton;
|
HWND browseButton;
|
||||||
HWND filesListCtrl;
|
HWND filesListCtrl;
|
||||||
|
HWND searchBox;
|
||||||
|
HWND searchBtn;
|
||||||
HWND playButton;
|
HWND playButton;
|
||||||
HWND stopButton;
|
HWND stopButton;
|
||||||
HWND npLabel;
|
HWND npLabel;
|
||||||
@@ -59,6 +74,7 @@ HMENU menuBar;
|
|||||||
//HOOKS
|
//HOOKS
|
||||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
bool alphabeticSort(WIN32_FIND_DATA a, WIN32_FIND_DATA b);
|
||||||
|
|
||||||
//ENTRY POINT
|
//ENTRY POINT
|
||||||
int WINAPI WinMain(HINSTANCE currentInst, HINSTANCE previousInst, LPSTR lpCmdLine, int nCmdShow) {
|
int WINAPI WinMain(HINSTANCE currentInst, HINSTANCE previousInst, LPSTR lpCmdLine, int nCmdShow) {
|
||||||
@@ -104,13 +120,18 @@ 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);
|
||||||
filesListCtrl = CreateWindowEx(0, L"LISTBOX", NULL, LBS_STANDARD | WS_CHILD | WS_VISIBLE | WS_VSCROLL, 0, 50, 400, 425, window, (HMENU)IDC_LIST, globalInstance, NULL);
|
filesListCtrl = CreateWindowEx(0, L"LISTBOX", NULL, LBS_NOTIFY | LBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE | WS_VSCROLL, 0, 50, 380, 425, window, (HMENU)IDC_LIST, globalInstance, NULL);
|
||||||
SendMessage(filesListCtrl, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendMessage(filesListCtrl, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
npLabel = CreateWindowEx(0, L"STATIC", NOT_PLAYING_LABEL, SS_CENTER | WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, -5, 460, 400, 40, window, (HMENU)IDC_NPLABEL, globalInstance, NULL);
|
searchBox = CreateWindowEx(0, L"EDIT", L"", WS_CHILD | WS_VISIBLE, 0, 460, 300, 25, window, (HMENU)IDC_SEARCH, globalInstance, NULL);
|
||||||
|
SendMessage(searchBox, EM_SETCUEBANNER, FALSE, (LPARAM)L"Wyszukaj pliki...");
|
||||||
|
SendMessage(searchBox, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
|
searchBtn = CreateWindowEx(0, L"BUTTON", L"Szukaj", WS_CHILD | WS_VISIBLE, 300, 460, 80, 25, window, (HMENU)IDC_SEARCHBTN, globalInstance, NULL);
|
||||||
|
SendMessage(searchBtn, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
|
npLabel = CreateWindowEx(0, L"STATIC", NOT_PLAYING_LABEL, SS_CENTER | WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, -5, 485, 400, 25, window, (HMENU)IDC_NPLABEL, globalInstance, NULL);
|
||||||
SendMessage(npLabel, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendMessage(npLabel, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
playButton = CreateWindowEx(0, L"BUTTON", PLAY_LABEL, WS_CHILD | WS_VISIBLE, 75, 515, 100, 30, window, (HMENU)IDC_PLAYBTN, globalInstance, NULL);
|
playButton = CreateWindowEx(0, L"BUTTON", PLAY_LABEL, WS_CHILD | WS_VISIBLE, 75, 515, 100, 30, window, (HMENU)IDC_PLAYBTN, globalInstance, NULL);
|
||||||
SendMessage(playButton, WM_SETFONT, (WPARAM)hFont, TRUE);
|
SendMessage(playButton, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
@@ -118,82 +139,198 @@ 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 = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//LOAD SELECTION
|
||||||
|
/*
|
||||||
|
* ERROR CODES
|
||||||
|
* -1 - invalid index
|
||||||
|
* -2 - file not found
|
||||||
|
* -3 - path not loaded
|
||||||
|
* -4 - file loading error
|
||||||
|
*/
|
||||||
|
int LoadSelection(int index) {
|
||||||
|
UnloadSelection();
|
||||||
|
if (index >= 0) {
|
||||||
|
if (!path.empty()) {
|
||||||
|
wstring fullPath = path + L"\\" + wstring(files[index].cFileName);
|
||||||
|
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 usuniêty. Naciœnij klawisz F5, aby odœwie¿yæ listê i 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();
|
||||||
|
|
||||||
|
if (mciSendString(fullCommand, NULL, 0, mainWindow) != 0) {
|
||||||
|
MessageBox(mainWindow, L"Nieznany b³¹d uniemo¿liwia odtworzenie tego pliku. SprawdŸ czy plik nie jest uszkodzony.", L"B³¹d wczytywania", MB_ICONERROR);
|
||||||
|
UnloadSelection();
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
selected = index;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILL THE LIST BOX
|
||||||
|
void GenerateList(vector<WIN32_FIND_DATA> list) {
|
||||||
|
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
wstring fileName = list[i].cFileName;
|
||||||
|
if (!showExtensions) {
|
||||||
|
int dotPos = fileName.find_last_of('.');
|
||||||
|
fileName.erase(dotPos, 4);
|
||||||
|
}
|
||||||
|
SendMessage(filesListCtrl, LB_ADDSTRING, NULL, (LPARAM)fileName.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//UNLOAD DIRECTORY
|
||||||
|
void UnloadDir() {
|
||||||
|
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
||||||
|
path.clear();
|
||||||
|
files.clear();
|
||||||
|
if (selected != -1) {
|
||||||
|
UnloadSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//LOAD DIRECTORY
|
||||||
|
/*
|
||||||
|
* ERROR CODES
|
||||||
|
* -1 - empty string
|
||||||
|
* -2 - invalid directory
|
||||||
|
* -3 - empty directory
|
||||||
|
*/
|
||||||
|
int LoadDir(wstring dir) {
|
||||||
|
UnloadDir();
|
||||||
|
if (!dir.empty()) {
|
||||||
|
DWORD dirA = GetFileAttributes(dir.c_str());
|
||||||
|
if (dirA & FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
|
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 {
|
||||||
|
files.push_back(dirData);
|
||||||
|
} while (FindNextFile(finder, &dirData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (files.empty()) {
|
||||||
|
MessageBox(mainWindow, L"Wygl¹da na to, ¿e w tym katalogu nie ma ¿adnych plików, które mog¹ zostaæ otwarte przez program. Wybierz inny folder i spróbuj ponownie.", L"Brak plików", MB_ICONEXCLAMATION);
|
||||||
|
files.clear();
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
std::sort(files.begin(), files.end(), alphabeticSort);
|
||||||
|
GenerateList(files);
|
||||||
|
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 wczytano katalogu. U¿yj przycisku PRZEGL¥DAJ, aby za³adaowaæ katalog.", L"Brak katalogu", MB_ICONERROR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//INITALIZE FOLDER PICKER
|
//INITALIZE FOLDER PICKER
|
||||||
BOOL FolderBrowseDialog(HWND window) {
|
int FolderBrowseDialog(HWND window) {
|
||||||
BROWSEINFO dialog = { 0 };
|
BROWSEINFO dialog = { 0 };
|
||||||
dialog.hwndOwner = window;
|
dialog.hwndOwner = window;
|
||||||
dialog.ulFlags = BIF_NEWDIALOGSTYLE;
|
dialog.ulFlags = BIF_NEWDIALOGSTYLE;
|
||||||
dialog.lpszTitle = L"Wybierz folder, który ma zostaæ otwarty przez program";
|
dialog.lpszTitle = L"Wybierz katalog, który ma zostaæ otwarty przez program...";
|
||||||
LPITEMIDLIST pid = SHBrowseForFolder(&dialog);
|
LPITEMIDLIST pid = SHBrowseForFolder(&dialog);
|
||||||
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 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return FALSE;
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MCI PROCESSOR
|
//SEARCH DIRECTORY
|
||||||
void Play(wstring path, wstring fileName) {
|
void SearchDir(wstring phrase) {
|
||||||
if (path[0] != NULL && selected.empty() == false) {
|
//PERFORM CHECKING
|
||||||
//STOP PREVIOUS PLAYBACKS
|
if (path.empty()) {
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
|
//RELOAD DIR
|
||||||
//PROCESS COMMAND
|
LoadDir(path);
|
||||||
wstring fullCommandS = L"open \"" + fullPath + L"\" type mpegvideo alias mp3";
|
//PREPARE
|
||||||
LPCWSTR fullCommand = fullCommandS.c_str();
|
if (phrase.empty()) {
|
||||||
|
|
||||||
//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;
|
return;
|
||||||
}
|
}
|
||||||
|
vector<WIN32_FIND_DATA> results;
|
||||||
|
//GET FILES
|
||||||
|
for (int i = 0; i < files.size(); i++) {
|
||||||
|
if (wstring(files[i].cFileName).find(phrase) != wstring::npos) {
|
||||||
|
results.push_back(files[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (results.empty()) {
|
||||||
|
MessageBox(mainWindow, L"Nie znaleziono plików zawieraj¹cych wpisan¹ frazê.", L"Brak plików", MB_ICONEXCLAMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::sort(results.begin(), results.end(), alphabeticSort);
|
||||||
|
files = results;
|
||||||
|
//ADD FILTERED CONTENT
|
||||||
|
GenerateList(files);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET SEARCH PHRASE FROM searchBox
|
||||||
|
wstring GetSearchPhrase() {
|
||||||
|
double searchLength = SendMessage(searchBox, WM_GETTEXTLENGTH, 0, NULL);
|
||||||
|
TCHAR* searchPhrase = new TCHAR[searchLength + 1];
|
||||||
|
SendMessage(searchBox, WM_GETTEXT, searchLength + 1, (LPARAM)searchPhrase);
|
||||||
|
searchPhrase[(int)searchLength] = _T('\0');
|
||||||
|
return wstring(searchPhrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
//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, randIndex;
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
@@ -209,59 +346,49 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||||||
windowEvent = HIWORD(wParam);
|
windowEvent = HIWORD(wParam);
|
||||||
|
|
||||||
switch (windowId) {
|
switch (windowId) {
|
||||||
|
case ID_PLIK_OPENDIR:
|
||||||
case IDC_BROWSEBTN:
|
case IDC_BROWSEBTN:
|
||||||
if (FolderBrowseDialog(mainWindow) == TRUE) {
|
switch (FolderBrowseDialog(mainWindow)) {
|
||||||
mciSendString(L"close mp3", NULL, 0, NULL);
|
case 0:
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
||||||
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
break;
|
||||||
for (int i = 0; i < EXT_LENGTH; i++) {
|
case -2:
|
||||||
GetFiles(path, ext[i]);
|
SendMessage(mainWindow, STATE_CHANGE, -1, NULL);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
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 (isOnClickPlayEnabled == TRUE) {
|
||||||
if (SendMessage(filesListCtrl, LB_GETSEL, (WPARAM)i, NULL) > 0) {
|
|
||||||
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);
|
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (windowEvent == LBN_SELCANCEL) {
|
|
||||||
selected.clear();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case IDC_SEARCHBTN:
|
||||||
|
SearchDir(GetSearchPhrase());
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
|
||||||
|
break;
|
||||||
case IDC_PLAYBTN:
|
case IDC_PLAYBTN:
|
||||||
switch (currentState) {
|
switch (currentState) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (LoadSelection(GetIndex()) == 0) {
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
|
||||||
Play(path, selected);
|
}
|
||||||
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;
|
||||||
|
UnloadSelection();
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
||||||
break;
|
break;
|
||||||
case IDM_EXIT:
|
case IDM_EXIT:
|
||||||
@@ -271,24 +398,21 @@ 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) {
|
if (LoadDir(path) != 0) {
|
||||||
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
SendMessage(mainWindow, STATE_CHANGE, -1, 0);
|
||||||
for (int i = 0; i < EXT_LENGTH; i++) {
|
|
||||||
GetFiles(path, ext[i]);
|
|
||||||
}
|
}
|
||||||
}
|
if (SendMessage(searchBox, WM_GETTEXTLENGTH, 0, 0) > 0) {
|
||||||
else {
|
SearchDir(GetSearchPhrase());
|
||||||
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 (isOnClickPlayEnabled) {
|
||||||
CheckMenuItem(menuBar, ID_OPCJE_ONCLICK, MF_UNCHECKED);
|
CheckMenuItem(menuBar, ID_OPCJE_ONCLICK, MF_UNCHECKED);
|
||||||
isAutoPlayEnabled = FALSE;
|
isOnClickPlayEnabled = FALSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CheckMenuItem(menuBar, ID_OPCJE_ONCLICK, MF_CHECKED);
|
CheckMenuItem(menuBar, ID_OPCJE_ONCLICK, MF_CHECKED);
|
||||||
isAutoPlayEnabled = TRUE;
|
isOnClickPlayEnabled = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ID_OPCJE_LOOP:
|
case ID_OPCJE_LOOP:
|
||||||
@@ -300,55 +424,189 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||||||
CheckMenuItem(menuBar, ID_OPCJE_LOOP, MF_CHECKED);
|
CheckMenuItem(menuBar, ID_OPCJE_LOOP, MF_CHECKED);
|
||||||
isLoopEnabled = TRUE;
|
isLoopEnabled = TRUE;
|
||||||
}
|
}
|
||||||
|
UnloadSelection();
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
|
||||||
break;
|
break;
|
||||||
case ID_POMOC_KBSHR:
|
case ID_OPCJE_SHOWEXT:
|
||||||
MessageBox(mainWindow, L"F1 = ekran skrótów klawiszowych\nF2 = ekran Informacje\nF5 = odœwie¿ listê plików", L"Skróty klawiszowe", MB_ICONASTERISK);
|
if (showExtensions) {
|
||||||
|
CheckMenuItem(menuBar, ID_OPCJE_SHOWEXT, MF_UNCHECKED);
|
||||||
|
showExtensions = FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CheckMenuItem(menuBar, ID_OPCJE_SHOWEXT, MF_CHECKED);
|
||||||
|
showExtensions = TRUE;
|
||||||
|
}
|
||||||
|
if (!path.empty() && !files.empty()) {
|
||||||
|
GenerateList(files);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ID_PLIK_CLOSEDIR:
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, -1, NULL);
|
||||||
|
break;
|
||||||
|
case ID_AKCJE_SRCLEAR:
|
||||||
|
SendMessage(searchBox, WM_SETTEXT, (WPARAM)L"", 0);
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
|
||||||
|
if (LoadDir(path) != 0) {
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, -1, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ID_AKCJE_RANDOM:
|
||||||
|
if (currentState == 1) {
|
||||||
|
isQueued = TRUE;
|
||||||
|
}
|
||||||
|
//GET SEED
|
||||||
|
srand(time(NULL));
|
||||||
|
//LOAD AND PLAY
|
||||||
|
randIndex = rand() % files.size();
|
||||||
|
LoadSelection(randIndex);
|
||||||
|
SendMessage(filesListCtrl, LB_SETCURSEL, randIndex, 0);
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 1, 0);
|
||||||
|
break;
|
||||||
|
case ID_OPCJE_AUTOPLAY:
|
||||||
|
if (isAutoPlayEnabled) {
|
||||||
|
CheckMenuItem(menuBar, ID_OPCJE_AUTOPLAY, MF_UNCHECKED);
|
||||||
|
isAutoPlayEnabled = FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CheckMenuItem(menuBar, ID_OPCJE_AUTOPLAY, MF_CHECKED);
|
||||||
|
isAutoPlayEnabled = TRUE;
|
||||||
|
}
|
||||||
|
UnloadSelection();
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MM_MCINOTIFY:
|
case MM_MCINOTIFY:
|
||||||
mciSendString(L"close mp3", NULL, 0, NULL);
|
if (!isQueued) {
|
||||||
|
if (isAutoPlayEnabled) {
|
||||||
|
if (selected != -1 && !(selected + 1 > files.size() - 1)) {
|
||||||
|
if (LoadSelection(selected + 1) == 0) {
|
||||||
|
SendMessage(filesListCtrl, LB_SETCURSEL, selected, 0);
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 1, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(isLoopEnabled && selected != -1) {
|
||||||
|
if (LoadSelection(0) == 0) {
|
||||||
|
SendMessage(filesListCtrl, LB_SETCURSEL, selected, 0);
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 1, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (selected != -1) {
|
||||||
|
UnloadSelection();
|
||||||
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (selected != -1) {
|
||||||
|
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);
|
||||||
|
EnableWindow(searchBtn, FALSE);
|
||||||
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
||||||
SetWindowText(npLabel, L"-");
|
EnableMenuItem(menuBar, ID_PLIK_CLOSEDIR, MF_DISABLED);
|
||||||
SetWindowText(playButton, PLAY_LABEL);
|
EnableMenuItem(menuBar, ID_AKCJE_RANDOM, MF_DISABLED);
|
||||||
break;
|
EnableMenuItem(menuBar, ID_AKCJE_SRCLEAR, MF_DISABLED);
|
||||||
case 0:
|
SetWindowText(dirLabel, NO_DIR_LOADED_LABEL);
|
||||||
EnableWindow(filesListCtrl, TRUE);
|
|
||||||
EnableWindow(playButton, TRUE);
|
|
||||||
EnableWindow(stopButton, TRUE);
|
|
||||||
EnableMenuItem(menuBar, ID_REFRESH, MF_ENABLED);
|
|
||||||
SetWindowText(npLabel, NOT_PLAYING_LABEL);
|
SetWindowText(npLabel, NOT_PLAYING_LABEL);
|
||||||
SetWindowText(playButton, PLAY_LABEL);
|
SetWindowText(playButton, PLAY_LABEL);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 0:
|
||||||
EnableWindow(filesListCtrl, FALSE);
|
if (!path.empty()) {
|
||||||
|
EnableWindow(filesListCtrl, TRUE);
|
||||||
EnableWindow(playButton, TRUE);
|
EnableWindow(playButton, TRUE);
|
||||||
EnableWindow(stopButton, TRUE);
|
EnableWindow(stopButton, TRUE);
|
||||||
|
EnableWindow(searchBtn, TRUE);
|
||||||
|
EnableMenuItem(menuBar, ID_REFRESH, MF_ENABLED);
|
||||||
|
EnableMenuItem(menuBar, ID_PLIK_CLOSEDIR, MF_ENABLED);
|
||||||
|
EnableMenuItem(menuBar, ID_AKCJE_RANDOM, MF_ENABLED);
|
||||||
|
EnableMenuItem(menuBar, ID_AKCJE_SRCLEAR, MF_ENABLED);
|
||||||
|
SetWindowText(npLabel, NOT_PLAYING_LABEL);
|
||||||
|
SetWindowText(playButton, PLAY_LABEL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, -1, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
if (!path.empty() && selected != -1) {
|
||||||
|
int playerState = 0;
|
||||||
|
if (currentState == 2) {
|
||||||
|
playerState = mciSendString(L"resume mp3", NULL, 0, mainWindow);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (isLoopEnabled && !isAutoPlayEnabled) {
|
||||||
|
playerState = mciSendString(L"play mp3 repeat", NULL, 0, mainWindow);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerState = mciSendString(L"play mp3 notify", NULL, 0, mainWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerState != 0) {
|
||||||
|
MessageBox(mainWindow, L"Nie uda³o siê odtworzyæ wskazanego pliku. SprawdŸ czy plik nie jest uszkodzony.", L"B³¹d odtwarzania", MB_ICONERROR);
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableWindow(filesListCtrl, TRUE);
|
||||||
|
EnableWindow(playButton, TRUE);
|
||||||
|
EnableWindow(stopButton, TRUE);
|
||||||
|
EnableWindow(searchBtn, TRUE);
|
||||||
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
||||||
SetWindowText(npLabel, selected.c_str());
|
EnableMenuItem(menuBar, ID_PLIK_CLOSEDIR, MF_ENABLED);
|
||||||
|
EnableMenuItem(menuBar, ID_AKCJE_RANDOM, MF_ENABLED);
|
||||||
|
EnableMenuItem(menuBar, ID_AKCJE_SRCLEAR, MF_ENABLED);
|
||||||
|
SetWindowText(npLabel, files[selected].cFileName);
|
||||||
SetWindowText(playButton, PAUSE_LABEL);
|
SetWindowText(playButton, PAUSE_LABEL);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 2:
|
case 2:
|
||||||
wstring pauseStringWS = selected + L" [PAUZA]";
|
mciSendString(L"pause mp3", NULL, 0, mainWindow);
|
||||||
|
|
||||||
|
wstring pauseStringWS = wstring(files[selected].cFileName) + 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);
|
||||||
|
EnableWindow(searchBtn, TRUE);
|
||||||
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
EnableMenuItem(menuBar, ID_REFRESH, MF_DISABLED);
|
||||||
|
EnableMenuItem(menuBar, ID_PLIK_CLOSEDIR, MF_ENABLED);
|
||||||
|
EnableMenuItem(menuBar, ID_AKCJE_RANDOM, MF_ENABLED);
|
||||||
|
EnableMenuItem(menuBar, ID_AKCJE_SRCLEAR, MF_ENABLED);
|
||||||
SetWindowText(npLabel, pauseString);
|
SetWindowText(npLabel, pauseString);
|
||||||
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);
|
||||||
@@ -371,3 +629,39 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
|
|||||||
}
|
}
|
||||||
return (INT_PTR)FALSE;
|
return (INT_PTR)FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SORTING FUNCTION
|
||||||
|
bool alphabeticSort(WIN32_FIND_DATA a, WIN32_FIND_DATA b) {
|
||||||
|
wstring aStr = a.cFileName;
|
||||||
|
wstring bStr = b.cFileName;
|
||||||
|
wstring aBuf;
|
||||||
|
wstring bBuf;
|
||||||
|
int aNum = 0;
|
||||||
|
int bNum = 0;
|
||||||
|
for (int i = 0; i < aStr.size(); i++) {
|
||||||
|
if (std::isdigit(static_cast<unsigned char>(aStr.at(i)))) {
|
||||||
|
aBuf += aStr.at(i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < bStr.size(); i++) {
|
||||||
|
if (std::isdigit(static_cast<unsigned char>(bStr.at(i)))) {
|
||||||
|
bBuf += bStr.at(i);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!aBuf.empty()) {
|
||||||
|
aNum = std::stoi(aBuf);
|
||||||
|
}
|
||||||
|
if (!bBuf.empty()) {
|
||||||
|
bNum = std::stoi(bBuf);
|
||||||
|
}
|
||||||
|
if (aNum != 0 || bNum != 0) {
|
||||||
|
return aNum < bNum;
|
||||||
|
}
|
||||||
|
return std::tolower(aStr.at(0)) < std::tolower(bStr.at(0));
|
||||||
|
}
|
||||||
+9
-7
@@ -12,13 +12,15 @@
|
|||||||
#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_ONCLICK 32776
|
||||||
#define ID_OPCJE_ONCLICK 32778
|
#define ID_OPCJE_LOOP 32777
|
||||||
#define ID_OPCJE_LOOP 32779
|
#define ID_PLIK_CLOSEDIR 32778
|
||||||
#define ID_POMOC_SKR32782 32782
|
#define ID_AKCJE_SRCLEAR 32779
|
||||||
#define ID_POMOC_KBSHR 32783
|
#define ID_PLIK_OPENDIR 32780
|
||||||
|
#define ID_AKCJE_RANDOM 32781
|
||||||
|
#define ID_OPCJE_SHOWEXT 32782
|
||||||
|
#define ID_OPCJE_AUTOPLAY 32783
|
||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
@@ -27,7 +29,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 32784
|
||||||
#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
|
||||||
|
|||||||
Reference in new issue
Block a user