📄 netmanagerdlg.cpp
字号:
GetWindowRect(&rcDlg);
if(rcDlg.Width() > DLG_MIN_WIDTH)
GetDlgItem(IDB_SHOW_OUTPUT)->SetWindowText("Hide <<");
else
GetDlgItem(IDB_SHOW_OUTPUT)->SetWindowText("Show >>");
CRect rcTabCtrl;
m_OutputTabCtrl.GetWindowRect(&rcTabCtrl);
rcTabCtrl.right = rcDlg.right - 3;
ScreenToClient(&rcTabCtrl);
m_OutputTabCtrl.MoveWindow(rcTabCtrl);
CRect rcOutput;
m_Output.GetWindowRect(&rcOutput);
ScreenToClient(&rcOutput);
rcTabCtrl.left += 2;
rcTabCtrl.right -= 4;
rcTabCtrl.top = rcOutput.top;
rcTabCtrl.bottom -= 3;
m_Output.MoveWindow(rcTabCtrl);
m_History.MoveWindow(rcTabCtrl);
CRect rcInfoTree;
CRect rcInfoWindow;
m_InfoTree.GetWindowRect(&rcInfoTree);
m_InfoWindow.GetWindowRect(&rcInfoWindow);
ScreenToClient(&rcInfoTree);
ScreenToClient(&rcInfoWindow);
int nWork = rcTabCtrl.bottom;
rcTabCtrl.bottom = rcInfoTree.bottom;
m_InfoTree.MoveWindow(rcTabCtrl);
rcTabCtrl.top = rcInfoWindow.top;
rcTabCtrl.bottom = nWork;
m_InfoWindow.MoveWindow(rcTabCtrl);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::IniToStringArray(LPCTSTR lpszTag, LPCTSTR lpszDefault, CStringArray* psArray)
{
char* ps_INI_Buffer = new char[64000];
DWORD nStringsNum = GetPrivateProfileString(lpszTag, NULL, NULL, ps_INI_Buffer, 64000, m_sIniFilePath);
if(nStringsNum == 0)
{
strcpy(ps_INI_Buffer, lpszDefault);
nStringsNum = strlen(lpszDefault);
}
psArray->Add(ps_INI_Buffer);
DWORD dwCounter = 0;
while(dwCounter != (nStringsNum-1))
{
if(*(ps_INI_Buffer + dwCounter) == '\0')
psArray->Add(ps_INI_Buffer + dwCounter + 1);
dwCounter++;
}
delete ps_INI_Buffer;
}
/////////////////////////////////////////////////////////////////////////////
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CNetManagerDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
DrawLogoText();
if(g_bStarting && !m_bStarted)
{
m_bStarted = true;
OnStart();
}
}
}
/////////////////////////////////////////////////////////////////////////////
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CNetManagerDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::DrawLogoText()
{
CWindowDC dc(this);
CString m_LogoText = "NetManager";
CFont m_fontLogo;
dc.SetBkMode(TRANSPARENT);
CRect rectText;
rectText.left = 400;
rectText.top = GetSystemMetrics(SM_CYSIZE) + 2;
rectText.bottom = rectText.top + 18;
rectText.right = 650;
CFont* OldFont = dc.SelectObject(&m_fontLogo);
COLORREF OldColor = dc.SetTextColor(::GetSysColor( COLOR_3DHILIGHT)); // draw text in DC
dc.DrawText(m_LogoText, rectText + CPoint(1,1), DT_SINGLELINE | DT_LEFT | DT_VCENTER);
dc.SetTextColor(::GetSysColor( COLOR_3DSHADOW));
dc.DrawText(m_LogoText, rectText, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
dc.SetTextColor(OldColor); // restore old text color
dc.SelectObject(OldFont); // restore old font
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnCancel()
{
int nResult = MessageBox("Really Quit???", NULL, MB_ICONQUESTION | MB_YESNO);
if(nResult != IDNO)
{
if(g_bEnding)
OnEnd();
if(g_bAutoSaveSettings)
SaveSettings();
CDialog::EndDialog(0);
}
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnShowOutput()
{
CRect rect;
GetWindowRect(&rect);
if(rect.Width() > DLG_MIN_WIDTH)
HideOutput();
else
ShowOutput();
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::ShowOutput()
{
CRect rcDlg;
GetWindowRect(&rcDlg);
rcDlg.right = rcDlg.left + m_nDlgDefaultWidth;
GetDlgItem(IDB_SHOW_OUTPUT)->SetWindowText("Show >>");
MoveWindow(rcDlg);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::HideOutput()
{
CRect rcDlg;
GetWindowRect(&rcDlg);
rcDlg.right = rcDlg.left + DLG_MIN_WIDTH;
GetDlgItem(IDB_SHOW_OUTPUT)->SetWindowText("Hide <<");
MoveWindow(rcDlg);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnStart()
{
m_dlgPropSheet->SetActivePage(0);
g_WriteToHistory(TRUE, ">>> NETMANAGER FUNCTIONS STARTED <<<");
// files
if(m_pPageFiles->m_CopyOnStart.GetCheck())
m_pPageFiles->FilesCopy();
int i = 0;
int j = m_pPageFiles->m_pArrayAutoStart->GetSize();
while(i != j)
{
if(m_pPageFiles->m_pArrayAutoStart->GetAt(i))
m_pPageFiles->FilesExecute(i);
i++;
}
// net
if(m_pPageNet->m_OnStart.GetCheck())
{
g_AnimateWait->Play(0, -1, -1);
CString sOutput;
m_pPageNet->CheckAll(sOutput);
g_WriteToHistory(TRUE, sOutput);
}
// people
if(m_pPagePeople->m_OnStart.GetCheck())
{
g_AnimateWait->Play(0, -1, -1);
m_pPagePeople->ResetServersAndUsers();
CString sOutput;
m_pPagePeople->CheckAll(sOutput);
g_WriteToHistory(TRUE, sOutput);
}
// you
if(m_pPageYou->m_OnlineOnStart.GetCheck())
m_pPageYou->OnOnline();
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnEnd()
{
m_dlgPropSheet->SetActivePage(0);
g_WriteToHistory(TRUE, ">>> NETMANAGER FUNCTIONS FINISHED <<<");
if(m_pPageFiles->m_ReturnOnEnd.GetCheck())
m_pPageFiles->FilesReturn();
if(m_pPageFiles->m_DeleteOnEnd.GetCheck())
m_pPageFiles->FilesDelete();
if(m_pPageYou->m_OfflineOnEnd.GetCheck())
m_pPageYou->OnOffline();
// people
if(m_pPagePeople->m_OnEnd.GetCheck())
{
g_AnimateWait->Play(0, -1, -1);
m_pPagePeople->ResetServersAndUsers();
CString sOutput;
m_pPagePeople->CheckAll(sOutput);
g_WriteToHistory(TRUE, sOutput);
}
// net
if(m_pPageNet->m_OnEnd.GetCheck())
{
g_AnimateWait->Play(0, -1, -1);
CString sOutput;
m_pPageNet->CheckAll(sOutput);
g_WriteToHistory(TRUE, sOutput);
}
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::OnTimer(UINT nIDEvent)
{
if(nIDEvent == TIMER_NET_ID)
{
CString sOutput;
if(m_pPageNet->CheckAll(sOutput))
{
MessageBeep(0);
if(g_bWinNotification)
{
ShowWindow(SW_SHOWMINIMIZED);
ShowWindow(SW_RESTORE);
}
else
{
m_BlinkState = true;
m_BlinkIcon = g_pThisApp->LoadIcon(IDI_NET);
SetTimer(TIMER_ICON_BLINKING_ID, 500, NULL);
}
g_WriteToHistory(TRUE, sOutput);
}
}
if(nIDEvent == TIMER_PEOPLE_ID)
{
CString sOutput;
if(m_pPagePeople->CheckAll(sOutput))
{
MessageBeep(0);
if(g_bWinNotification)
{
ShowWindow(SW_SHOWMINIMIZED);
ShowWindow(SW_RESTORE);
}
else
{
SetTimer(TIMER_ICON_BLINKING_ID, 500, NULL);
m_BlinkIcon = g_pThisApp->LoadIcon(IDI_PEOPLE);
}
g_WriteToHistory(TRUE, sOutput);
}
}
if(nIDEvent == TIMER_ICON_BLINKING_ID)
{
if(m_BlinkState ^= true)
{
g_pMainWnd->SetIcon(g_pThisApp->LoadIcon(IDR_MAINFRAME), FALSE);
g_pMainWnd->SetWindowText("NetManager");
}
else
{
g_pMainWnd->SetIcon(m_BlinkIcon, FALSE);
g_pMainWnd->SetWindowText("");
}
}
CDialog::OnTimer(nIDEvent);
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::SaveArrayToIni(LPCTSTR lpszTag, CStringArray* pArray)
{
int i = 0;
int j = pArray->GetSize();
while(i != j)
g_pThisApp->WriteProfileString(lpszTag, pArray->GetAt(i++), "");
}
/////////////////////////////////////////////////////////////////////////////
void CNetManagerDlg::SaveSettings()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -