📄 netmanagerdlg.cpp
字号:
// delete old items in INI file -------------------------------------------
g_pThisApp->WriteProfileString("NetManager", NULL, NULL);
g_pThisApp->WriteProfileString("Files Exe", NULL, NULL);
g_pThisApp->WriteProfileString("Files Copy", NULL, NULL);
g_pThisApp->WriteProfileString("You", NULL, NULL);
g_pThisApp->WriteProfileString("Net", NULL, NULL);
g_pThisApp->WriteProfileString("Net URLs", NULL, NULL);
g_pThisApp->WriteProfileString("Mail", NULL, NULL);
g_pThisApp->WriteProfileString("Mail Server", NULL, NULL);
g_pThisApp->WriteProfileString("Mail From", NULL, NULL);
g_pThisApp->WriteProfileString("Mail To", NULL, NULL);
g_pThisApp->WriteProfileString("Mail Subject", NULL, NULL);
g_pThisApp->WriteProfileString("Mail Program", NULL, NULL);
g_pThisApp->WriteProfileString("Mail Signature", NULL, NULL);
g_pThisApp->WriteProfileString("People", NULL, NULL);
CStringArray* psServersArray = new CStringArray;
IniToStringArray("People Servers", "server.domain.cz", psServersArray);
g_pThisApp->WriteProfileString("People Servers", NULL, NULL);
int j = psServersArray->GetSize();
for(int i = 0; i < j; i++)
g_pThisApp->WriteProfileString(psServersArray->GetAt(i), NULL, NULL); // smaze vsechny servry
// save new items ---------------------------------------------------------
m_dlgPropSheet->SetActivePage(0);
g_pThisApp->WriteProfileInt("NetManager", "Starting", g_bStarting);
g_pThisApp->WriteProfileInt("NetManager", "Ending", g_bEnding);
g_pThisApp->WriteProfileInt("NetManager", "AutoNetMonitoring", g_bNetMonitoring);
g_pThisApp->WriteProfileInt("NetManager", "AutoPeopleMonitoring", g_bPeopleMonitoring);
g_pThisApp->WriteProfileInt("NetManager", "AutoSaveSettings", g_bAutoSaveSettings);
g_pThisApp->WriteProfileInt("NetManager", "HistoryFontSize", m_nHistoryFontSize);
g_pThisApp->WriteProfileString("NetManager", "HistoryFontFace", m_sHistoryFontFace);
g_pThisApp->WriteProfileInt("NetManager", "OutputFontSize", m_nOutputFontSize);
g_pThisApp->WriteProfileString("NetManager", "OutputFontFace", m_sOutputFontFace);
g_pThisApp->WriteProfileInt("NetManager", "WindowMaximizing", g_bWinNotification);
g_pThisApp->WriteProfileInt("NetManager", "ExeImages", g_bExeImages);
g_pThisApp->WriteProfileInt("NetManager", "PeopleImages", g_bPeopleImages);
CRect rect;
GetWindowRect(&rect);
g_pThisApp->WriteProfileInt("NetManager", "WindowWidth", rect.Width());
g_pThisApp->WriteProfileInt("NetManager", "ExeWindowWidth", m_pPageFiles->m_ExeFiles.GetColumnWidth(0));
// files exe
m_pPageFiles->UpdateArray();
i = 0;
j = m_pPageFiles->m_psArrayExeNames->GetSize();
int k = 0;
while(i != j)
{
g_pThisApp->WriteProfileInt("Files Exe", m_pPageFiles->m_psArrayExeNames->GetAt(i++), m_pPageFiles->m_pArrayAutoStart->GetAt(k++));
g_pThisApp->WriteProfileString("Files Exe", m_pPageFiles->m_psArrayExeNames->GetAt(i++), "");
}
// others
g_pThisApp->WriteProfileString("Files Copy", "Source", m_pPageFiles->m_sSourceCopyFile);
g_pThisApp->WriteProfileString("Files Copy", "Destination", m_pPageFiles->m_sDestCopyFile);
g_pThisApp->WriteProfileInt("Files Copy", "CopyOnStart", m_pPageFiles->m_CopyOnStart.GetCheck());
g_pThisApp->WriteProfileInt("Files Copy", "ReturnOnEnd", m_pPageFiles->m_ReturnOnEnd.GetCheck());
g_pThisApp->WriteProfileInt("Files Copy", "DeleteOnEnd", m_pPageFiles->m_DeleteOnEnd.GetCheck());
// net
g_pThisApp->WriteProfileInt("Net", "OnStart", m_pPageNet->m_OnStart.GetCheck());
g_pThisApp->WriteProfileInt("Net", "OnEnd", m_pPageNet->m_OnEnd.GetCheck());
g_pThisApp->WriteProfileInt("Net", "Minutes", m_pPageNet->m_nNetMinutes);
i = 0;
j = m_pPageNet->m_psArrayNet->GetSize();
k = 0;
while(i != j)
{
g_pThisApp->WriteProfileString("Net URLs", m_pPageNet->m_psArrayNet->GetAt(i++), '"' + m_pPageNet->m_psArrayNetLastModified->GetAt(k++) + '"');
g_pThisApp->WriteProfileString("Net URLs", m_pPageNet->m_psArrayNet->GetAt(i++), "");
}
m_pPageYou->SaveSettings();
m_pPageMail->UpdateArrays(m_pPageMail->m_psArrayMailServer, &(m_pPageMail->m_Server));
SaveArrayToIni("Mail Server", m_pPageMail->m_psArrayMailServer);
m_pPageMail->UpdateArrays(m_pPageMail->m_psArrayMailFrom, &(m_pPageMail->m_From));
SaveArrayToIni("Mail From", m_pPageMail->m_psArrayMailFrom);
m_pPageMail->UpdateArrays(m_pPageMail->m_psArrayMailTo, &(m_pPageMail->m_To));
SaveArrayToIni("Mail To", m_pPageMail->m_psArrayMailTo);
m_pPageMail->UpdateArrays(m_pPageMail->m_psArrayMailSubject, &(m_pPageMail->m_Subject));
SaveArrayToIni("Mail Subject", m_pPageMail->m_psArrayMailSubject);
m_pPageMail->UpdateArrays(m_pPageMail->m_psArrayMailProgram, &(m_pPageMail->m_Program));
SaveArrayToIni("Mail Program", m_pPageMail->m_psArrayMailProgram);
SaveArrayToIni("Mail Signature", m_pPageMail->m_psArrayMailSignature);
g_pThisApp->WriteProfileInt("Mail", "Clear", m_pPageMail->m_Clear.GetCheck());
g_pThisApp->WriteProfileInt("Mail", "WithDate", m_pPageMail->m_WithDate.GetCheck());
g_pThisApp->WriteProfileInt("Mail", "WithSignature", m_pPageMail->m_WithSignature.GetCheck());
g_pThisApp->WriteProfileInt("Mail", "WithMailer", m_pPageMail->m_WithMailer.GetCheck());
g_pThisApp->WriteProfileInt("People", "OnStart", m_pPagePeople->m_OnStart.GetCheck());
g_pThisApp->WriteProfileInt("People", "OnEnd", m_pPagePeople->m_OnEnd.GetCheck());
g_pThisApp->WriteProfileInt("People", "Minutes", m_pPagePeople->m_nPeopleMinutes);
m_pPagePeople->SavePeople();
g_WriteToHistory(TRUE, ">>> SETTINGS SAVED <<<");
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnClearOutput()
{
if(m_OutputTabCtrl.GetCurSel() == 0)
{
m_History.SetReadOnly(FALSE);
m_History.SetSel(0, -1);
m_History.Clear();
m_History.SetReadOnly();
}
else
{
m_Output.SetReadOnly(FALSE);
m_Output.SetSel(0, -1);
m_Output.Clear();
m_Output.SetReadOnly();
}
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnChangeHistory()
{
CString sHistory;
m_History.GetWindowText(sHistory);
if(sHistory == "" && m_OutputTabCtrl.GetCurSel() == 0)
{
m_ClearOutput.EnableWindow(FALSE);
g_pMainWnd->GetMenu()->EnableMenuItem(IDM_OUTPUT_CLEAR, MF_GRAYED);
}
else
{
m_ClearOutput.EnableWindow(TRUE);
g_pMainWnd->GetMenu()->EnableMenuItem(IDM_OUTPUT_CLEAR, MF_ENABLED);
}
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnChangeOutput()
{
CString sOutput;
m_Output.GetWindowText(sOutput);
if(sOutput == "" && m_OutputTabCtrl.GetCurSel() == 1)
{
m_ClearOutput.EnableWindow(FALSE);
g_pMainWnd->GetMenu()->EnableMenuItem(IDM_OUTPUT_CLEAR, MF_GRAYED);
}
else
{
m_ClearOutput.EnableWindow(TRUE);
g_pMainWnd->GetMenu()->EnableMenuItem(IDM_OUTPUT_CLEAR, MF_ENABLED);
}
}
/////////////////////////////////////////////////////////////////////////////
BOOL CNetManagerDlg::OnHelpInfo(HELPINFO* pHelpInfo)
{
GoToHelp();
return 0; //CDialog::OnHelpInfo(pHelpInfo);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CDialog::OnActivate(nState, pWndOther, bMinimized);
KillTimer(TIMER_ICON_BLINKING_ID);
g_pMainWnd->SetIcon(g_pThisApp->LoadIcon(IDR_MAINFRAME), FALSE);
g_pMainWnd->SetWindowText("NetManager");
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnSelchangeTabctrlOutput(NMHDR* pNMHDR, LRESULT* pResult)
{
switch(m_OutputTabCtrl.GetCurSel())
{
case 0:
OnChangeHistory();
m_History.ShowWindow(SW_SHOWNA);
m_Output.ShowWindow(SW_HIDE);
m_InfoTree.ShowWindow(SW_HIDE);
m_InfoWindow.ShowWindow(SW_HIDE);
m_History.SetSel(-1, -1);
break;
case 1:
OnChangeOutput();
m_Output.ShowWindow(SW_SHOWNA);
m_History.ShowWindow(SW_HIDE);
m_InfoTree.ShowWindow(SW_HIDE);
m_InfoWindow.ShowWindow(SW_HIDE);
m_Output.SetSel(-1, -1);
break;
case 2:
GoToHelp();
break;
}
*pResult = 0;
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::GoToHelp()
{
m_OutputTabCtrl.SetCurSel(2);
m_InfoTree.ShowWindow(SW_SHOWNA);
m_InfoWindow.ShowWindow(SW_SHOWNA);
m_ClearOutput.EnableWindow(FALSE);
m_Output.ShowWindow(SW_HIDE);
m_History.ShowWindow(SW_HIDE);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnSelchangedInfotree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
CString sText;
sText.LoadString(m_InfoTree.GetItemData(m_InfoTree.GetSelectedItem()));
sText = g_MakeWindowsTextLines(sText);
m_InfoWindow.SetSel(0, -1);
m_InfoWindow.ReplaceSel(sText);
m_InfoWindow.SetSel(-1, -1);
*pResult = 0;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CNetManagerDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// if the cursor is not over a child window control, revert
// to the default status bar text
if(pWnd == this)
SetPaneText();
else
{
if(DYNAMIC_DOWNCAST(CComboBox, pWnd->GetOwner()))
SetPaneText(pWnd->GetOwner()->GetDlgCtrlID()); // only for combobox
else
SetPaneText(pWnd->GetDlgCtrlID()); // others controls
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::SetPaneText(UINT nID)
{
CString sText;
if(!sText.LoadString(nID) || nID == (UINT)m_StatusBar.GetDlgCtrlID())
sText = "NetManager";
m_StatusBar.SetPaneText(0, sText);
}
/////////////////////////////////////////////////////////////////////////////
BOOL CNetManagerDlg::PreTranslateMessage(MSG* pMsg)
{
{
// transate the message based on TTM_WINDOWFROMPOINT
MSG msg = *pMsg;
msg.hwnd = (HWND)m_ToolTip.SendMessage(TTM_WINDOWFROMPOINT, 0, (LPARAM)&msg.pt);
CPoint pt = pMsg->pt;
if (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST)
::ScreenToClient(msg.hwnd, &pt);
msg.lParam = MAKELONG(pt.x, pt.y);
// Let the ToolTip process this message.
m_ToolTip.RelayEvent(&msg);
}
/*
if(FromHandle(m_hWnd)->GetDlgCtrlID() == IDD_PAGE_FILES)
if(FromHandle(pMsg->hwnd) == m_dlgPropSheet)
if (m_hWnd)
{
m_ToolTip.RelayEvent (pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
return (FALSE);
*/
return CDialog::PreTranslateMessage(pMsg);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
{
CDialog::OnSettingChange(uFlags, lpszSection);
// for menu (more than 1 row of main menu (while resizing))
CRect rc;
GetClientRect(rc);
if(rc.Height() != m_nDlgClientHeight)
m_nDlgHeight += m_nDlgClientHeight - rc.Height(); // new height
RedrawWindow();
GetWindowRect(rc);
MoveWindow(rc);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu)
{
CDialog::OnMenuSelect(nItemID, nFlags, hSysMenu);
TCHAR szFullText[256];
CString cstStatusText;
if (nItemID != 0) // will be zero on a separator
{
AfxLoadString(nItemID, szFullText); // this is the command id, not the button index
AfxExtractSubString(cstStatusText, szFullText, 0, '\n');
m_StatusBar.SetPaneText(0, cstStatusText);
}
}
/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -