⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 greenbrowseroptions.cpp

📁 用VC写的浏览器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGestureProp, CSAPrefsSubDlg)
	//{{AFX_MSG_MAP(CGestureProp)
	ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
	ON_BN_CLICKED(IDC_NEW, OnNew)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST, OnItemchangedList)
	ON_BN_CLICKED(IDC_UP, OnUp)
	ON_BN_CLICKED(IDC_DOWN, OnDown)
	ON_BN_CLICKED(IDC_LEFT, OnLeft)
	ON_BN_CLICKED(IDC_RIGHT, OnRight)
	ON_BN_CLICKED(IDC_DELETE, OnDelete)
	ON_BN_CLICKED(IDC_BACK, OnBack)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGestureProp message handlers
void CGestureProp::OnNew()
{
	m_gesture.SetWindowText("");
	m_command.SetCurSel(-1);
	m_nLastIdx = MAX_MOUSE_ACTION;
}

void CGestureProp::OnUpdate() 
{
	// TODO: Add your control notification handler code here
	CString strGesture;
	m_gesture.GetWindowText(strGesture);
	if (strGesture.GetLength()<1)
		return;
	int nCurSel = m_command.GetCurSel();
	if (nCurSel<0)
		return;
	CString strItem;
	int count = m_list.GetItemCount();
	for (int i=0; i<count; i++)
	{
		strItem = m_list.GetItemText(i,0);
		if (strItem == strGesture)
			break;
	}
	if (i==count)
		m_list.InsertItem(count,strGesture);
	m_command.GetLBText(nCurSel, strGesture);
	m_list.SetItemText(i,1,strGesture);
	m_list.SetItemData(i,m_command.GetItemData(nCurSel));
	LIST_FOCUS_POS (m_list, i);
}

void CGestureProp::OnDelete() 
{
	// TODO: Add your control notification handler code here
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	int current = m_list.GetNextSelectedItem(pos);
	if (current<MAX_MOUSE_ACTION)
	{
		CString str;
		LOADSTR(str,IDS_NONE);
		m_list.SetItemText(current,1,str);
		m_list.SetItemData(current,0);
		return;
	}
	m_list.DeleteItem(current);
	LIST_FOCUS_POS(m_list,current);
}

void CGestureProp::OnItemchangedList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	int i=-1, nIndex = pNMListView->iItem;
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	if(pos!=NULL)
		i = m_list.GetNextSelectedItem(pos);
	if(nIndex==i)
	{
		m_gesture.SetWindowText(m_list.GetItemText(nIndex,0));
		m_command.SelectString(0,m_list.GetItemText(nIndex,1));
	}
	else
	{
		m_gesture.SetWindowText("");
		m_command.SetCurSel(-1);
	}
	m_nLastIdx = i;
	*pResult = 0;
}

void CGestureProp::OnDeltaposSpin(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	int nItem = -1, newItem;
	if(pos!=NULL)
	{
		nItem = m_list.GetNextSelectedItem(pos);
		if (nItem<MAX_MOUSE_ACTION)
			goto _myexit;
		if(pNMUpDown->iDelta<0)
			newItem = nItem -1;
		else
			newItem = nItem + 1;
		if (newItem<MAX_MOUSE_ACTION)
			goto _myexit;
		int n = m_list.GetItemCount();
		if(newItem>=0 && newItem<n)
		{
			CString str = m_list.GetItemText(nItem,0);
			CString str2 = m_list.GetItemText(nItem, 1);
			DWORD   bState = m_list.GetItemData(nItem);
			m_list.DeleteItem(nItem);

			m_list.InsertItem(newItem, str);
			m_list.SetItemText(newItem, 1, str2);
			m_list.SetItemState(newItem, LVIS_SELECTED, LVIS_SELECTED);
			m_list.SetItemData(newItem, bState);
			m_list.EnsureVisible(newItem, FALSE);
		}
	}

_myexit:
	*pResult = 0;
}

void CGestureProp::GetMenuItemString(CString &strName, int nID)
{
	int count = m_command.GetCount();
	for (int i=0;i<count;i++)
	{
		if (m_command.GetItemData(i) == (DWORD)nID)
			m_command.GetLBText(i,strName);
	}
}

BOOL CGestureProp::OnInitDialog()
{
#ifdef _WRITE_LNG_FILE_
	_WriteDlgString(this,"DialogMouseProp");
#endif
	LOADDLG("DialogMouseProp");
	CSAPrefsSubDlg::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_list.SetExtendedStyle(m_list.GetExtendedStyle()| LVS_EX_FULLROWSELECT);
	// TODO: Add extra initialization here
	CRect rect;
	CString str;
	LOADSTR(str ,IDS_NAME);
	m_list.InsertColumn(0,str);
	m_list.GetWindowRect(rect);
	m_list.SetColumnWidth(0, 120);
	LOADSTR(str ,IDS_COMMAND);
	m_list.InsertColumn(1,str);
	m_list.SetColumnWidth(1, rect.Width()-150);
	//
	_LoadMenuString2ComboBox(pmf->GetMenu(),&m_command);
	//load mouse item
	LOADSTR(str ,IDS_LEFT_CLICK);m_list.InsertItem(0,str);m_list.SetItemData(0,m_nLButtonDown);
	GetMenuItemString(str,m_nLButtonDown);m_list.SetItemText(0,1,str);
	//
	LOADSTR(str ,IDS_LEFT_DBCLICK);m_list.InsertItem(1,str);m_list.SetItemData(1,m_nLDbClick);
	GetMenuItemString(str,m_nLDbClick);m_list.SetItemText(1,1,str);
	//
	LOADSTR(str ,IDS_MIDDLE_CLICK);m_list.InsertItem(2,str);m_list.SetItemData(2,m_nMButtonDown);
	GetMenuItemString(str,m_nMButtonDown);m_list.SetItemText(2,1,str);
	//
	LOADSTR(str ,IDS_RIGHT_CLICK);m_list.InsertItem(3,str);m_list.SetItemData(3,m_nRButtonDown);
	GetMenuItemString(str,m_nRButtonDown);m_list.SetItemText(3,1,str);
	//
	LOADSTR(str ,IDS_LEFT_RIGHT);m_list.InsertItem(4,str);m_list.SetItemData(4,m_nLeftRight);
	GetMenuItemString(str,m_nLeftRight);m_list.SetItemText(4,1,str);
	//
	LOADSTR(str ,IDS_RIGHT_LEFT);m_list.InsertItem(5,str);m_list.SetItemData(5,m_nRightLeft);
	GetMenuItemString(str,m_nRightLeft);m_list.SetItemText(5,1,str);
	//
	CGesture *item;
	CString strUp,strDown,strLeft,strRight;
	if (theApp.m_bUseLngFile)
	{
		LOADSTR(strUp,IDS_UP);
		LOADSTR(strDown,IDS_DOWN);
		LOADSTR(strLeft,IDS_LEFT);
		LOADSTR(strRight,IDS_RIGHT);
	}
	CString strItem;
	for(int i=0;i<=pmf->m_GestureList.m_Gestures.GetUpperBound();i++)
	{
		item = pmf->m_GestureList.m_Gestures.GetAt(i);
		strItem = item->gesture;
		if (theApp.m_bUseLngFile)
		{
			strItem.Replace("U",strUp);
			strItem.Replace("D",strDown);
			strItem.Replace("L",strLeft);
			strItem.Replace("R",strRight);
		}
		m_list.InsertItem(i+MAX_MOUSE_ACTION, strItem);
		//
		GetMenuItemString(strItem,item->command);
		m_list.SetItemText(i+MAX_MOUSE_ACTION, 1, strItem);
		m_list.SetItemData(i+MAX_MOUSE_ACTION,item->command);
	}
	//
	if (theApp.m_bUseLngFile)
	{
		GetDlgItem(IDC_UP)->SetWindowText(strUp);
		GetDlgItem(IDC_DOWN)->SetWindowText(strDown);
		GetDlgItem(IDC_LEFT)->SetWindowText(strLeft);
		GetDlgItem(IDC_RIGHT)->SetWindowText(strRight);
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CGestureProp::OnOK() 
{
	CString strUp,strDown,strLeft,strRight;
	if (theApp.m_bUseLngFile)
	{
		LOADSTR(strUp,IDS_UP);
		LOADSTR(strDown,IDS_DOWN);
		LOADSTR(strLeft,IDS_LEFT);
		LOADSTR(strRight,IDS_RIGHT);
	}
	//
	CGesture *ps;
	pmf->m_GestureList.Clean();
	int n = m_list.GetItemCount();
	for( int i=MAX_MOUSE_ACTION; i<n; i++)
	{
		ps = new CGesture;
		ps->gesture = m_list.GetItemText(i,0);
		if (theApp.m_bUseLngFile)
		{
			ps->gesture.Replace(strUp,"U");
			ps->gesture.Replace(strDown,"D");
			ps->gesture.Replace(strLeft,"L");
			ps->gesture.Replace(strRight,"R");
		}
		//
		ps->command = m_list.GetItemData(i);
		pmf->m_GestureList.m_Gestures.Add(ps);
	}
	pmf->m_GestureList.SaveGestureList();
	//
	m_nLButtonDown = m_list.GetItemData(0);
	m_nLDbClick = m_list.GetItemData(1);
	m_nMButtonDown = m_list.GetItemData(2);
	m_nRButtonDown = m_list.GetItemData(3);
	m_nLeftRight = m_list.GetItemData(4);
	m_nRightLeft = m_list.GetItemData(5);
	//
	CSAPrefsSubDlg::OnOK();
}

void CGestureProp::InputOneGesture(int id) 
{
	if (m_nLastIdx>=0 && m_nLastIdx < MAX_MOUSE_ACTION )
		return;

	CString str;
	m_gesture.GetWindowText(str);

	CString strArrow;
	LOADSTR(strArrow,id);
	
	int nArrowLen = strArrow.GetLength();
	if (str.GetLength()>=8*nArrowLen)
		return;
	if (str.GetLength())
	{
		if (strArrow == str.Right(nArrowLen))
			return;
	}
	str += strArrow;
	m_gesture.SetWindowText(str);
}

void CGestureProp::OnUp() 
{
	// TODO: Add your control notification handler code here
	InputOneGesture(IDS_UP);
}

void CGestureProp::OnDown() 
{
	// TODO: Add your control notification handler code here
	InputOneGesture(IDS_DOWN);
}

void CGestureProp::OnLeft() 
{
	// TODO: Add your control notification handler code here
	InputOneGesture(IDS_LEFT);
}

void CGestureProp::OnRight() 
{
	// TODO: Add your control notification handler code here
	InputOneGesture(IDS_RIGHT);
}

void CGestureProp::OnBack() 
{
	// TODO: Add your control notification handler code here
	if (m_nLastIdx>=0 && m_nLastIdx < MAX_MOUSE_ACTION )
		return;
	CString str;
	CString strArrow;
	LOADSTR(strArrow,IDS_UP);
	m_gesture.GetWindowText(str);
	if (str.GetLength())
	{
		int len = strArrow.GetLength();
		str = str.Left(str.GetLength()-len);
	}
	m_gesture.SetWindowText(str);
}

void COtherProp::OnShowTray() 
{
	// TODO: Add your control notification handler code here
	CButton *p = (CButton*)GetDlgItem(IDC_SHOW_TRAY);
	BOOL state = p->GetCheck();
	p = (CButton*)GetDlgItem(IDC_MIN_TRAY);
	p->SetCheck(state);
	p = (CButton*)GetDlgItem(IDC_CLOSE_TRAY);
	p->SetCheck(state);
}

BOOL CMouseProp::OnInitDialog() 
{
#ifdef _WRITE_LNG_FILE_
	_WriteDlgString(this,"DialogMouseDragProp");
#endif
	CSAPrefsSubDlg::OnInitDialog();
#ifdef _WRITE_LNG_FILE_
	_WriteDlgComboBox(this,"DialogMouseDragProp");
#endif
	LOADDLG("DialogMouseDragProp");
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

WORD COtherProp::Mod2HotKey(WORD key)
{
	WORD temp=0;
	if (key&MOD_ALT)
		temp |= HOTKEYF_ALT;
	if (key&MOD_CONTROL)
		temp |= HOTKEYF_CONTROL;
	if (key&MOD_SHIFT)
		temp |= HOTKEYF_SHIFT;
	return temp;
}

WORD COtherProp::HotKey2Mod(WORD key)
{
	WORD temp=0;
	if (key&HOTKEYF_ALT)
		temp |= MOD_ALT;
	if (key&HOTKEYF_CONTROL)
		temp |= MOD_CONTROL;
	if (key&HOTKEYF_SHIFT)
		temp |= MOD_SHIFT;
	return temp;
}

void COtherProp::OnUpdateHotkey() 
{
	// TODO: Add your control notification handler code here
	WORD Modifiers, Key;
	WORD temp=0;
	m_HotKey.GetHotKey(Key, Modifiers);
	Modifiers = HotKey2Mod(Modifiers);//HOTKEYF_ALT != MOD_ALT !!!
	if (Key<=0)
	{
		if(MSGBOX(IDS_REG_HOTKEY_NULL, MB_YESNO|MB_ICONQUESTION)==IDYES)
		{
			AfxGetApp()->WriteProfileInt("Settings", "ShowHideModifiers", 0);
			AfxGetApp()->WriteProfileInt("Settings", "ShowHideKey", 0);
			UnregisterHotKey (pmf->m_hWnd, 0);
			return;
		}
		m_HotKey.SetHotKey(m_OldKey, Mod2HotKey(m_OldModifiers));
		return;
	}
	UnregisterHotKey (pmf->m_hWnd, 0);
	g_bRegisterHotKeyOk = RegisterHotKey ( pmf->m_hWnd, 0, Modifiers , Key);
	if (!g_bRegisterHotKeyOk)
	{
		MSGBOX(IDS_REG_HOTKEY_FAIL);
		//back to old key
		g_bRegisterHotKeyOk = RegisterHotKey ( pmf->m_hWnd, 0, m_OldModifiers , m_OldKey);
	}
	else
	{
		AfxGetApp()->WriteProfileInt("Settings", "ShowHideModifiers", Modifiers);
		AfxGetApp()->WriteProfileInt("Settings", "ShowHideKey", Key);
		m_OldModifiers = Modifiers;
		m_OldKey = Key;
		MSGBOX(IDS_REG_HOTKEY_OK);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CToolbarProp dialog
IMPLEMENT_DYNCREATE(CToolbarProp, CSAPrefsSubDlg)

CToolbarProp::CToolbarProp() : CSAPrefsSubDlg(CToolbarProp::IDD)
{
	//{{AFX_DATA_INIT(CToolbarProp)
	m_bShowToolbarLabel = TRUE;
	m_bComboShowIcon = FALSE;
	m_bGoProxyMenu = FALSE;
	m_bShowSearchBarButton = FALSE;
	m_bShowAddressBarButton = FALSE;
	//}}AFX_DATA_INIT
}

CToolbarProp::~CToolbarProp()
{
}

void CToolbarProp::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CToolbarProp)
	DDX_Check(pDX, ID_TB_LABEL, m_bShowToolbarLabel);
	DDX_Check(pDX, ID_TB_COMBO_ICON, m_bComboShowIcon);
	DDX_Check(pDX, IDC_GO_PROXY_MENU, m_bGoProxyMenu);
	DDX_Check(pDX, ID_SEARCH_BUTTON, m_bShowSearchBarButton);
	DDX_Check(pDX, ID_ADDRESS_BUTTON, m_bShowAddressBarButton);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CToolbarProp, CSAPrefsSubDlg)
	//{{AFX_MSG_MAP(CToolbarProp)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CToolbarProp message handlers

BOOL CToolbarProp::OnInitDialog() 
{
#ifdef _WRITE_LNG_FILE_
	_WriteDlgString(this,"DialogToolbarProp");
#endif
	LOADDLG("DialogToolbarProp");
	CSAPrefsSubDlg::OnInitDialog();
	
	// TODO: Add extra initialization here
	int id,index;
	CButton *pWnd; 
	index = 1;
	for (id=IDC_FS_TOOL;id<=IDC_FS_STATUS;id++)
	{
		pWnd = (CButton*)GetDlgItem(id);
		pWnd->SetCheck(m_dwFsShow & index);
		index *= 2;
	}
	index = 1;
	for (id=IDC_FS_TOOL2;id<=IDC_FS_STATUS2;id++)
	{
		pWnd = (CButton*)GetDlgItem(id);
		pWnd->SetCheck(m_dwAhShow & index);
		index *= 2;
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CToolbarProp::OnOK() 
{
	// TODO: Add your specialized code here and/or call the base class
	int id,index;
	CButton *pWnd;

	m_dwFsShow = 0;
	index = 1;
	for (id=IDC_FS_TOOL;id<=IDC_FS_STATUS;id++)
	{
		pWnd = (CButton*)GetDlgItem(id);
		if (pWnd->GetCheck())
			m_dwFsShow |= index;
		index *= 2;
	}
	//
	m_dwAhShow = 0;
	index = 1;
	for (id=IDC_FS_TOOL2;id<=IDC_FS_STATUS2;id++)
	{
		pWnd = (CButton*)GetDlgItem(id);
		if (pWnd->GetCheck())
			m_dwAhShow |= index;
		index *= 2;
	}
	CSAPrefsSubDlg::OnOK();
}
/////////////////////////////////////////////////////////////////////////////
// CMenuProp property page

IMPLEMENT_DYNCREATE(CMenuProp, CSAPrefsSubDlg)

CMenuProp::CMenuProp() : CSAPrefsSubDlg(CMenuProp::IDD)
{
	//{{AFX_DATA_INIT(CMenuProp)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -