Exemple #1
0
INT_PTR CSideBarOptions::DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg) {
	case WM_INITDIALOG:
		{
			DlgCheckBox_Check(hDlg,IDC_SIDEBAR_SHOWPOPUP,m_fShowPopup);

			::SendDlgItemMessage(hDlg,IDC_SIDEBAR_OPACITY_SLIDER,
								 TBM_SETRANGE,TRUE,MAKELPARAM(OPACITY_MIN,OPACITY_MAX));
			::SendDlgItemMessage(hDlg,IDC_SIDEBAR_OPACITY_SLIDER,
								 TBM_SETPOS,TRUE,m_PopupOpacity);
			::SendDlgItemMessage(hDlg,IDC_SIDEBAR_OPACITY_SLIDER,
								 TBM_SETPAGESIZE,0,10);
			::SendDlgItemMessage(hDlg,IDC_SIDEBAR_OPACITY_SLIDER,
								 TBM_SETTICFREQ,10,0);
			DlgEdit_SetInt(hDlg,IDC_SIDEBAR_OPACITY_INPUT,m_PopupOpacity);
			DlgUpDown_SetRange(hDlg,IDC_SIDEBAR_OPACITY_SPIN,OPACITY_MIN,OPACITY_MAX);
			EnableDlgItems(hDlg,IDC_SIDEBAR_OPACITY_LABEL,IDC_SIDEBAR_OPACITY_UNIT,
						   m_fShowPopup && Util::OS::IsWindows8OrLater());

			DlgCheckBox_Check(hDlg,IDC_SIDEBAR_SHOWTOOLTIPS,m_fShowToolTips);
			DlgCheckBox_Check(hDlg,IDC_SIDEBAR_SHOWCHANNELLOGO,m_fShowChannelLogo);

			const COLORREF IconColor=::GetSysColor(COLOR_WINDOWTEXT);
			const int IconWidth=::GetSystemMetrics(SM_CXSMICON);
			const int IconHeight=::GetSystemMetrics(SM_CYSMICON);
			SIZE sz;
			HBITMAP hbmIcons=CreateImage(IconWidth<=16 && IconHeight<=16?ICON_SIZE_SMALL:ICON_SIZE_BIG,&sz);
			TVTest::Theme::IconList Bitmap;
			Bitmap.Create(hbmIcons,sz.cx,sz.cy,IconWidth,IconHeight);
			::DeleteObject(hbmIcons);
			m_himlIcons=Bitmap.CreateImageList(IconColor);
			Bitmap.Destroy();

			m_IconIDMap.clear();
			for (int i=0;i<lengthof(ItemList);i++)
				m_IconIDMap.insert(std::pair<int,int>(ItemList[i].Command,ItemList[i].Icon));
			const CCommandList *pCommandList=m_pSideBar->GetCommandList();
			for (size_t i=lengthof(ItemList);i<m_AvailItemList.size();i++) {
				const int ID=m_AvailItemList[i].Command;
				if (ID>=CM_PLUGIN_FIRST && ID<=CM_PLUGIN_LAST) {
					CPlugin *pPlugin=GetAppClass().PluginManager.GetPluginByCommand(ID);
					if (pPlugin!=NULL && pPlugin->GetIcon().IsCreated()) {
						HICON hIcon=pPlugin->GetIcon().ExtractIcon(IconColor);
						if (hIcon!=NULL) {
							int Icon=ImageList_AddIcon(m_himlIcons,hIcon);
							::DestroyIcon(hIcon);
							m_IconIDMap.insert(std::pair<int,int>(ID,Icon));
						}
					}
				} else if (ID>=CM_PLUGINCOMMAND_FIRST && ID<=CM_PLUGINCOMMAND_LAST) {
					LPCTSTR pszCommand;
					CPlugin *pPlugin=GetAppClass().PluginManager.GetPluginByPluginCommand(
						pCommandList->GetCommandTextByID(ID),&pszCommand);
					if (pPlugin!=NULL) {
						CPlugin::CPluginCommandInfo *pCommandInfo=
							pPlugin->GetPluginCommandInfo(pszCommand);
						if (pCommandInfo!=NULL && pCommandInfo->GetIcon().IsCreated()) {
							HICON hIcon=pCommandInfo->GetIcon().ExtractIcon(IconColor);
							if (hIcon!=NULL) {
								int Icon=ImageList_AddIcon(m_himlIcons,hIcon);
								::DestroyIcon(hIcon);
								m_IconIDMap.insert(std::pair<int,int>(ID,Icon));
							}
						}
					}
				}
			}

			HWND hwndList=::GetDlgItem(hDlg,IDC_SIDEBAR_ITEMLIST);
			ListView_SetExtendedListViewStyle(hwndList,LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
			ListView_SetImageList(hwndList,m_himlIcons,LVSIL_SMALL);
			RECT rc;
			::GetClientRect(hwndList,&rc);
			rc.right-=::GetSystemMetrics(SM_CXVSCROLL);
			LVCOLUMN lvc;
			lvc.mask=LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
			lvc.fmt=LVCFMT_LEFT;
			lvc.cx=rc.right;
			lvc.iSubItem=0;
			ListView_InsertColumn(hwndList,0,&lvc);
			SetItemList(hwndList,&m_ItemList[0],(int)m_ItemList.size());
			hwndList=::GetDlgItem(hDlg,IDC_SIDEBAR_COMMANDLIST);
			ListView_SetExtendedListViewStyle(hwndList,LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
			ListView_SetImageList(hwndList,m_himlIcons,LVSIL_SMALL);
			::GetClientRect(hwndList,&rc);
			rc.right-=::GetSystemMetrics(SM_CXVSCROLL);
			lvc.cx=rc.right;
			ListView_InsertColumn(hwndList,0,&lvc);
			std::vector<int> List;
			List.resize(m_AvailItemList.size());
			for (size_t i=0;i<m_AvailItemList.size();i++)
				List[i]=m_AvailItemList[i].Command;
			SetItemList(hwndList,List.data(),(int)List.size());
		}
		return TRUE;

	case WM_HSCROLL:
		if (reinterpret_cast<HWND>(lParam)==::GetDlgItem(hDlg,IDC_SIDEBAR_OPACITY_SLIDER)) {
			SyncEditWithTrackBar(hDlg,
								 IDC_SIDEBAR_OPACITY_SLIDER,
								 IDC_SIDEBAR_OPACITY_INPUT);
		}
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_SIDEBAR_SHOWPOPUP:
			EnableDlgItems(hDlg,IDC_SIDEBAR_OPACITY_LABEL,IDC_SIDEBAR_OPACITY_UNIT,
				DlgCheckBox_IsChecked(hDlg,IDC_SIDEBAR_SHOWPOPUP) && Util::OS::IsWindows8OrLater());
			return TRUE;

		case IDC_SIDEBAR_OPACITY_INPUT:
			if (HIWORD(wParam)==EN_CHANGE) {
				SyncTrackBarWithEdit(hDlg,
									 IDC_SIDEBAR_OPACITY_INPUT,
									 IDC_SIDEBAR_OPACITY_SLIDER);
			}
			return TRUE;

		case IDC_SIDEBAR_UP:
		case IDC_SIDEBAR_DOWN:
			{
				bool fUp=LOWORD(wParam)==IDC_SIDEBAR_UP;
				HWND hwndList=::GetDlgItem(hDlg,IDC_SIDEBAR_ITEMLIST);
				int Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);

				if ((fUp && Sel>0) || (!fUp && Sel<ListView_GetItemCount(hwndList)-1)) {
					LVITEM lvi;
					TCHAR szText[CCommandList::MAX_COMMAND_TEXT];

					lvi.mask=LVIF_STATE | LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
					lvi.iItem=Sel;
					lvi.iSubItem=0;
					lvi.stateMask=~0U;
					lvi.pszText=szText;
					lvi.cchTextMax=lengthof(szText);
					ListView_GetItem(hwndList,&lvi);
					ListView_DeleteItem(hwndList,Sel);
					if (fUp)
						lvi.iItem--;
					else
						lvi.iItem++;
					ListView_InsertItem(hwndList,&lvi);
				}
			}
			return TRUE;

		case IDC_SIDEBAR_REMOVE:
			{
				HWND hwndList=::GetDlgItem(hDlg,IDC_SIDEBAR_ITEMLIST);
				int Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);

				if (Sel>=0)
					ListView_DeleteItem(hwndList,Sel);
			}
			return TRUE;

		case IDC_SIDEBAR_DEFAULT:
			SetItemList(::GetDlgItem(hDlg,IDC_SIDEBAR_ITEMLIST),
						DefaultItemList,lengthof(DefaultItemList));
			return TRUE;

		case IDC_SIDEBAR_ADD:
			{
				HWND hwndList=::GetDlgItem(hDlg,IDC_SIDEBAR_COMMANDLIST);
				int Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);

				if (Sel>=0) {
					LVITEM lvi;
					TCHAR szText[CCommandList::MAX_COMMAND_TEXT];

					lvi.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
					lvi.iItem=Sel;
					lvi.iSubItem=0;
					lvi.pszText=szText;
					lvi.cchTextMax=lengthof(szText);
					ListView_GetItem(hwndList,&lvi);
					hwndList=::GetDlgItem(hDlg,IDC_SIDEBAR_ITEMLIST);
					Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);
					lvi.iItem=Sel>=0?Sel:ListView_GetItemCount(hwndList);
					lvi.state=LVIS_SELECTED | LVIS_FOCUSED;
					lvi.stateMask=LVIS_SELECTED | LVIS_FOCUSED;
					ListView_InsertItem(hwndList,&lvi);
				}
			}
			return TRUE;

		case IDC_SIDEBAR_SEPARATOR:
			{
				HWND hwndList=::GetDlgItem(hDlg,IDC_SIDEBAR_ITEMLIST);
				int Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);
				LVITEM lvi;

				lvi.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
				lvi.iItem=Sel>=0?Sel:ListView_GetItemCount(hwndList);
				lvi.iSubItem=0;
				lvi.pszText=TEXT("(区切り)");
				lvi.iImage=-1;
				lvi.lParam=ITEM_SEPARATOR;
				ListView_InsertItem(hwndList,&lvi);
			}
			return TRUE;
		}
		return TRUE;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case LVN_ITEMCHANGED:
			{
				LPNMLISTVIEW pnmlv=reinterpret_cast<LPNMLISTVIEW>(lParam);
				int Sel=ListView_GetNextItem(pnmlv->hdr.hwndFrom,-1,LVNI_SELECTED);

				if (pnmlv->hdr.idFrom==IDC_SIDEBAR_ITEMLIST) {
					EnableDlgItem(hDlg,IDC_SIDEBAR_UP,Sel>0);
					EnableDlgItem(hDlg,IDC_SIDEBAR_DOWN,Sel>=0 && Sel<ListView_GetItemCount(pnmlv->hdr.hwndFrom)-1);
					EnableDlgItem(hDlg,IDC_SIDEBAR_REMOVE,Sel>=0);
				} else {
					EnableDlgItem(hDlg,IDC_SIDEBAR_ADD,Sel>=0);
				}
			}
			break;

		case NM_RCLICK:
			{
				LPNMITEMACTIVATE pnmia=reinterpret_cast<LPNMITEMACTIVATE>(lParam);

				if (pnmia->hdr.idFrom==IDC_SIDEBAR_ITEMLIST) {
					if (pnmia->iItem>=0) {
						static const int MenuIDs[] = {
							IDC_SIDEBAR_UP,
							IDC_SIDEBAR_DOWN,
							0,
							IDC_SIDEBAR_REMOVE,
						};
						PopupMenuFromControls(hDlg,MenuIDs,lengthof(MenuIDs),TPM_RIGHTBUTTON);
					}
				} else {
					if (pnmia->iItem>=0) {
						static const int MenuIDs[] = {
							IDC_SIDEBAR_ADD,
						};
						PopupMenuFromControls(hDlg,MenuIDs,lengthof(MenuIDs),TPM_RIGHTBUTTON);
					}
				}
			}
			break;

		case PSN_APPLY:
			{
				m_fShowPopup=DlgCheckBox_IsChecked(hDlg,IDC_SIDEBAR_SHOWPOPUP);
				if (Util::OS::IsWindows8OrLater()) {
					int Opacity=DlgEdit_GetInt(hDlg,IDC_SIDEBAR_OPACITY_INPUT);
					m_PopupOpacity=CLAMP(Opacity,OPACITY_MIN,OPACITY_MAX);
				}
				m_fShowToolTips=DlgCheckBox_IsChecked(hDlg,IDC_SIDEBAR_SHOWTOOLTIPS);
				m_pSideBar->ShowToolTips(m_fShowToolTips);
				bool fShowChannelLogo=DlgCheckBox_IsChecked(hDlg,IDC_SIDEBAR_SHOWCHANNELLOGO);
				if (m_fShowChannelLogo!=fShowChannelLogo) {
					m_fShowChannelLogo=fShowChannelLogo;
					m_pSideBar->Invalidate();
				}

				HWND hwndList=::GetDlgItem(hDlg,IDC_SIDEBAR_ITEMLIST);
				std::vector<int> ItemList;
				int i,Count;
				LVITEM lvi;

				Count=ListView_GetItemCount(hwndList);
				lvi.mask=LVIF_PARAM;
				lvi.iSubItem=0;
				for (i=0;i<Count;i++) {
					lvi.iItem=i;
					ListView_GetItem(hwndList,&lvi);
					ItemList.push_back((int)lvi.lParam);
				}
				if (ItemList!=m_ItemList) {
					m_ItemList=ItemList;

					const CCommandList *pCommandList=m_pSideBar->GetCommandList();
					m_ItemNameList.clear();
					for (int i=0;i<Count;i++) {
						const int ID=m_ItemList[i];
						if (ID==ITEM_SEPARATOR) {
							m_ItemNameList.push_back(TVTest::String());
						} else {
							m_ItemNameList.push_back(TVTest::String(pCommandList->GetCommandTextByID(ID)));
						}
					}

					ApplyItemList();
				}

				m_fChanged=true;
			}
			break;
		}
		break;

	case WM_DESTROY:
		if (m_himlIcons!=NULL) {
			::ImageList_Destroy(m_himlIcons);
			m_himlIcons=NULL;
		}
		m_IconIDMap.clear();
		return TRUE;
	}

	return FALSE;
}
INT_PTR COperationOptions::DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg) {
	case WM_INITDIALOG:
		{
			DlgCheckBox_Check(hDlg,IDC_OPTIONS_DISPLAYDRAGMOVE,m_fDisplayDragMove);
			DlgCheckBox_Check(hDlg,IDC_OPTIONS_HIDECURSOR,m_fHideCursor);

			InitWheelSettings(IDC_OPTIONS_WHEELMODE,m_WheelCommand);
			InitWheelSettings(IDC_OPTIONS_WHEELSHIFTMODE,m_WheelShiftCommand);
			InitWheelSettings(IDC_OPTIONS_WHEELCTRLMODE,m_WheelCtrlCommand);
			InitWheelSettings(IDC_OPTIONS_WHEELTILTMODE,m_WheelTiltCommand);

			DlgCheckBox_Check(hDlg,IDC_OPTIONS_WHEELVOLUMEREVERSE,m_fWheelVolumeReverse);
			DlgCheckBox_Check(hDlg,IDC_OPTIONS_WHEELCHANNELREVERSE,m_fWheelChannelReverse);
			DlgEdit_SetUInt(hDlg,IDC_OPTIONS_WHEELCHANNELDELAY,m_WheelChannelDelay);
			DlgCheckBox_Check(hDlg,IDC_OPTIONS_STATUSBARWHEEL,m_fStatusBarWheel);

			int LeftDoubleClick=0,RightClick=0,MiddleClick=0;
			for (int i=IDC_OPTIONS_MOUSECOMMAND_FIRST;i<=IDC_OPTIONS_MOUSECOMMAND_LAST;i++) {
				DlgComboBox_AddString(hDlg,i,TEXT("なし"));
				DlgComboBox_SetItemData(hDlg,i,0,0);
			}
			int NumCommands=m_pCommandList->NumCommands();
			for (int i=0;i<NumCommands;i++) {
				TCHAR szText[CCommandList::MAX_COMMAND_NAME];
				int Command=m_pCommandList->GetCommandID(i);

				m_pCommandList->GetCommandName(i,szText,lengthof(szText));
				for (int j=IDC_OPTIONS_MOUSECOMMAND_FIRST;j<=IDC_OPTIONS_MOUSECOMMAND_LAST;j++) {
					int Index=(int)DlgComboBox_AddString(hDlg,j,szText);
					DlgComboBox_SetItemData(hDlg,j,Index,Command);
				}
				if (Command==m_LeftDoubleClickCommand)
					LeftDoubleClick=i+1;
				if (Command==m_RightClickCommand)
					RightClick=i+1;
				if (Command==m_MiddleClickCommand)
					MiddleClick=i+1;
			}
			DlgComboBox_SetCurSel(hDlg,IDC_OPTIONS_LEFTDOUBLECLICKCOMMAND,LeftDoubleClick);
			DlgComboBox_SetCurSel(hDlg,IDC_OPTIONS_RIGHTCLICKCOMMAND,RightClick);
			DlgComboBox_SetCurSel(hDlg,IDC_OPTIONS_MIDDLECLICKCOMMAND,MiddleClick);

			DlgEdit_SetInt(hDlg,IDC_OPTIONS_VOLUMESTEP,m_VolumeStep);
			DlgUpDown_SetRange(hDlg,IDC_OPTIONS_VOLUMESTEP_UD,1,100);

			DlgEdit_SetInt(hDlg,IDC_OPTIONS_AUDIODELAYSTEP,m_AudioDelayStep);
			DlgUpDown_SetRange(hDlg,IDC_OPTIONS_AUDIODELAYSTEP_UD,1,1000);
		}
		return TRUE;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case PSN_APPLY:
			{
				m_fDisplayDragMove=
					DlgCheckBox_IsChecked(hDlg,IDC_OPTIONS_DISPLAYDRAGMOVE);
				m_fHideCursor=
					DlgCheckBox_IsChecked(hDlg,IDC_OPTIONS_HIDECURSOR);

				m_WheelCommand=
					(int)DlgComboBox_GetItemData(hDlg,IDC_OPTIONS_WHEELMODE,
						DlgComboBox_GetCurSel(hDlg,IDC_OPTIONS_WHEELMODE));
				m_WheelShiftCommand=
					(int)DlgComboBox_GetItemData(hDlg,IDC_OPTIONS_WHEELSHIFTMODE,
						DlgComboBox_GetCurSel(hDlg,IDC_OPTIONS_WHEELSHIFTMODE));
				m_WheelCtrlCommand=
					(int)DlgComboBox_GetItemData(hDlg,IDC_OPTIONS_WHEELCTRLMODE,
						DlgComboBox_GetCurSel(hDlg,IDC_OPTIONS_WHEELCTRLMODE));
				m_WheelTiltCommand=
					(int)DlgComboBox_GetItemData(hDlg,IDC_OPTIONS_WHEELTILTMODE,
						DlgComboBox_GetCurSel(hDlg,IDC_OPTIONS_WHEELTILTMODE));

				m_fWheelVolumeReverse=DlgCheckBox_IsChecked(hDlg,IDC_OPTIONS_WHEELVOLUMEREVERSE);
				m_fWheelChannelReverse=DlgCheckBox_IsChecked(hDlg,IDC_OPTIONS_WHEELCHANNELREVERSE);
				m_WheelChannelDelay=DlgEdit_GetUInt(hDlg,IDC_OPTIONS_WHEELCHANNELDELAY);
				if (m_WheelChannelDelay<WHEEL_CHANNEL_DELAY_MIN)
					m_WheelChannelDelay=WHEEL_CHANNEL_DELAY_MIN;
				m_fStatusBarWheel=DlgCheckBox_IsChecked(hDlg,IDC_OPTIONS_STATUSBARWHEEL);

				m_LeftDoubleClickCommand=
					(int)DlgComboBox_GetItemData(hDlg,IDC_OPTIONS_LEFTDOUBLECLICKCOMMAND,
						DlgComboBox_GetCurSel(hDlg,IDC_OPTIONS_LEFTDOUBLECLICKCOMMAND));
				m_RightClickCommand=
					(int)DlgComboBox_GetItemData(hDlg,IDC_OPTIONS_RIGHTCLICKCOMMAND,
						DlgComboBox_GetCurSel(hDlg,IDC_OPTIONS_RIGHTCLICKCOMMAND));
				m_MiddleClickCommand=
					(int)DlgComboBox_GetItemData(hDlg,IDC_OPTIONS_MIDDLECLICKCOMMAND,
						DlgComboBox_GetCurSel(hDlg,IDC_OPTIONS_MIDDLECLICKCOMMAND));

				m_VolumeStep=DlgEdit_GetInt(hDlg,IDC_OPTIONS_VOLUMESTEP);
				m_AudioDelayStep=DlgEdit_GetInt(hDlg,IDC_OPTIONS_AUDIODELAYSTEP);

				m_fChanged=true;
			}
			break;
		}
		break;
	}

	return FALSE;
}
Exemple #3
0
INT_PTR CMenuOptions::DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg) {
	case WM_INITDIALOG:
		::SetDlgItemInt(hDlg,IDC_MENUOPTIONS_MAXCHANNELMENUROWS,m_MaxChannelMenuRows,TRUE);
		DlgUpDown_SetRange(hDlg,IDC_MENUOPTIONS_MAXCHANNELMENUROWS_SPIN,1,100);

		::SetDlgItemInt(hDlg,IDC_MENUOPTIONS_MAXCHANNELMENUEVENTINFO,m_MaxChannelMenuEventInfo,TRUE);
		DlgUpDown_SetRange(hDlg,IDC_MENUOPTIONS_MAXCHANNELMENUEVENTINFO_SPIN,0,100);

		{
			HWND hwndList=::GetDlgItem(hDlg,IDC_MENUOPTIONS_ITEMLIST);
			ListView_SetExtendedListViewStyle(hwndList,
				LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP);

			RECT rc;
			::GetClientRect(hwndList,&rc);
			LVCOLUMN lvc;
			lvc.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
			lvc.fmt=LVCFMT_LEFT;
			lvc.cx=rc.right-::GetSystemMetrics(SM_CXVSCROLL);
			lvc.pszText=TEXT("");
			lvc.iSubItem=0;
			ListView_InsertColumn(hwndList,0,&lvc);

			m_fChanging=true;

			LVITEM lvi;
			TCHAR szText[CCommandList::MAX_COMMAND_NAME];
			lvi.mask=LVIF_TEXT | LVIF_PARAM;
			lvi.iSubItem=0;
			lvi.pszText=szText;

			for (int i=0;i<(int)m_MenuItemList.size();i++) {
				int ID=m_MenuItemList[i].ID;
				GetItemText(ID,szText,lengthof(szText));
				lvi.iItem=i;
				lvi.lParam=ID;
				lvi.iItem=ListView_InsertItem(hwndList,&lvi);
				ListView_SetCheckState(hwndList,lvi.iItem,m_MenuItemList[i].fVisible);
			}

			m_fChanging=false;
		}
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_MENUOPTIONS_ITEMLIST_UP:
		case IDC_MENUOPTIONS_ITEMLIST_DOWN:
			{
				HWND hwndList=::GetDlgItem(hDlg,IDC_MENUOPTIONS_ITEMLIST);
				int From=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED),To;

				if (From>=0) {
					if (LOWORD(wParam)==IDC_MENUOPTIONS_ITEMLIST_UP) {
						if (From<1)
							break;
						To=From-1;
					} else {
						if (From+1>=ListView_GetItemCount(hwndList))
							break;
						To=From+1;
					}
					m_fChanging=true;
					LVITEM lvi;
					TCHAR szText[CCommandList::MAX_COMMAND_NAME];
					lvi.mask=LVIF_STATE | LVIF_TEXT | LVIF_PARAM;
					lvi.iItem=From;
					lvi.iSubItem=0;
					lvi.stateMask=~0U;
					lvi.pszText=szText;
					lvi.cchTextMax=lengthof(szText);
					ListView_GetItem(hwndList,&lvi);
					BOOL fChecked=ListView_GetCheckState(hwndList,From);
					ListView_DeleteItem(hwndList,From);
					lvi.iItem=To;
					ListView_InsertItem(hwndList,&lvi);
					ListView_SetCheckState(hwndList,To,fChecked);
					SetDlgItemState(hDlg);
					m_fChanging=false;
				}
			}
			return TRUE;

		case IDC_MENUOPTIONS_ITEMLIST_INSERTSEPARATOR:
			{
				HWND hwndList=::GetDlgItem(hDlg,IDC_MENUOPTIONS_ITEMLIST);
				int Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);

				if (Sel>=0) {
					LVITEM lvi;
					TCHAR szText[CCommandList::MAX_COMMAND_NAME];

					m_fChanging=true;
					GetItemText(MENU_ID_SEPARATOR,szText,lengthof(szText));
					lvi.mask=LVIF_TEXT | LVIF_PARAM;
					lvi.iItem=Sel;
					lvi.iSubItem=0;
					lvi.pszText=szText;
					lvi.lParam=MENU_ID_SEPARATOR;
					ListView_InsertItem(hwndList,&lvi);
					ListView_SetItemState(hwndList,Sel,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED);
					ListView_SetCheckState(hwndList,Sel,TRUE);
					SetDlgItemState(hDlg);
					m_fChanging=false;
				}
			}
			return TRUE;

		case IDC_MENUOPTIONS_ITEMLIST_REMOVESEPARATOR:
			{
				HWND hwndList=::GetDlgItem(hDlg,IDC_MENUOPTIONS_ITEMLIST);
				int Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);

				if (Sel>=0) {
					if (GetListViewItemParam(hwndList,Sel)==MENU_ID_SEPARATOR) {
						m_fChanging=true;
						ListView_DeleteItem(hwndList,Sel);
						SetDlgItemState(hDlg);
						m_fChanging=false;
					}
				}
			}
			return TRUE;

		case IDC_MENUOPTIONS_ITEMLIST_DEFAULT:
			{
				HWND hwndList=::GetDlgItem(hDlg,IDC_MENUOPTIONS_ITEMLIST);

				m_fChanging=true;

				ListView_DeleteAllItems(hwndList);

				LVITEM lvi;
				TCHAR szText[CCommandList::MAX_COMMAND_NAME];
				lvi.mask=LVIF_TEXT | LVIF_PARAM;
				lvi.iSubItem=0;
				lvi.pszText=szText;

				for (int i=0;i<lengthof(m_DefaultMenuItemList);i++) {
					int ID=m_DefaultMenuItemList[i].ID;
					GetItemText(ID,szText,lengthof(szText));
					lvi.iItem=i;
					lvi.lParam=ID;
					lvi.iItem=ListView_InsertItem(hwndList,&lvi);
					ListView_SetCheckState(hwndList,lvi.iItem,TRUE);
				}

				SetDlgItemState(hDlg);

				m_fChanging=false;
			}
			return TRUE;
		}
		return TRUE;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case LVN_ITEMCHANGED:
			if (!m_fChanging)
				SetDlgItemState(hDlg);
			return TRUE;

		case PSN_APPLY:
			{
				int Value;

				Value=::GetDlgItemInt(hDlg,IDC_MENUOPTIONS_MAXCHANNELMENUROWS,NULL,TRUE);
				if (Value>0)
					m_MaxChannelMenuRows=Value;

				Value=::GetDlgItemInt(hDlg,IDC_MENUOPTIONS_MAXCHANNELMENUEVENTINFO,NULL,TRUE);
				m_MaxChannelMenuEventInfo=Value;
			}

			{
				HWND hwndList=::GetDlgItem(hDlg,IDC_MENUOPTIONS_ITEMLIST);
				const int ItemCount=ListView_GetItemCount(hwndList);

				m_MenuItemList.resize(ItemCount);

				LVITEM lvi;
				lvi.mask=LVIF_STATE | LVIF_PARAM;
				lvi.iSubItem=0;
				lvi.stateMask=~0U;

				for (int i=0;i<ItemCount;i++) {
					lvi.iItem=i;
					ListView_GetItem(hwndList,&lvi);
					m_MenuItemList[i].ID=(int)lvi.lParam;
					m_MenuItemList[i].fVisible=(lvi.state & LVIS_STATEIMAGEMASK)==INDEXTOSTATEIMAGEMASK(2);
				}
			}

			m_fChanged=true;
			return TRUE;
		}
		break;
	}

	return FALSE;
}