Example #1
0
int COption::PropSheetProc(HWND hWnd, UINT msg, LPARAM lParam)
{
	switch (msg)
	{
		case PSCB_INITIALIZED:
		{
			m_option_tmp = m_option;
			CSusie susie;
			susie.Init();
			const LONG_PTR style = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
			SetWindowLongPtr(hWnd, GWL_EXSTYLE, style & ~WS_EX_CONTEXTHELP);
			break;
		}
	}

	return FALSE;
}
Example #2
0
LRESULT COption::SusieProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
	static CFolderDialog FolderDlg;
	static SOption* pOption = &m_option_tmp;

	static CCheckBox SusieCheckUse, SusieCheckFirst;
	static CLabel SusieLabelDir;
	static CEditBox SusieEditDir;
  static CButton SusieBtnDir, SusieBtnUpdate;
  static std::array<CButton, 2> SusieBtn;
	static CSusieListView SusieListView;
	static CSusie susie;

	switch (msg)
	{
		case WM_INITDIALOG:
		{
			UINT ID = 10000;
			const int x = 10;
			const int xx = 15;
			int y = 0;

			SusieCheckUse.Create(hWnd, _T("Use Susie Plugins"), ID++, x + 15, y += 20, 200, 20);
			SusieCheckUse.SetCheck(pOption->bSusieUse);

			SusieLabelDir.Create(hWnd, _T("Susie Folder"), ID++, x + xx, y += 24, 75, 20);
			SusieEditDir.Create(hWnd, pOption->SusieDir, ID++, x + xx + 75, y - 4, 200, 22);
			SusieEditDir.Enable(pOption->bSusieUse);
			SusieBtnDir.Create(hWnd, _T("Browse"), ID++, x + xx + 280, y - 3, 50, 20);
			SusieBtnDir.Enable(pOption->bSusieUse);

			SusieCheckFirst.Create(hWnd, _T("Give Susie plugins priority when decoding"), ID++, x + xx, y += 20, 250, 20);
			SusieCheckFirst.SetCheck(pOption->bSusieFirst);
			SusieCheckFirst.Enable(pOption->bSusieUse);

			SusieListView.Create(hWnd, *pOption, x + xx, y += 30, 500, 190);
			SusieListView.Close();
			SusieListView.Enable(pOption->bSusieUse);
			SusieListView.Show();

			SusieBtnUpdate.Create(hWnd, _T("Update"), ID++, x + 290, y += 200, 50, 20);
			SusieBtnUpdate.Enable(pOption->bSusieUse);
			SusieBtn[0].Create(hWnd, _T("All ON"), ID++, x + 350, y, 80, 20);
			SusieBtn[0].Enable(pOption->bSusieUse);
			SusieBtn[1].Create(hWnd, _T("All OFF"), ID++, x + 430, y, 80, 20);
			SusieBtn[1].Enable(pOption->bSusieUse);

			break;
		}

		case WM_COMMAND:
			// Use Susie plugins
			if (LOWORD(wp) == SusieCheckUse.GetID())
			{
				const BOOL flag = SusieCheckUse.GetCheck();
				SusieEditDir.Enable(flag);
				SusieBtnDir.Enable(flag);
				SusieCheckFirst.Enable(flag);
				SusieListView.Enable(flag);
				SusieBtnUpdate.Enable(flag);
				SusieBtn[0].Enable(flag);
				SusieBtn[1].Enable(flag);
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				// Click here to show / hide the list of checkboxes, de-selected state
				pOption->bSusieUse = flag;
				SusieListView.SetItemSelAll(0);
				break;
			}

			// Susie Folder Browse
			if (LOWORD(wp) == SusieBtnDir.GetID())
			{
				TCHAR szSusieDir[_MAX_DIR];
				SusieEditDir.GetText(szSusieDir, sizeof(szSusieDir));
				if (FolderDlg.DoModal(hWnd, _T("Select the Susie folder"), szSusieDir))
					SusieEditDir.SetText(szSusieDir);
			}

			// Give Susie plugins priority on decoding
			if (LOWORD(wp) == SusieCheckFirst.GetID())
			{
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// Update
			if (LOWORD(wp) == SusieBtnUpdate.GetID())
			{
				susie.LoadSpi(pOption->SusieDir);
				susie.Init();
				SusieListView.Show();
				SusieListView.Update();
				break;
			}

			// All ON
			if (LOWORD(wp) == SusieBtn[0].GetID())
			{
				SusieListView.SetCheckAll(true);
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// All OFF
			if (LOWORD(wp) == SusieBtn[1].GetID())
			{
				SusieListView.SetCheckAll(false);
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// Settings
			if (LOWORD(wp) == IDM_SUSIE_SET)
			{
				const SSusieInfo* const susie_info = SusieListView.GetFocusSusieInfo();

				// Get ConfigurationDlg()
				const auto ConfigurationDlg = reinterpret_cast<ConfigurationDlgProc>(susie_info->plugin.GetProcAddress(_T("ConfigurationDlg")));

				if (ConfigurationDlg == nullptr)
					break;

				// Call settings
				ConfigurationDlg(hWnd, 1);

				break;
			}

			// Contents of the editbox have changed
			if (HIWORD(wp) == EN_CHANGE)
			{
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}
			break;

		case WM_NOTIFY:
		{
			const auto* const hdr = reinterpret_cast<LPNMHDR>(lp);

			switch (hdr->code)
			{
				// OK/Apply, Tabbing
				case PSN_APPLY:
				case PSN_KILLACTIVE:
					pOption->bSusieUse = SusieCheckUse.GetCheck();
					pOption->bSusieFirst = SusieCheckFirst.GetCheck();
					SusieEditDir.GetText(pOption->SusieDir);
					SusieListView.SaveIni();
					// OK/Apply
					if (hdr->code == PSN_APPLY)
					{
						const bool update = m_option.SusieDir == pOption->SusieDir;
						Apply();
						// Re-acquire plugin folder only when Susie has been changed
						if (pOption->bSusieUse && update)
						{
							susie.LoadSpi(pOption->SusieDir);
							susie.Init();
							SusieListView.Show();
							SusieListView.Update();
						}
					}
					return TRUE;
				// Check processing
				case NM_CLICK:
				case NM_DBLCLK:
					if (hdr->idFrom == idsSusieList)
					{
						if (SusieListView.SetCheck())
							PropSheet_Changed(::GetParent(hWnd), hWnd);
						break;
					}
			}

			// List view
			if (wp == idsSusieList)
			{
				const auto* const plv = reinterpret_cast<LPNMLISTVIEW>(lp);
				switch (plv->hdr.code)
				{
					// Custom draw
					case NM_CUSTOMDRAW:
						return SusieListView.CustomDraw(reinterpret_cast<LPNMLVCUSTOMDRAW>(lp));
					// Show tool tip
					case LVN_GETINFOTIP:
						SusieListView.ShowTip(reinterpret_cast<LPNMLVGETINFOTIP>(lp));
						break;
					// View
					case LVN_GETDISPINFO:
						SusieListView.Show(reinterpret_cast<NMLVDISPINFO*>(lp));
						break;
				}
			}

			break;
		}

		case WM_MOUSEWHEEL:
		{
			POINT pos;
			GetCursorPos(&pos);
			HWND pWnd = WindowFromPoint(pos);
			if (pWnd == SusieListView.GetHandle())
				SendMessage(pWnd, WM_MOUSEWHEEL, wp, lp);
			break;
		}

		// Right-click menu (Context menu)
		case WM_CONTEXTMENU:
		{
			if (wp == reinterpret_cast<WPARAM>(SusieListView.GetHandle()))
				SusieListView.CreateMenu(lp);
			break;
		}
	}

	return FALSE;
}