📄 simtooldlg.cpp
字号:
SetConnStatus(FALSE);
theApp.m_wndStatusBar.SetPaneInfo(theApp.m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED),
ID_INDICATOR_OFFLINELED, SBPS_NOBORDERS, 14);
}
// 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);
return TRUE;
}
BOOL CSIMTOOLDlg::RegSoft()
{
CString strRegSN;
char sn[255];
memset(sn, 0, 255);
strRegSN = theApp.GetRegSN();
sprintf(sn, "%s", strRegSN);
if (strRegSN.GetLength() != 0) // 注册码已经注册
{
if (theApp.CheckSN(sn)) // 注册码正确
{
return TRUE;
}
else // 注册码错误
{
if (m_SNDlg.DoModal() == IDOK)
{
strRegSN = theApp.GetRegSN();
sprintf(sn, "%s", strRegSN);
if (theApp.CheckSN(sn))
{
return TRUE;
}
else
{
MessageBox("无效的注册码", "AWS");
theApp.mobile.CloseComm();
return FALSE;
}
}
else
{
theApp.mobile.CloseComm();
return FALSE;
}
}
}
else // 注册码还未注册
{
if (m_SNDlg.DoModal() == IDOK)
{
strRegSN = theApp.GetRegSN();
sprintf(sn, "%s", strRegSN);
if (theApp.CheckSN(sn))
{
return TRUE;
}
else
{
MessageBox("无效的注册码", "AWS");
theApp.mobile.CloseComm();
return FALSE;
}
}
else
{
theApp.mobile.CloseComm();
return FALSE;
}
}
}
void CSIMTOOLDlg::ActivatePage(int nIndex)
{
// make sure outlookbar has correct selection
m_OutlookBar.SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
switch(nIndex)
{
//case 0:
//m_LogPage.ShowWindow(SW_SHOW);
//m_PBPage.ShowWindow(SW_HIDE);
//m_SMSPage.ShowWindow(SW_HIDE);
//m_InfoBar.SetText("系统日志");
//break;
case 0:
//m_LogPage.ShowWindow(SW_HIDE);
m_PBPage.ShowWindow(SW_SHOW);
m_SMSPage.ShowWindow(SW_HIDE);
m_DialupPage.ShowWindow(SW_HIDE);
m_SendPage.ShowWindow(SW_HIDE);
//m_StatPage.ShowWindow(SW_HIDE);
m_InfoBar.SetText("电话簿");
break;
case 1:
//m_LogPage.ShowWindow(SW_HIDE);
m_PBPage.ShowWindow(SW_HIDE);
m_SMSPage.ShowWindow(SW_SHOW);
m_DialupPage.ShowWindow(SW_HIDE);
m_SendPage.ShowWindow(SW_HIDE);
//m_StatPage.ShowWindow(SW_HIDE);
m_InfoBar.SetText("读短信息");
break;
case 2:
//m_LogPage.ShowWindow(SW_HIDE);
m_PBPage.ShowWindow(SW_HIDE);
m_SMSPage.ShowWindow(SW_HIDE);
m_DialupPage.ShowWindow(SW_HIDE);
m_SendPage.ShowWindow(SW_SHOW);
//m_StatPage.ShowWindow(SW_HIDE);
m_InfoBar.SetText("写短信息");
break;
case 3:
//m_LogPage.ShowWindow(SW_HIDE);
m_PBPage.ShowWindow(SW_HIDE);
m_SMSPage.ShowWindow(SW_HIDE);
m_DialupPage.ShowWindow(SW_SHOW);
m_SendPage.ShowWindow(SW_HIDE);
//m_StatPage.ShowWindow(SW_HIDE);
m_InfoBar.SetText("拨号上网");
break;
case 4:
m_PBPage.ShowWindow(SW_HIDE);
m_SMSPage.ShowWindow(SW_HIDE);
m_DialupPage.ShowWindow(SW_HIDE);
m_SendPage.ShowWindow(SW_HIDE);
//m_StatPage.ShowWindow(SW_SHOW);
m_InfoBar.SetText("上网统计");
break;
default:
break;
}
MoveChilds();
}
void CSIMTOOLDlg::MoveChilds()
{
// position property pages
CRect rcDlgs;
// get dialog area rect
GetDlgItem(IDC_DIALOG_AREA)->GetWindowRect(rcDlgs);
ScreenToClient(rcDlgs);
//m_LogPage.MoveWindow(rcDlgs);
m_PBPage.MoveWindow(rcDlgs);
m_SMSPage.MoveWindow(rcDlgs);
m_DialupPage.MoveWindow(rcDlgs);
m_SendPage.MoveWindow(rcDlgs);
//m_StatPage.MoveWindow(rcDlgs);
}
void CSIMTOOLDlg::OnSize(UINT nType, int cx, int cy)
{
CDialogResize::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if (m_bInitialized)
MoveChilds();
}
void CSIMTOOLDlg::OnClickOutlookbar(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int nIndex = m_OutlookBar.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
if(nIndex == -1)
return;
ActivatePage(nIndex);
*pResult = 0;
}
void CSIMTOOLDlg::SetOnlineLed(BOOL bOnline)
{
HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
bOnline ? MAKEINTRESOURCE(IDI_LED_GREEN) : MAKEINTRESOURCE(IDI_LED_OFF),
IMAGE_ICON, 16, 16, LR_SHARED);
theApp.m_wndStatusBar.GetStatusBarCtrl().SetIcon(theApp.m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), hIcon);
theApp.m_wndStatusBar.GetStatusBarCtrl().Invalidate();
theApp.m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
DestroyIcon(hIcon);
}
void CSIMTOOLDlg::SetOfflineLed(BOOL bOffline)
{
HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
bOffline ? MAKEINTRESOURCE(IDI_LED_RED) : MAKEINTRESOURCE(IDI_LED_OFF),
IMAGE_ICON, 16, 16, LR_SHARED);
theApp.m_wndStatusBar.GetStatusBarCtrl().SetIcon(theApp.m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), hIcon);
theApp.m_wndStatusBar.GetStatusBarCtrl().Invalidate();
theApp.m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
DestroyIcon(hIcon);
}
void CSIMTOOLDlg::SetConnStatus(BOOL bConnStatus)
{
/*
HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
bConnStatus ? MAKEINTRESOURCE(IDI_SBDIALUP) : MAKEINTRESOURCE(IDI_SBHANDUP),
IMAGE_ICON, 16, 16, LR_SHARED);
*/
HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_LOGO),
IMAGE_ICON, 16, 16, LR_SHARED);
theApp.m_wndStatusBar.GetStatusBarCtrl().SetIcon(theApp.m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), hIcon);
theApp.m_wndStatusBar.GetStatusBarCtrl().Invalidate();
theApp.m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
DestroyIcon(hIcon);
}
void CSIMTOOLDlg::SetConnShow(int iIco)
{
HICON hIcon;
switch(iIco)
{
case 0:
hIcon= (HICON)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_SBDIALUP),
IMAGE_ICON, 16, 16, LR_SHARED);
break;
case 1:
hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_SBCONN1),
IMAGE_ICON, 16, 16, LR_SHARED);
break;
case 2:
hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_SBCONN2),
IMAGE_ICON, 16, 16, LR_SHARED);
break;
case 3:
hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_SBCONN3),
IMAGE_ICON, 16, 16, LR_SHARED);
break;
default:
HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_SBDIALUP),
IMAGE_ICON, 16, 16, LR_SHARED);
break;
}
theApp.m_wndStatusBar.GetStatusBarCtrl().SetIcon(theApp.m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), hIcon);
theApp.m_wndStatusBar.GetStatusBarCtrl().Invalidate();
theApp.m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
DestroyIcon(hIcon);
}
BOOL CSIMTOOLDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (m_hWnd)
{
if (IsWindow(m_ToolTipCtrl.m_hWnd))
m_ToolTipCtrl.RelayEvent(pMsg);
}
return CDialogResize::PreTranslateMessage(pMsg);
}
BOOL CSIMTOOLDlg::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);
// need to handle both ANSI and UNICODE versions of the message
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
TCHAR szFullText[256];
CString cstTipText;
CString cstStatusText;
UINT nID = pNMHDR->idFrom;
if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
{
// idFrom is actually the HWND of the tool
nID = ((UINT)(WORD)::GetDlgCtrlID((HWND)nID));
}
if (nID != 0) // will be zero on a separator
{
AfxLoadString(nID, szFullText);
// this is the command id, not the button index
AfxExtractSubString(cstTipText, szFullText, 1, '\n');
AfxExtractSubString(cstStatusText, szFullText, 0, '\n');
}
// Non-UNICODE Strings only are shown in the tooltip window...
if (pNMHDR->code == TTN_NEEDTEXTA)
lstrcpyn(pTTTA->szText, cstTipText,
(sizeof(pTTTA->szText)/sizeof(pTTTA->szText[0])));
else
_mbstowcsz(pTTTW->szText, cstTipText,
(sizeof(pTTTW->szText)/sizeof(pTTTW->szText[0])));
*pResult = 0;
// bring the tooltip window above other popup windows
::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE);
// message was handled
return TRUE;
}
void CSIMTOOLDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if (AfxGetApp()->GetProfileInt("Settings", "SavePosition", 1))
{
// Save main window position
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
AfxGetApp()->WriteProfileInt("Settings", "FrameStatus", wp.showCmd);
AfxGetApp()->WriteProfileInt("Settings", "FrameTop", wp.rcNormalPosition.top);
AfxGetApp()->WriteProfileInt("Settings", "FrameLeft", wp.rcNormalPosition.left);
AfxGetApp()->WriteProfileInt("Settings", "FrameBottom", wp.rcNormalPosition.bottom);
AfxGetApp()->WriteProfileInt("Settings", "FrameRight", wp.rcNormalPosition.right);
}
CDialog::OnClose();
}
void CSIMTOOLDlg::OnOK()
{
return;
}
void CSIMTOOLDlg::OnCancel()
{
return;
}
void CSIMTOOLDlg::OnSysexit()
{
// TODO: Add your command handler code here
if (MessageBox("确定要退出此软件?", "AWS",MB_YESNO|MB_ICONQUESTION) == IDNO)
{
return;
}
//m_StatPage.SetInfo(m_ConnTime, m_sSpeed, m_sSent, m_sRecv);
theApp.HandUpConn();
SetConnStatus(FALSE);
//SetStatusText("网络连接已断开");
CDialog::OnClose();
CDialog::OnOK();
}
void CSIMTOOLDlg::OnUpdateViewPhonebook(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(m_PBPage.IsWindowVisible());
}
void CSIMTOOLDlg::OnUpdateViewDialup(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(m_SMSPage.IsWindowVisible());
}
void CSIMTOOLDlg::OnUpdateViewSms(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(m_DialupPage.IsWindowVisible());
}
void CSIMTOOLDlg::OnViewPhonebook()
{
// TODO: Add your command handler code here
ActivatePage(0);
}
void CSIMTOOLDlg::OnViewDialup()
{
// TODO: Add your command handler code here
ActivatePage(3);
}
void CSIMTOOLDlg::OnViewSms()
{
// TODO: Add your command handler code here
ActivatePage(1);
}
void CSIMTOOLDlg::OnAboutbox()
{
// TODO: Add your command handler code here
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
void CSIMTOOLDlg::OnViewWritesms()
{
// TODO: Add your command handler code here
ActivatePage(2);
}
void CSIMTOOLDlg::OnUpdateViewWritesms(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
//pCmdUI->SetRadio(m_DialupPage.IsWindowVisible());
}
void CSIMTOOLDlg::OnDialup()
{
// TODO: Add your command handler code here
m_dialdlg.DoModal();
}
void CSIMTOOLDlg::OnHandup()
{
// TODO: Add your command handler code here
//m_StatPage.SetInfo(m_ConnTime, m_sSpeed, m_sSent, m_sRecv);
theApp.HandUpConn();
SetConnStatus(FALSE);
//SetStatusText("网络连接已断开");
}
void CSIMTOOLDlg::OnViewConnstat()
{
// TODO: Add your command handler code here
ActivatePage(4);
}
void CSIMTOOLDlg::OnUpdateViewConnstat(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(m_StatPage.IsWindowVisible());
}
void CSIMTOOLDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
CDialogResize::OnTimer(nIDEvent);
}
CString CSIMTOOLDlg::L2S(LONG l)
{
CString ret;
sprintf(ret.GetBuffer(512), "%ld", l);
ret.ReleaseBuffer();
return ret;
}
void CSIMTOOLDlg::OnStartTimer()
{
m_nTimer = SetTimer(1, 1000, 0);
}
void CSIMTOOLDlg::OnStopTimer()
{
KillTimer(m_nTimer);
}
void CSIMTOOLDlg::OnShow()
{
// TODO: Add your command handler code here
ShowWindow(SW_SHOW);
}
void CSIMTOOLDlg::OnUpdateDialup(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
//pCmdUI->Enable(!theApp.GetConnected());
}
void CSIMTOOLDlg::OnUpdateHandup(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
//pCmdUI->Enable(theApp.GetConnected());
}
void CSIMTOOLDlg::OnDialupphone()
{
// TODO: Add your command handler code here
m_DialPhoneDlg.DoModal();
}
void CSIMTOOLDlg::OnUpdateDialupphone(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CSIMTOOLDlg::OnCommset()
{
// TODO: Add your command handler code here
m_CommSetDlg.DoModal();
}
void CSIMTOOLDlg::OnHelpcontent()
{
// TODO: Add your command handler code here
char filepath[MAX_PATH];
CString strdir;
memset(filepath, 0, MAX_PATH);
strdir = theApp.GetAppPath();
sprintf(filepath, "%s\\GPRSHelp.chm", strdir);
ShellExecute(NULL, "open", filepath, NULL, NULL, SW_SHOWNORMAL);
}
void CSIMTOOLDlg::OnVolume()
{
// TODO: Add your command handler code here
m_VolDlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -