From 60fc2fb0ae380375a64cc482dc84355ef15063c0 Mon Sep 17 00:00:00 2001 From: OV2 Date: Sun, 1 Apr 2018 13:32:56 +0200 Subject: [PATCH] win32: select correct output method when cancelling dialog --- win32/wsnes9x.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index 179443ad..f0042877 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -7263,6 +7263,17 @@ LRESULT CALLBACK GroupBoxCheckBoxTitle(HWND hWnd, UINT message, WPARAM wParam, L return CallWindowProc(lpfnOldWndProc, hWnd, message, wParam, lParam); } +void SelectOutputMethodInVideoDropdown(HWND hDlg, OutputMethod method) +{ + // select item with corresponding itemdata + int item_count = SendDlgItemMessage(hDlg, IDC_OUTPUTMETHOD, CB_GETCOUNT, 0, 0); + for (int index = 0; index < item_count; index++) { + int item_data = SendDlgItemMessage(hDlg, IDC_OUTPUTMETHOD, CB_GETITEMDATA, index, 0); + if (item_data == method) + SendDlgItemMessage(hDlg, IDC_OUTPUTMETHOD, CB_SETCURSEL, index, 0); + } +} + INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { int index; @@ -7406,13 +7417,7 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) inserted_index = SendDlgItemMessage(hDlg, IDC_OUTPUTMETHOD, CB_ADDSTRING, 0, (LPARAM)TEXT("OpenGL")); SendDlgItemMessage(hDlg, IDC_OUTPUTMETHOD, CB_SETITEMDATA, inserted_index, OPENGL); - // select item with corresponding itemdata - int item_count = SendDlgItemMessage(hDlg, IDC_OUTPUTMETHOD, CB_GETCOUNT, 0, 0); - for (int index = 0; index < item_count; index++) { - int item_data = SendDlgItemMessage(hDlg, IDC_OUTPUTMETHOD, CB_GETITEMDATA, index, 0); - if (item_data == GUI.outputMethod) - SendDlgItemMessage(hDlg, IDC_OUTPUTMETHOD, CB_SETCURSEL, index, 0); - } + SelectOutputMethodInVideoDropdown(hDlg, GUI.outputMethod); // add all the GUI.Scale filters to the combo box for (int filter = 0; filter < (int)NUM_FILTERS; filter++) @@ -7784,7 +7789,7 @@ updateFilterBox2: case IDCANCEL: - ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_OUTPUTMETHOD),prevOutputMethod); + SelectOutputMethodInVideoDropdown(hDlg, prevOutputMethod); SendMessage(hDlg,WM_COMMAND,MAKEWPARAM(IDC_OUTPUTMETHOD,CBN_SELCHANGE),0); {