9 Commits
6 changed files with 42 additions and 15 deletions

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
name="CompanyName.ProductName.YourApplication" name="CompanyName.ProductName.YourApplication"
type="win32" type="win32"
/> />
<description>PAiPlayer - A school project that helps me learn C++</description> <description>ClickPlay - a simple C++ music player</description>
<dependency> <dependency>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity <assemblyIdentity
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -22,7 +22,7 @@
<VCProjectVersion>16.0</VCProjectVersion> <VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<ProjectGuid>{c734fda7-262e-4202-8f4e-5e3031cb9935}</ProjectGuid> <ProjectGuid>{c734fda7-262e-4202-8f4e-5e3031cb9935}</ProjectGuid>
<RootNamespace>EasyAudioPlayer</RootNamespace> <RootNamespace>ClickPlay</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>ClickPlay</ProjectName> <ProjectName>ClickPlay</ProjectName>
</PropertyGroup> </PropertyGroup>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

+40 -13
View File
@@ -109,7 +109,7 @@ int WINAPI WinMain(HINSTANCE currentInst, HINSTANCE previousInst, LPSTR lpCmdLin
//INITIALIZE MESSAGE LOOP //INITIALIZE MESSAGE LOOP
while (GetMessage(&msg, NULL, 0, 0)) { while (GetMessage(&msg, NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, shortcuts, &msg)) { if (!TranslateAccelerator(mainWindow, shortcuts, &msg)) {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
@@ -180,8 +180,8 @@ int LoadSelection(int index) {
LPCWSTR fullCommand = fullCommandS.c_str(); LPCWSTR fullCommand = fullCommandS.c_str();
if (mciSendString(fullCommand, NULL, 0, mainWindow) != 0) { 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(); UnloadSelection();
MessageBox(mainWindow, L"Nieznany b³¹d uniemo¿liwia odtworzenie tego pliku. SprawdŸ czy plik nie jest uszkodzony.", L"B³¹d wczytywania", MB_ICONERROR);
return -4; return -4;
} }
selected = index; selected = index;
@@ -291,16 +291,23 @@ int FolderBrowseDialog(HWND window) {
} }
//SEARCH DIRECTORY //SEARCH DIRECTORY
void SearchDir(wstring phrase) { /*ERROR CODES
* -1 - no files found
* -2 - LoadDir error
* -3 - empty input
*/
int SearchDir(wstring phrase) {
//PERFORM CHECKING //PERFORM CHECKING
if (path.empty()) { if (path.empty()) {
return; return -2;
} }
//RELOAD DIR //RELOAD DIR
LoadDir(path); if (LoadDir(path) != 0) {
return -2;
}
//PREPARE //PREPARE
if (phrase.empty()) { if (phrase.empty()) {
return; return -3;
} }
vector<WIN32_FIND_DATA> results; vector<WIN32_FIND_DATA> results;
//GET FILES //GET FILES
@@ -311,12 +318,13 @@ void SearchDir(wstring phrase) {
} }
if (results.empty()) { if (results.empty()) {
MessageBox(mainWindow, L"Nie znaleziono plików zawieraj¹cych wpisan¹ frazê.", L"Brak plików", MB_ICONEXCLAMATION); MessageBox(mainWindow, L"Nie znaleziono plików zawieraj¹cych wpisan¹ frazê.", L"Brak plików", MB_ICONEXCLAMATION);
return; return -1;
} }
std::sort(results.begin(), results.end(), alphabeticSort); std::sort(results.begin(), results.end(), alphabeticSort);
files = results; files = results;
//ADD FILTERED CONTENT //ADD FILTERED CONTENT
GenerateList(files); GenerateList(files);
return 0;
} }
//GET SEARCH PHRASE FROM searchBox //GET SEARCH PHRASE FROM searchBox
@@ -365,11 +373,18 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
SendMessage(mainWindow, STATE_CHANGE, 1, NULL); SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
} }
} }
else {
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
}
} }
break; break;
case IDC_SEARCHBTN: case IDC_SEARCHBTN:
SearchDir(GetSearchPhrase()); if (SearchDir(GetSearchPhrase()) == -2) {
SendMessage(mainWindow, STATE_CHANGE, 0, 0); SendMessage(mainWindow, STATE_CHANGE, -1, 0);
}
else {
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
}
break; break;
case IDC_PLAYBTN: case IDC_PLAYBTN:
switch (currentState) { switch (currentState) {
@@ -377,6 +392,9 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
if (LoadSelection(GetIndex()) == 0) { if (LoadSelection(GetIndex()) == 0) {
SendMessage(mainWindow, STATE_CHANGE, 1, NULL); SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
} }
else {
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
}
break; break;
case 1: case 1:
SendMessage(mainWindow, STATE_CHANGE, 2, NULL); SendMessage(mainWindow, STATE_CHANGE, 2, NULL);
@@ -402,7 +420,9 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
SendMessage(mainWindow, STATE_CHANGE, -1, 0); SendMessage(mainWindow, STATE_CHANGE, -1, 0);
} }
if (SendMessage(searchBox, WM_GETTEXTLENGTH, 0, 0) > 0) { if (SendMessage(searchBox, WM_GETTEXTLENGTH, 0, 0) > 0) {
SearchDir(GetSearchPhrase()); if (SearchDir(GetSearchPhrase()) == -2) {
SendMessage(mainWindow, STATE_CHANGE, -1, 0);
}
} }
break; break;
case ID_OPCJE_ONCLICK: case ID_OPCJE_ONCLICK:
@@ -438,6 +458,9 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
} }
if (!path.empty() && !files.empty()) { if (!path.empty() && !files.empty()) {
GenerateList(files); GenerateList(files);
if (selected != -1) {
SendMessage(filesListCtrl, LB_SETCURSEL, selected, 0);
}
} }
break; break;
case ID_PLIK_CLOSEDIR: case ID_PLIK_CLOSEDIR:
@@ -458,9 +481,13 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
srand(time(NULL)); srand(time(NULL));
//LOAD AND PLAY //LOAD AND PLAY
randIndex = rand() % files.size(); randIndex = rand() % files.size();
LoadSelection(randIndex); if (LoadSelection(randIndex) == 0) {
SendMessage(filesListCtrl, LB_SETCURSEL, randIndex, 0); SendMessage(filesListCtrl, LB_SETCURSEL, randIndex, 0);
SendMessage(mainWindow, STATE_CHANGE, 1, 0); SendMessage(mainWindow, STATE_CHANGE, 1, 0);
}
else {
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
}
break; break;
case ID_OPCJE_AUTOPLAY: case ID_OPCJE_AUTOPLAY:
if (isAutoPlayEnabled) { if (isAutoPlayEnabled) {