📄 netmanagerdlg.cpp
字号:
{
AfxMessageBox("Error: The INI file contains odd number of exe-files items.\nThere is an invalid item. Repair it!\nTerminating the application...");
CDialog::OnCancel();
return FALSE;
}
else
{
int j = m_pPageFiles->m_psArrayExeNames->GetSize();
for(i = 0; i <= (j - 2); i += 2)
m_pPageFiles->m_pArrayAutoStart->Add(g_pThisApp->GetProfileInt("Files Exe", m_pPageFiles->m_psArrayExeNames->GetAt(i), 0));
}
// net ----------------------------------------------------------------------
m_pPageNet->m_psArrayNet = new CStringArray;
IniToStringArray("Net URLs", "File", m_pPageNet->m_psArrayNet);
m_pPageNet->m_psArrayNetLastModified = new CStringArray;
i = 0;
int j = m_pPageNet->m_psArrayNet->GetSize();
while(i <= (j - 2))
{
m_pPageNet->m_psArrayNetLastModified->Add(g_pThisApp->GetProfileString("Net URLs", m_pPageNet->m_psArrayNet->GetAt(i), "not tested"));
i += 2;
}
// menu ---------------------------------------------------------------------
CMenu* pMenu = GetMenu();
if(g_pThisApp->GetProfileInt("NetManager", "Starting", 0))
{
pMenu->CheckMenuItem(IDM_STARTING, MF_CHECKED | MF_BYCOMMAND);
g_bStarting = true;
}
else
{
pMenu->CheckMenuItem(IDM_STARTING, MF_UNCHECKED | MF_BYCOMMAND);
g_bStarting = false;
}
if(g_pThisApp->GetProfileInt("NetManager", "Ending", 0))
{
pMenu->CheckMenuItem(IDM_ENDING, MF_CHECKED | MF_BYCOMMAND);
g_bEnding = true;
}
else
{
pMenu->CheckMenuItem(IDM_ENDING, MF_UNCHECKED | MF_BYCOMMAND);
g_bEnding = false;
}
if(g_pThisApp->GetProfileInt("NetManager", "AutoNetMonitoring", 0))
{
pMenu->CheckMenuItem(IDM_NETMONITORING, MF_CHECKED | MF_BYCOMMAND);
g_bNetMonitoring = true;
}
else
{
pMenu->CheckMenuItem(IDM_NETMONITORING, MF_UNCHECKED | MF_BYCOMMAND);
g_bNetMonitoring = false;
}
if(g_pThisApp->GetProfileInt("NetManager", "AutoPeopleMonitoring", 0))
{
pMenu->CheckMenuItem(IDM_PEOPLEMONITORING, MF_CHECKED | MF_BYCOMMAND);
g_bPeopleMonitoring = true;
}
else
{
pMenu->CheckMenuItem(IDM_PEOPLEMONITORING, MF_UNCHECKED | MF_BYCOMMAND);
g_bPeopleMonitoring = false;
}
if(g_pThisApp->GetProfileInt("NetManager", "AutoSaveSettings", 1))
{
pMenu->CheckMenuItem(IDM_AUTOSAVE, MF_CHECKED | MF_BYCOMMAND);
g_bAutoSaveSettings = true;
}
else
{
pMenu->CheckMenuItem(IDM_AUTOSAVE, MF_UNCHECKED | MF_BYCOMMAND);
g_bAutoSaveSettings = false;
}
if(g_pThisApp->GetProfileInt("NetManager", "WindowMaximizing", 1))
{
pMenu->CheckMenuItem(IDM_NOTIFICATION_WIN, MF_CHECKED | MF_BYCOMMAND);
g_bWinNotification = true;
}
else
{
pMenu->CheckMenuItem(IDM_NOTIFICATION_ICON, MF_CHECKED | MF_BYCOMMAND);
g_bWinNotification = false;
}
if(g_pThisApp->GetProfileInt("NetManager", "ExeImages", 0))
{
pMenu->CheckMenuItem(IDM_EXEIMAGES_LARGE, MF_CHECKED | MF_BYCOMMAND);
g_bExeImages = true;
}
else
{
pMenu->CheckMenuItem(IDM_EXEIMAGES_SMALL, MF_CHECKED | MF_BYCOMMAND);
g_bExeImages = false;
}
if(g_pThisApp->GetProfileInt("NetManager", "PeopleImages", 0))
{
pMenu->CheckMenuItem(IDM_PEOPLEIMAGES_LARGE, MF_CHECKED | MF_BYCOMMAND);
g_bPeopleImages = true;
}
else
{
pMenu->CheckMenuItem(IDM_PEOPLEIMAGES_SMALL, MF_CHECKED | MF_BYCOMMAND);
g_bPeopleImages = false;
}
m_pPageNet->m_nNetMinutes = g_pThisApp->GetProfileInt("Net", "Minutes", 60);
m_pPagePeople->m_nPeopleMinutes = g_pThisApp->GetProfileInt("People", "Minutes", 3);
m_pPageFiles->m_sSourceCopyFile = g_pThisApp->GetProfileString("Files Copy", "Source", "x:/sourcefile");
m_pPageFiles->m_sDestCopyFile = g_pThisApp->GetProfileString("Files Copy", "Destination", "d:/destinationfile");
m_pPageYou->m_sServerName = g_pThisApp->GetProfileString("You", "Server", "server-name");
m_pPageYou->m_sUserName = g_pThisApp->GetProfileString("You", "User", "user-name");
m_pPageYou->m_sPassword = g_pThisApp->GetProfileString("You", "Password", "password");
m_pPageYou->m_sSourceFile1 = g_pThisApp->GetProfileString("You", "SourceFileOn", "x:/sourcefile.htm");
m_pPageYou->m_sSourceFile2 = g_pThisApp->GetProfileString("You", "SourceFileOff", "x:/destinationfile.htm");
m_pPageYou->m_sDestinationDir = g_pThisApp->GetProfileString("You", "DestinationDir", "html");
m_pPageYou->m_sDestination = g_pThisApp->GetProfileString("You", "DestinationName", "filename.html");
m_pPageYou->m_sTagMachine = g_pThisApp->GetProfileString("You", "TagMachine", "-MACHINE-");
m_pPageYou->m_sTagDate = g_pThisApp->GetProfileString("You", "TagDate", "-DATE-");
m_pPageMail->m_psArrayMailServer = new CStringArray;
IniToStringArray("Mail Server", "server name", m_pPageMail->m_psArrayMailServer);
m_pPageMail->m_psArrayMailProgram = new CStringArray;
IniToStringArray("Mail Program", "NetManager", m_pPageMail->m_psArrayMailProgram);
m_pPageMail->m_psArrayMailFrom = new CStringArray;
IniToStringArray("Mail From", "Your Name <You@server.domain.cz>", m_pPageMail->m_psArrayMailFrom);
m_pPageMail->m_psArrayMailTo = new CStringArray;
IniToStringArray("Mail To", "Name <to@server.domain.cz>", m_pPageMail->m_psArrayMailTo);
m_pPageMail->m_psArrayMailSubject = new CStringArray;
IniToStringArray("Mail Subject", "no subject", m_pPageMail->m_psArrayMailSubject);
m_pPageMail->m_psArrayMailSignature = new CStringArray;
IniToStringArray("Mail Signature", "---------- used NetManager ----------", m_pPageMail->m_psArrayMailSignature);
// fill out tree control ----------------------------------------------------
CStringArray* psServersArray = new CStringArray;
m_pPagePeople->m_pAllServersArray = new CPtrArray;
CStringArray* pServerArray;
IniToStringArray("People Servers", "server.domain.cz", psServersArray);
i = 0;
j = psServersArray->GetSize();
while(i != j)
{
pServerArray = new CStringArray;
m_pPagePeople->m_pAllServersArray->Add(pServerArray);
pServerArray->Add(psServersArray->GetAt(i));
IniToStringArray(psServersArray->GetAt(i), "user", pServerArray);
i++;
}
m_nHistoryFontSize = g_pThisApp->GetProfileInt("NetManager", "HistoryFontSize", 8);
m_sHistoryFontFace = g_pThisApp->GetProfileString("NetManager", "HistoryFontFace", "Arial");
m_nOutputFontSize = g_pThisApp->GetProfileInt("NetManager", "OutputFontSize", 10);
m_sOutputFontFace = g_pThisApp->GetProfileString("NetManager", "OutputFontFace", "Courier");
// init prop. sheet ---------------------------------------------------------
m_dlgPropSheet->AddPage(m_pPageGeneral);
m_dlgPropSheet->AddPage(m_pPageFiles);
m_dlgPropSheet->AddPage(m_pPageYou);
m_dlgPropSheet->AddPage(m_pPageNet);
m_dlgPropSheet->AddPage(m_pPagePeople);
m_dlgPropSheet->AddPage(m_pPageMail);
m_dlgPropSheet->Create(this, WS_CHILD | WS_VISIBLE, 0);
m_dlgPropSheet->ModifyStyle(0, WS_TABSTOP);
m_dlgPropSheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT);
CImageList* pButtonImages = new CImageList;
pButtonImages->Create(16, 16, ILC_COLORDDB | ILC_MASK, 5, 0);
pButtonImages->Add(g_pThisApp->LoadIcon(IDI_GENERAL));
pButtonImages->Add(g_pThisApp->LoadIcon(IDI_FILES));
pButtonImages->Add(g_pThisApp->LoadIcon(IDI_YOU));
pButtonImages->Add(g_pThisApp->LoadIcon(IDI_NET));
pButtonImages->Add(g_pThisApp->LoadIcon(IDI_PEOPLE));
pButtonImages->Add(g_pThisApp->LoadIcon(IDI_MAIL));
CTabCtrl *pTab = m_dlgPropSheet->GetTabControl();
pTab->SetImageList(pButtonImages);
TC_ITEM tcItem;
tcItem.mask = TCIF_IMAGE;
for(i = 0; i < 6; i++)
{
tcItem.iImage = i;
pTab->SetItem(i, &tcItem);
}
CRect rcSheet;
GetWindowRect(&rcSheet);
m_dlgPropSheet->SetWindowPos(NULL, rcSheet.left - 4, rcSheet.top - 4, rcSheet.Width(), rcSheet.Height(),
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
m_pHistoryFont = new CFont;
if(!(m_pHistoryFont->CreatePointFont(m_nHistoryFontSize * 10, m_sHistoryFontFace)))
m_pHistoryFont->CreateFont(0, 0, 1, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, 0, 0, NULL);
m_History.SetFont(m_pHistoryFont);
m_pOutputFont = new CFont;
if(!(m_pOutputFont->CreatePointFont(m_nOutputFontSize * 10, m_sOutputFontFace)))
m_pOutputFont->CreateFont(0, 0, 1, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, 0, 0, NULL);
m_Output.SetFont(m_pOutputFont);
m_dlgPropSheet->SetActivePage(1);
m_dlgPropSheet->SetActivePage(2);
m_dlgPropSheet->SetActivePage(3);
m_dlgPropSheet->SetActivePage(4);
m_dlgPropSheet->SetActivePage(5);
m_dlgPropSheet->SetActivePage(0);
int nWindowWidth = g_pThisApp->GetProfileInt("NetManager", "WindowWidth", DLG_MIN_WIDTH);
int nMaxWindowWidth = DLG_MAX_WIDTH;
if(nWindowWidth > nMaxWindowWidth)
nWindowWidth = nMaxWindowWidth;
CRect rcDlg;
GetWindowRect(&rcDlg);
m_nDlgDefaultWidth = rcDlg.Width(); // right - rcDlg.left;
rcDlg.right = rcDlg.left + nWindowWidth;
MoveWindow(rcDlg);
///////////////////////////////////////////////////////////////////////////
// Create status bar at the bottom of the dialog window
if(m_StatusBar.Create(this))
{
m_StatusBar.SetIndicators(auIDStatusBar, sizeof(auIDStatusBar) / sizeof(UINT));
m_StatusBar.SetWindowText("NetManager");
m_StatusBar.SetPaneInfo(0, m_StatusBar.GetItemID(0), SBPS_STRETCH, NULL );
}
else
AfxMessageBox("Error - Statusbar");
// We need to resize the dialog to make room for control bars.
// First, figure out how big the control bars are.
CRect rcClientStart;
CRect rcClientNow;
GetClientRect(rcClientStart);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow);
// Now move all the controls so they are in the same relative
// position within the remaining client area as they would be
// with no control bars.
CPoint ptOffset(rcClientNow.left - rcClientStart.left, rcClientNow.top - rcClientStart.top);
CRect rcChild;
CWnd* pwndChild = GetWindow(GW_CHILD);
while (pwndChild)
{
pwndChild->GetWindowRect(rcChild);
ScreenToClient(rcChild);
rcChild.OffsetRect(ptOffset);
pwndChild->MoveWindow(rcChild, FALSE);
pwndChild = pwndChild->GetNextWindow();
}
// Adjust the dialog window dimensions
CRect rcWindow;
GetWindowRect(rcWindow);
rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
MoveWindow(rcWindow, FALSE);
// And position the control bars
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
// Dialog windows resizing //////////////////////////////////////////////////
GetClientRect(&rcDlg);
m_nDlgHeight = 10 + rcDlg.Height() + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYSIZE);
ResizeWindows();
// for menu (number of lines)
CRect rc;
GetClientRect(rc);
m_nDlgClientHeight = rc.Height();
/*
CRect rcOriginal;
GetClientRect(rcOriginal);
if(rcOriginal.Height() < (rc.Height() + GetSystemMetrics(SM_CYMENUSIZE)))
{
m_nDlgHeight += GetSystemMetrics(SM_CYMENUSIZE);
m_nDlgClientHeight += GetSystemMetrics(SM_CYMENUSIZE);
}
*/
/////////////////////////////////////////////////////////////////////////////
m_pPageGeneral->CreateRootNode();
// IP Address ---------------------------------------------------------------
unsigned long ulIpAddress = 0;
hostent* pHostent;// = new HOSTENT;
char abHostName[255];
if((!gethostname(abHostName, sizeof(abHostName))) &&
((pHostent = gethostbyname(abHostName)) != NULL) &&
(pHostent->h_length == 4))
{
CopyMemory(&ulIpAddress, pHostent->h_addr, 4);
}
in_addr inaddr;
inaddr.s_addr = ulIpAddress;
CString sIpAddress = inet_ntoa(inaddr);
if((pHostent = gethostbyaddr((LPCSTR)&ulIpAddress, 4, PF_INET)) != NULL)
strcpy(abHostName, pHostent->h_name);
m_pPageYou->m_sIP = sIpAddress;
m_pPageYou->m_sIPName = abHostName;
m_bDlgCreated = true;
return TRUE; // return TRUE unless you set the focus to a control
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::ResizeWindows()
{
CRect rcDlg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -