From 8aed9d2c78139d4b7816c93bd14ff3bfc91f267a Mon Sep 17 00:00:00 2001 From: GRZ4NA Date: Sat, 29 May 2021 22:15:50 +0200 Subject: [PATCH] menu bar options --- main.cpp | 49 +++++++++++++++++++++---------------------------- resource.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 resource.h diff --git a/main.cpp b/main.cpp index 96a6883..f7e2f54 100644 --- a/main.cpp +++ b/main.cpp @@ -50,8 +50,6 @@ HWND filesListScroll; HWND playButton; HWND stopButton; HWND npLabel; -HWND autoPlayCheck; -HWND loopCheck; HMENU menuBar; //HOOKS @@ -97,12 +95,6 @@ void CreateControls(HWND window) { SendMessage(playButton, WM_SETFONT, (WPARAM)hFont, TRUE); stopButton = EzCreateButton(L"Zatrzymaj", 195, 515, 100, 30, window, NULL); SendMessage(stopButton, WM_SETFONT, (WPARAM)hFont, TRUE); - autoPlayCheck = CreateWindowEx(NULL, L"BUTTON", L"Odtwarzaj automatycznie", BS_CHECKBOX | WS_VISIBLE | WS_CHILD | SS_CENTER | SS_CENTERIMAGE, 105, 485, 170, 30, window, NULL, NULL, NULL); - SendMessage(autoPlayCheck, BM_SETCHECK, BST_CHECKED, NULL); - SendMessage(autoPlayCheck, WM_SETFONT, (WPARAM)hFont, TRUE); - loopCheck = CreateWindowEx(NULL, L"BUTTON", L"Pętla", BS_CHECKBOX | WS_VISIBLE | WS_CHILD | SS_CENTER | SS_CENTERIMAGE, 300, 485, 50, 30, window, NULL, NULL, NULL); - SendMessage(loopCheck, BM_SETCHECK, BST_UNCHECKED, NULL); - SendMessage(loopCheck, 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, wstring ext) { @@ -227,26 +219,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { } } } - else if ((HWND)lParam == autoPlayCheck) { - if (isAutoPlayEnabled) { - SendMessage(autoPlayCheck, BM_SETCHECK, BST_UNCHECKED, NULL); - isAutoPlayEnabled = FALSE; - } - else { - SendMessage(autoPlayCheck, BM_SETCHECK, BST_CHECKED, NULL); - isAutoPlayEnabled = TRUE; - } - } - else if ((HWND)lParam == loopCheck) { - if (isLoopEnabled) { - SendMessage(loopCheck, BM_SETCHECK, BST_UNCHECKED, NULL); - isLoopEnabled = FALSE; - } - else { - SendMessage(loopCheck, BM_SETCHECK, BST_CHECKED, NULL); - isLoopEnabled = TRUE; - } - } else if ((HWND)lParam == stopButton) { mciSendString(L"close mp3", NULL, 0, NULL); SendMessage(mainWindow, STATE_CHANGE, 0, NULL); @@ -285,6 +257,27 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { else { MessageBox(mainWindow, L"Nie załadowano folderu. Naciśnij przycisk PRZEGLĄDAJ, aby wczytać katalog.", L"Brak katalogu", MB_ICONERROR); } + break; + case ID_OPCJE_ONCLICK: + if (isAutoPlayEnabled) { + CheckMenuItem(menuBar, ID_OPCJE_ONCLICK, MF_UNCHECKED); + isAutoPlayEnabled = FALSE; + } + else { + CheckMenuItem(menuBar, ID_OPCJE_ONCLICK, MF_CHECKED); + isAutoPlayEnabled = TRUE; + } + break; + case ID_OPCJE_LOOP: + if (isLoopEnabled) { + CheckMenuItem(menuBar, ID_OPCJE_LOOP, MF_UNCHECKED); + isLoopEnabled = FALSE; + } + else { + CheckMenuItem(menuBar, ID_OPCJE_LOOP, MF_CHECKED); + isLoopEnabled = TRUE; + } + break; } break; case MM_MCINOTIFY: diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..d912f2e --- /dev/null +++ b/resource.h @@ -0,0 +1,34 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by PAiPlayer.rc +// +#define IDC_MYICON 2 +#define IDD_PAIPLAYER_DIALOG 102 +#define IDS_APP_TITLE 103 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_PAIPLAYER 107 +#define IDI_SMALL 108 +#define IDC_PAIPLAYER 109 +#define IDR_MAINFRAME 128 +#define IDC_MENU 200 +#define ID_PLIK_OD32774 32774 +#define ID_REFRESH 32775 +#define ID_OPCJE_ODTWARZAJPOKLIKNI32776 32776 +#define ID_OPCJE_POWTARZAJ 32777 +#define ID_OPCJE_ONCLICK 32778 +#define ID_OPCJE_LOOP 32779 +#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 129 +#define _APS_NEXT_COMMAND_VALUE 32780 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif