📄 mainfrm.cpp
字号:
theWindowTab.SetWindowPos(0,rc.left,rc.top,rc.Width(),
rc.Height(), SWP_NOZORDER);
}
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::OnMyWindowList()
//
// PURPOSE :
//
// PARAMETERS : none
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::OnMyWindowList()
{
theViewManager.DoWindowList();
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::OnWindowAutosave()
//
// PURPOSE :
//
// PARAMETERS : none
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::OnWindowAutosave()
{
CMenu* pTopMenu = AfxGetMainWnd()->GetMenu();
CMenu* pMenu = pTopMenu->GetSubMenu(4);
if (pMenu->GetMenuState(ID_WINDOW_AUTOSAVE,MF_BYCOMMAND | MF_CHECKED) == MF_CHECKED) {
pMenu->CheckMenuItem(ID_WINDOW_AUTOSAVE,MF_BYCOMMAND | MF_UNCHECKED);
m_wndStatusBar.SetPaneText(2,"",TRUE);
KillTimer(ID_TIMER_AUTOSAVE);
}
else {
CDialogAutoSave dlg;
dlg.m_delay = m_delay;
dlg.m_filename = m_file;
if (dlg.DoModal()==IDOK) {
pMenu->CheckMenuItem(ID_WINDOW_AUTOSAVE,MF_BYCOMMAND | MF_CHECKED);
m_wndStatusBar.SetPaneText(2,"AS",TRUE);
m_delay = dlg.m_delay;
m_file = dlg.m_filename;
AfxGetApp()->WriteProfileInt("Settings","Autosave_delay",m_delay);
AfxGetApp()->WriteProfileString("Settings","Autosave_file",m_file);
SetTimer(ID_TIMER_AUTOSAVE,m_delay*1000,NULL);
}
}
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::SaveUrlList(CString)
//
// PURPOSE :
//
// PARAMETERS :
// file -
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::SaveUrlList(CString file)
{
if (m_lUrl.IsEmpty()) {
return;
}
CFile f;
// we will create an HTM file containing the links to these URL's
if (!f.Open(file, CFile::modeCreate | CFile::modeWrite))
{
// an error occured
AfxMessageBox(CString(LPCTSTR(IDS_FILEERROR)));
return;
}
CString liste;
char *buf;
POSITION p;
p=m_lUrl.GetHeadPosition();
while (p!=NULL) {
CString s = m_lUrl.GetNext(p);
if (s.GetLength() != 0) {
liste += s;
liste += "\r\n";
}
}
// we have the list in 'liste'
buf = (char*)malloc((liste.GetLength()+1)*sizeof(char));
buf[0]='\0';
strcpy(buf,(LPCTSTR)(liste));
f.Write(buf,liste.GetLength());
free(buf);
f.Close();
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::OnTimer(UINT)
//
// PURPOSE :
//
// PARAMETERS :
// nIDEvent -
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::OnTimer(UINT nIDEvent)
{
if (nIDEvent == ID_TIMER_AUTOSAVE) {
m_wndStatusBar.SetPaneText(0,CString(LPCTSTR(IDS_AUTOSAVE)),TRUE);
SaveUrlList(m_file);
}
CMDIFrameWnd::OnTimer(nIDEvent);
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::GetURL()
//
// PURPOSE : get the URL for the history from the registry
//
// PARAMETERS : none
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::GetURL()
{
CWinApp* pApp = AfxGetApp();
CString url;
CString name;
int i=0;
// entries in the registry from url1 to url25 !
HistoryList.RemoveAll();
HistoryList.InsertAt(0,""); // dummy value
for(i=1;i<26;i++){
name.Format("url%d",i);
url = pApp->GetProfileString("History",name,"");
if (url!="") {
HistoryList.InsertAt(1,url,1);
// add the URL the the history
COMBOBOXEXITEM item;
item.mask = CBEIF_TEXT;
item.iItem = -1; // insert at the end. So the order is keeped
item.pszText = (LPTSTR)(LPCTSTR)url;
m_wndAddress.InsertItem(&item);
}
else
return;
}
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::AddURL(CString)
//
// PURPOSE : add an url to the History and save it !
//
// PARAMETERS :
// url -
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::AddURL(CString url)
{
CWinApp* pApp = AfxGetApp();
CString name;
int i;
// entries in the registry from url1 to url25 !
HistoryList.InsertAt(1,url,1); //insert in head position
if (HistoryList.GetSize() == 27) { // 25 elements + dummy
HistoryList.RemoveAt(26,1);
HistoryList.FreeExtra();
}
int n = HistoryList.GetSize(); // include entry 0: dummy !
for(i=1;i<n;i++) {
name.Format("url%d",i);
url = HistoryList.GetAt(i);
if (url!="")
pApp->WriteProfileString("History",name,url);
}
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::DoNothing()
//
// PURPOSE :
//
// PARAMETERS : none
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::DoNothing()
{
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::OnDropDown(NMHDR*,LRESULT*)
//
// PURPOSE :
//
// PARAMETERS :
// pNotifyStruct -
// pResult -
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult)
{
// this function handles the dropdown menus from the toolbar
NMTOOLBAR* pNMToolBar = (NMTOOLBAR*)pNotifyStruct;
CRect rect;
// translate the current toolbar item rectangle into screen coordinates
// so that we'll know where to pop up the menu
m_wndToolBar.GetToolBarCtrl().GetRect(pNMToolBar->iItem, &rect);
rect.top = rect.bottom;
::ClientToScreen(pNMToolBar->hdr.hwndFrom, &rect.TopLeft());
if(pNMToolBar->iItem == ID_FONT_DROPDOWN)
{
CMenu menu;
CMenu* pPopup;
// the font popup is stored in a resource
menu.LoadMenu(IDR_FONT_POPUP);
pPopup = menu.GetSubMenu(0);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
}
*pResult = TBDDRET_DEFAULT;
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::OnFavFloat()
//
// PURPOSE :
//
// PARAMETERS : none
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::OnFavFloat()
{
static CDialogFav dlg;
if (dlg.GetSafeHwnd() == 0) {
TCHAR sz[MAX_PATH];
TCHAR szPath[MAX_PATH];
HKEY hKey;
DWORD dwSize;
// find out from the registry where the favorites are located.
if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"), &hKey) != ERROR_SUCCESS)
{
TRACE0("Favorites folder not found\n");
return;
}
dwSize = sizeof(sz);
RegQueryValueEx(hKey, _T("Favorites"), NULL, NULL, (LPBYTE)sz, &dwSize);
ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
RegCloseKey(hKey);
dlg.m_DefaultPath.Format("%s",szPath);
dlg.m_pMain = (CMainFrame *)AfxGetApp()->m_pMainWnd;
dlg.Create(IDD_DIALOGFAV);
}
dlg.ShowWindow(SW_SHOW);
}
/*
*******************************************************************************/
// FUNCTION : void CMainFrame::OnDebug()
//
// PURPOSE :
//
// PARAMETERS : none
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CMainFrame::OnDebug()
{
CString str; //current txt
static CString old = "";
static BOOL added;
static CString LastAdded = "";
CString found;
if (added) {
added = FALSE;
return;
}
m_wndAddress.GetEditCtrl()->GetWindowText(str);
int taille = str.GetLength();
if (taille == 0) {
str = old = LastAdded = "";
return;
}
////////////////////////////////////////
/* CString dbg;
dbg.Format("%d",str.GetLength());
m_wndStatusBar.SetPaneText(0,dbg,TRUE);*/
////////////////////////////////////////
if (old == str)
return;
// check if we just deleted a caracter
old = str;
int i, icount = m_wndAddress.GetCount();
for (i=0;i<icount;i++) {
CString s;
m_wndAddress.GetLBText(i,s);
if (s.Left(taille) == str) {
found = s;
break;
}
}
if (found.Left(taille) != str) {
LastAdded = "";
return;
}
// ok, lets update the selection.
// we know that a new call will be done !
added = TRUE;
m_wndAddress.GetEditCtrl()->SetWindowText(found);
m_wndAddress.GetEditCtrl()->SetSel(taille,found.GetLength(),TRUE);
LastAdded = found;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -