⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autodialdlg.cpp

📁 tel 自动拨号工具.自己开发的. 原来用这个工具打过不少免费电话
💻 CPP
字号:
// autodialDlg.cpp : implementation file
//

#include "stdafx.h"
#include "autodial.h"
#include "autodialDlg.h"
#include "UserAdd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAutodialDlg dialog

CAutodialDlg::CAutodialDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAutodialDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAutodialDlg)
	m_sCombo = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_pWnd=0;
	m_stateCopy=FALSE;
	m_stateTimer=0;
}

void CAutodialDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAutodialDlg)
	DDX_Control(pDX, IDC_LIST_PHONE, m_lCtrl);
	DDX_CBString(pDX, IDC_COMBO, m_sCombo);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAutodialDlg, CDialog)
	//{{AFX_MSG_MAP(CAutodialDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_NO_ADD, OnNoAdd)
	ON_BN_CLICKED(IDC_NO_DEL, OnNoDel)
	ON_BN_CLICKED(IDC_BTN_CALL, OnBtnCall)
	ON_NOTIFY(NM_CLICK, IDC_LIST_PHONE, OnClickListPhone)
	ON_BN_CLICKED(IDC_BTN_STOP, OnBtnStop)
	ON_WM_TIMER()
	ON_NOTIFY(NM_DBLCLK, IDC_LIST_PHONE, OnDblclkListPhone)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAutodialDlg message handlers

BOOL CAutodialDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here

	DWORD dwExStyle  = m_lCtrl.GetExtendedStyle();
	dwExStyle |= LVS_EX_FULLROWSELECT ;
	m_lCtrl.SetExtendedStyle(dwExStyle);



	m_lCtrl.SetBkColor(RGB(210,222,242));
	m_lCtrl.InsertColumn(0,"姓名",LVCFMT_LEFT,70,0);
	m_lCtrl.InsertColumn(1,"电话号码",LVCFMT_LEFT,108,-1);

	
	int nCount=::GetPrivateProfileInt("FriendInfo","Count",100,".\\autodial.ini"); 
	if(nCount!=100)
	{
		for(int i=0;i<=nCount;i++)
		{
			CString str,strtmp;
			str.Format("%d",i);
			::GetPrivateProfileString("FriendInfo",str+"Name",0,m_sName.GetBuffer(100),100,".\\autodial.ini"); 
			::GetPrivateProfileString("FriendInfo",str+"PhoneNumber",0,strtmp.GetBuffer(100),100,".\\autodial.ini"); 
			m_lCtrl.InsertItem(i,m_sName);
			m_lCtrl.SetItemText(i,1,strtmp);
		}
	}
	
	
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CAutodialDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// 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 CAutodialDlg::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();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CAutodialDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CAutodialDlg::OnNoAdd() 
{
//	m_lCtrl.InsertItem(0,"温健");//插入行

//	m_lCtrl.SetItemText(0,1,"13302151933");//	//设置该行的不同列的显示字符
	UserAdd ua;
	if(IDOK==ua.DoModal())
	{
		m_sCountry=ua.m_sCountry;
		m_sPhone=ua.m_sPhone;
		m_sName=ua.m_sName;
		
		int count=m_lCtrl.GetItemCount();
		m_lCtrl.InsertItem(count,m_sName);
		m_lCtrl.SetItemText(count,1,m_sCountry+m_sPhone);
		
		CString str;
		//count++;
		str.Format("%d",count);
		::WritePrivateProfileString("FriendInfo","count",str,".\\autodial.ini"); 
		::WritePrivateProfileString("FriendInfo",str+"Name",m_sName,".\\autodial.ini"); 
		::WritePrivateProfileString("FriendInfo",str+"PhoneNumber",m_sCountry+m_sPhone,".\\autodial.ini"); 
	}
}

void CAutodialDlg::OnNoDel() 
{
	int index=m_lCtrl.GetSelectedCount();
	if(index)
	{
		m_lCtrl.DeleteItem (m_lCtrl.GetSelectedCount()-1);	
	}
	CFile file(".\\autodial.ini",CFile::modeCreate | CFile::modeWrite);
	file.Close();

	int count=m_lCtrl.GetItemCount();

	for(int i=0;i<count;i++)
	{
		CString str;
		str.Format("%d",i);;
		::WritePrivateProfileString("FriendInfo","count",str,".\\autodial.ini"); 
		::WritePrivateProfileString("FriendInfo",str+"Name",m_lCtrl.GetItemText(i,0),".\\autodial.ini"); 
		::WritePrivateProfileString("FriendInfo",str+"PhoneNumber",m_lCtrl.GetItemText(i,1),".\\autodial.ini"); 
	}



/*	CString strCount,strIndex;
	int count=m_lCtrl.GetItemCount();
	count--;
	strCount.Format("%d",count);

	strIndex.Format("%d",index);

	::WritePrivateProfileString("FriendInfo","count",strCount,".\\autodial.ini"); 
	::WritePrivateProfileString("FriendInfo",strIndex+"Name","",".\\autodial.ini"); 
	::WritePrivateProfileString("FriendInfo",strIndex+"PhoneNumber","",".\\autodial.ini"); 
*/

}

void CAutodialDlg::OnBtnCall() 
{
	if(!m_stateTimer)
	{
		m_stateTimer=SetTimer(1,4000,NULL);
	}
}

void CAutodialDlg::OnClickListPhone(NMHDR* pNMHDR, LRESULT* pResult) 
{
	int index=m_lCtrl.GetSelectionMark();
	m_sCombo=m_lCtrl.GetItemText(index,1);
	GetDlgItem(IDC_COMBO)->SetWindowText(m_sCombo);
	UpdateData();
	*pResult = 0;
}

void CAutodialDlg::OnBtnStop() 
{
	m_stateTimer=0;
	KillTimer(1);		
}

void CAutodialDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if(!m_pWnd)
	{
		m_pWnd=FindDialBtn();
	}
	if(!m_stateCopy)
	{
		CString str;
		((CComboBox*)GetDlgItem(IDC_COMBO))->GetWindowText(str);
		((CComboBox*)GetDlgItem(IDC_COMBO))->AddString(str);
		CopyTextTo(str);
		m_stateCopy=TRUE;
	}
	m_pWnd->SendMessage(BM_CLICK);
	CDialog::OnTimer(nIDEvent);
}

CWnd* CAutodialDlg::FindDialBtn()
{
	HWND hwnd;
	HWND ParenthWnd;
	CWnd* pChildWnd;
	CString str;
	ParenthWnd=::FindWindow(NULL,"TelTel Beta");
	if(!ParenthWnd)
	{
		MessageBox("请运行TelTel 0.7.2");
		return 0;
	}
	
	hwnd=FindWindowEx(ParenthWnd,NULL,NULL,NULL);
	while (hwnd) 
	{
		pChildWnd=CWnd::FromHandle(hwnd); 
		pChildWnd->GetWindowText(str);
		if(str.Find("Tool Bar")>-1)
		{
			hwnd=FindWindowEx(hwnd,NULL,"Button",NULL);
			CWnd* pBtn;
			pBtn=CWnd::FromHandle(hwnd); 
			return pBtn;
		}
		hwnd=FindWindowEx(hwnd,NULL,NULL,NULL);

	}
	MessageBox("没有找到按扭");
	return 0;

}

BOOL CAutodialDlg::CopyTextTo(CString strNo)
{

	HWND ParenthWnd;
	HWND hwnd;
	CString str;
	CWnd *pChildWnd;

	ParenthWnd=::FindWindow(NULL,"TelTel Beta");

	hwnd=FindWindowEx(ParenthWnd,NULL,NULL,NULL);
	while (hwnd) 
	{
		pChildWnd=CWnd::FromHandle(hwnd); 
		pChildWnd->GetWindowText(str);
		if(str.Find("Tool Bar")>-1)
		{
			hwnd=FindWindowEx(hwnd,NULL,"ComboBox",NULL);
			CComboBox* pCbox;
			pCbox=(CComboBox*)CWnd::FromHandle(hwnd); 
			pCbox->ResetContent();
		    
			
			hwnd=FindWindowEx(hwnd,NULL,"Edit",NULL);
			CEdit* pEdit; 
			pEdit=(CEdit*)CWnd::FromHandle(hwnd);
			pEdit->ReplaceSel(strNo);
			return TRUE;
		}
		hwnd=FindWindowEx(hwnd,NULL,NULL,NULL);
	}
	return FALSE;
}

void CAutodialDlg::OnDblclkListPhone(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	int index=m_lCtrl.GetSelectionMark();
	m_sCombo=m_lCtrl.GetItemText(index,1);
	GetDlgItem(IDC_COMBO)->SetWindowText(m_sCombo);
	UpdateData();
	OnBtnCall();
	*pResult = 0;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -