📄 mainfrm.cpp
字号:
}
void CMainFrame::OnWriteListData(WPARAM wParam,LPARAM lParam)
{
LIST_VIEWDATA *stListViewData=(LIST_VIEWDATA*)lParam;
int iPercent=(int)wParam; //if message is percent
CTestDownView *TestView=GetTestDownView();
TestView->m_ListNew.SetItemText(stListViewData->nItem,stListViewData->nColumn,stListViewData->lpcszText);
if(iPercent==1)
{
int iItem=stListViewData->nItem;
BTOOLTEXT stToolText;
int nCount=m_ToolTipArray.GetSize();
m_strToolTip="";
for(int i=1;i<nCount;i++)
{
stToolText=m_ToolTipArray.GetAt(i);
if(iItem==stToolText.iItem)
{
CString str,str2;
str=stToolText.strText;
stToolText.iItem=iItem;
str=str.Left(str.Find("["));
str2=stListViewData->lpcszText;
str+="["+str2+"]";
stToolText.strText=str;
m_ToolTipArray.SetAt(i,stToolText);
}
m_strToolTip+=stToolText.strText;
m_strToolTip+="\n";
}
m_strToolTip=m_strToolTip.Left(m_strToolTip.GetLength()-1);
}
}
//////*************NEW MESSAGE*************
void CMainFrame::OnWriteRegListCtrl(WPARAM wParam,LPARAM lParam)
{
WRITEREGLISTCTRL_DATA *stData=(WRITEREGLISTCTRL_DATA*)lParam;
//Write to CView List
CTestDownView *TestView=GetTestDownView();
if(TestView->m_hWnd)
{
CString sFile,sComment,sUrl;
LPTSTR lpszText[8];
int nImage,nItem;
nImage=stData->nImage;
nItem=stData->nItem;
lpszText[0]=(LPTSTR)((LPCTSTR)(stData->strFilePath)); //FileName
lpszText[1]=""; //FileLength
lpszText[2]="0%"; //Percent
lpszText[3]=""; //bps
lpszText[4]=""; //00:00:00
lpszText[5]=""; //00:00:00
lpszText[6]=(LPTSTR)((LPCTSTR)(stData->strComment)); //Comment
lpszText[7]=(LPTSTR)((LPCTSTR)(stData->strLocationUrl)); //URL
TestView->m_ListNew.SetItemColumnValueB(nItem,8,lpszText,nImage);
TestView->m_ListNew.SetAutoSize(2,5);
}
else
MessageBox("Get ListCtrl Failed!","Leo",MB_OK|MB_ICONSTOP);
}
void CMainFrame::OnCaulueTimer(WPARAM wParam,LPARAM lParam)
{
CAULUETIMER_DATA *stData=(CAULUETIMER_DATA*)lParam;
CTestDownView *TestView=GetTestDownView();
if(TestView->m_hWnd)
{
LPTSTR lpszText;
int nItem;
lpszText=stData->szTimer;
nItem=stData->nItem;
TestView->m_ListNew.SetItemText(nItem,5,lpszText);
}
else
MessageBox("Get ListCtrl Failed!","Leo",MB_OK|MB_ICONSTOP);
}
void CMainFrame::OnDecreaseThNum(WPARAM wParam,LPARAM lParam)
{
m_nThreadNumber--;
int iItem=(int)wParam;
BTOOLTEXT stToolText;
int nCount=m_ToolTipArray.GetSize();
for(int i=1;i<nCount;i++)
{
stToolText=m_ToolTipArray.GetAt(i);
if(iItem==stToolText.iItem)
{
m_ToolTipArray.RemoveAt(i);
break;
}
}
m_strToolTip="";
nCount=m_ToolTipArray.GetSize();
if(nCount==1)
{
m_strToolTip="Leo";
m_DropWin->KillTimerPaint(0);
}
else
{
for(i=1;i<nCount;i++)
{
stToolText=m_ToolTipArray.GetAt(i);
m_strToolTip+=stToolText.strText;
m_strToolTip+="\n";
}
m_strToolTip=m_strToolTip.Left(m_strToolTip.GetLength()-1);
}
//stToolText.strText=m_strToolTip;
//::SendMessage(m_DropWin->m_pDropView->GetSafeHwnd(),WM_BTOOLEXTENTCX,0,(LPARAM)&stToolText);
}
void CMainFrame::OnDownButton()
{
// TODO: Add your command handler code here
CString strValue;
m_pEditDownFind->GetWindowText(strValue);
if(strValue.IsEmpty())
{
AfxMessageBox("请输入软件名称!",MB_OK|MB_ICONINFORMATION);
return;
}
ShellExecute(NULL,"open","iexplore.exe",NULL,NULL,SW_SHOWNORMAL);
int CalueNum=0;
int retu=0;
CString strCom,strEdit;
int index=m_pComDownFind->GetCurSel();
while(retu<=0)
{
if(index>=0)
{
switch(index)
{
case 0:
strCom="<option value='00' >全部软件</option>";
break;
case 1:
strCom="<option value='01'>国产软件</option>";
break;
case 2:
strCom="<option value='02'>国外软件</option>";
break;
}
retu=ShellWindowIE((LPTSTR)(LPCTSTR)strCom);
}
}
}
int CMainFrame::IElement(IHTMLDocument2Ptr sp_Doc)
{
int ret=0;
CComPtr<IHTMLElementCollection> pCollection;
do{
if(!SUCCEEDED(sp_Doc->get_all(&pCollection)))
{
AfxMessageBox("Collection Doc All Link Failed!");
break;
}
int count=0;
int Count=0;
if(!SUCCEEDED(pCollection->get_length((long*)&Count)))
{
AfxMessageBox("Collection Get Length Failed!");
break;
}
for(int i=0;i<Count;i++)
{
_variant_t index=long(i);
CComPtr<IDispatch> spDispatch;
if(SUCCEEDED(pCollection->item(index,index,&spDispatch)))
{
CComPtr<IHTMLFormElement> pFormElement;
if(SUCCEEDED(spDispatch->QueryInterface(__uuidof(IHTMLFormElement),(void**)&pFormElement)))
{
pFormElement->submit();
}//if(SUCCEEDED(spDispatch->QueryInterface
}//if(SUCCEEDED(pCollection->item
}//for
ret=count;
break;
}while(false);
return ret;
}
int CMainFrame::ShellWindowIE(LPTSTR szCom)
{
int ret=0;
do{
SHDocVw::IShellWindowsPtr msp_SHWinds=NULL;
HRESULT hr=msp_SHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows));
if(hr!=S_OK || msp_SHWinds==NULL)
{
AfxMessageBox("SHDocVw::IShellWindowsPtr Failed!");
break;
}
int count=0;
int Count=msp_SHWinds->GetCount();
//int i=0;
for(int i=0;i<Count;i++)
{
_variant_t va(long(i),VT_I4);
IDispatchPtr sp_Disp;
sp_Disp=msp_SHWinds->Item(va);
SHDocVw::IWebBrowser2Ptr sp_Brower(sp_Disp);
if(sp_Brower!=NULL)
{
//m_listElement.AddString();
IHTMLDocument2Ptr sp_Doc(sp_Brower->GetDocument());
if(sp_Doc!=NULL)
{
count++;
CComBSTR bstr;
sp_Doc->get_title(&bstr);
CString str,strValue,strCom;
str.Format("Title=%s",(char*)_bstr_t(bstr));
m_pEditDownFind->GetWindowText(strValue);
strCom=szCom;
//m_listElement.AddString(str);
str="<body>";
str+="<FORM action='http://www.skycn.com/search.php' method='POST'><input type='text' name='ss_name' size='16' maxlength='40' value=\'";
str+=strValue;
str+="\'>";
str+="<select name='sor' >";
str+=strCom;
str+="</select>";
str+="<input type='submit' name='Submit' value='查找'></FORM>";
str+="</body>";
SAFEARRAY *psa=SafeArrayCreateVector(VT_VARIANT,0,1);
VARIANT *param;
bstr_t bsData=(LPCTSTR)str;
hr=SafeArrayAccessData(psa,(LPVOID*)¶m);
param->vt=VT_BSTR;
param->bstrVal=(BSTR)bsData;
sp_Doc->write(psa);
IElement(sp_Doc);
ret=1;
SafeArrayDestroy(psa);
break;
}
}//if
}//for
break;
}while(false);
return ret;
}
void CMainFrame::SetBToolTipText(int nThreadNum,CString strText,CString strExtent)
{
BTOOLTEXT stBTool;
::SendMessage(m_DropWin->GetSafeHwnd(),WM_BTOOLEXTENTCX,0,(LPARAM)&stBTool);
}
UINT CMainFrame::OnBToolExtentcx(WPARAM wParam,LPARAM lParam)
{
BTOOLTEXT *pBTool=(BTOOLTEXT*)lParam;
pBTool->strText=m_strToolTip;
if(!m_strToolTip.IsEmpty())
{
return 1;
}
return 0;
}
void CMainFrame::OnUpdateViewLeoToolbar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
BOOL bVisible;
bVisible=(m_ToolBarNew.GetStyle()&WS_VISIBLE);
if(bVisible)
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
void CMainFrame::OnViewLeoToolbarfind()
{
// TODO: Add your command handler code here
BOOL bVisible;
bVisible=(m_ToolBarButton.GetStyle()&WS_VISIBLE);
int nShow=(bVisible) ? SW_HIDE : SW_SHOWNORMAL;
m_ToolBarButton.ShowWindow(nShow);
RecalcLayout();
}
void CMainFrame::OnUpdateViewLeoToolbarfind(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
BOOL bVisible;
bVisible=(m_ToolBarButton.GetStyle()&WS_VISIBLE);
if(bVisible)
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(m_ToolTipBar)
m_ToolTipBar.RelayEvent(pMsg);
return CFrameWnd::PreTranslateMessage(pMsg);
}
void CMainFrame::OnAppDropWindow()
{
// TODO: Add your command handler code here
if(!m_bIsDropWin)
{
m_bIsDropWin=TRUE;
m_DropWin->ShowWindow(SW_SHOW);
}
else
{
m_bIsDropWin=FALSE;
m_DropWin->ShowWindow(SW_HIDE);
}
}
void CMainFrame::OnUpdateAppDropWindow(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bIsDropWin)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CMainFrame::OnAppMainWindows()
{
// TODO: Add your command handler code here
if(m_bIsMainWindows)
{
OnHideWindow(0,0);
m_bIsMainWindows=FALSE;
}
else
{
OnShowWindowL(0,0);
m_bIsMainWindows=TRUE;
}
}
void CMainFrame::OnUpdateAppMainWindows(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bIsMainWindows)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CMainFrame::OnDropwinMainwindows()
{
// TODO: Add your command handler code here
if(m_bIsMainWindows)
{
OnHideWindow(0,0);
m_bIsMainWindows=FALSE;
}
else
{
OnShowWindowL(0,0);
m_bIsMainWindows=TRUE;
}
}
void CMainFrame::OnUpdateDropwinMainwindows(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_bIsMainWindows)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
void CMainFrame::OnMainToolAutorun()
{
// TODO: Add your command handler code here
//Add Open Computer to Auto Run Leo 2005
CString strPath=m_InstallPath;
strPath+="\\Leo2005.exe";
HKEY nKeyRoot=HKEY_LOCAL_MACHINE;
LPSTR nSubKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
LPSTR szAutoRun="Leo2005";
CLRegistry nRegistry;
if(nRegistry.Open(nKeyRoot,nSubKey))
{
if(nRegistry.VerifyValue(szAutoRun))
nRegistry.DeleteValue(szAutoRun);
else
nRegistry.Write(szAutoRun,(LPCTSTR)strPath);
}
}
void CMainFrame::OnUpdateMainToolAutorun(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
CString strPath=m_InstallPath;
strPath+="\\Leo2005.exe";
HKEY nKeyRoot=HKEY_LOCAL_MACHINE;
LPSTR nSubKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
LPSTR szAutoRun="Leo2005";
CLRegistry nRegistry;
if(nRegistry.Open(nKeyRoot,nSubKey))
{
if(nRegistry.VerifyValue(szAutoRun))
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -