Archived
a lot
This commit is contained in:
1 parent
4cf972ae96
commit
b1f8834675
1 file changed
+26
-8
@@ -2,11 +2,12 @@
|
||||
#include "EzWinAPIBuilders.h"
|
||||
#include <ShlObj.h>
|
||||
#include <debugapi.h>
|
||||
#include <strsafe.h>
|
||||
#define IDC_LIST 1
|
||||
|
||||
//GLOBAL VARS
|
||||
MSG msg;
|
||||
TCHAR* openedPath;
|
||||
TCHAR path[MAX_PATH];
|
||||
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"));
|
||||
bool isAutoPlayEnabled = true;
|
||||
|
||||
@@ -60,11 +61,11 @@ void CreateControls(HWND window) {
|
||||
SendMessage(autoPlayCheck, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||
filesListScroll = CreateWindowEx(0, L"SCROLLBAR", NULL, WS_CHILD | WS_VISIBLE | SBS_VERT, 300, 50, 50, 425, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
void GetFiles(TCHAR* path) {
|
||||
openedPath = path;
|
||||
path = lstrcat(path, L"\\*.mp3");
|
||||
void GetFiles(TCHAR* inputPath) {
|
||||
StringCchCat(inputPath, MAX_PATH, L"\\*.mp3");
|
||||
MessageBox(NULL, inputPath, L"test", 0);
|
||||
WIN32_FIND_DATA data;
|
||||
HANDLE hFind = FindFirstFile(path, &data);
|
||||
HANDLE hFind = FindFirstFile(inputPath, &data);
|
||||
SendMessage(filesListCtrl, LB_RESETCONTENT, NULL, NULL);
|
||||
|
||||
if (hFind != INVALID_HANDLE_VALUE) {
|
||||
@@ -90,7 +91,6 @@ void FolderBrowseDialog(HWND window) {
|
||||
dialog.ulFlags = BIF_NEWDIALOGSTYLE;
|
||||
dialog.lpszTitle = L"Wybierz folder, który ma zostaæ otwarty przez program";
|
||||
LPITEMIDLIST pid = SHBrowseForFolder(&dialog);
|
||||
TCHAR path[MAX_PATH];
|
||||
if (pid != 0) {
|
||||
SHGetPathFromIDList(pid, path);
|
||||
SetCurrentDirectory(path);
|
||||
@@ -98,7 +98,11 @@ void FolderBrowseDialog(HWND window) {
|
||||
GetFiles(path);
|
||||
}
|
||||
}
|
||||
void PlaySound() {
|
||||
void PlaySound(TCHAR* openedPath, TCHAR* fileName) {
|
||||
/*openedPath = lstrcat(openedPath, L"\\");
|
||||
MessageBox(NULL, openedPath, L"test", 0);
|
||||
TCHAR* fullPath = lstrcat(openedPath, fileName);
|
||||
MessageBox(NULL, fullPath, L"test", 0);*/
|
||||
mciSendStringW(L"open D:\\grzan\\Music\\NIE.mp3 type mpegvideo alias mp3", NULL, 0, NULL);
|
||||
mciSendStringW(L"play mp3 wait", NULL, 0, NULL);
|
||||
mciSendStringW(L"close mp3", NULL, 0, NULL);
|
||||
@@ -120,7 +124,21 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||
windowEvent = HIWORD(wParam);
|
||||
if (windowId == IDC_LIST) {
|
||||
if (windowEvent == LBN_SELCHANGE) {
|
||||
PlaySound();
|
||||
int listItemsCount = SendMessage(filesListCtrl, LB_GETCOUNT, NULL, NULL);
|
||||
int selectedItemIndex = -1;
|
||||
TCHAR* selectedItemName = new TCHAR[sizeof(TCHAR) + 1];
|
||||
for (int i = 0; i < listItemsCount; i++) {
|
||||
if (SendMessage(filesListCtrl, LB_GETSEL, (WPARAM)i, NULL) > 0) {
|
||||
selectedItemIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (selectedItemIndex != -1) {
|
||||
int selectedItemNameLength = SendMessage(filesListCtrl, LB_GETTEXTLEN, (WPARAM)selectedItemIndex, NULL);
|
||||
selectedItemName = new TCHAR[selectedItemNameLength + 1];
|
||||
SendMessage(filesListCtrl, LB_GETTEXT, (WPARAM)selectedItemIndex, (LPARAM)selectedItemName);
|
||||
}
|
||||
PlaySound(path, selectedItemName);
|
||||
}
|
||||
}
|
||||
if ((HWND)lParam == browseButton) {
|
||||
|
||||
Reference in new issue
Block a user