home *** CD-ROM | disk | FTP | other *** search
/ .net 2002 March / DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin / pc / PC Software / picks / HTTrack / httrack-3.22-3.exe / {app} / src_win / WinHTTrack / Infoend.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-18  |  7.4 KB  |  299 lines

  1. // infoend.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Shell.h"
  6. #include "infoend.h"
  7. #include "iplog.h"
  8. #include "NewProj.h"
  9.  
  10. extern CNewProj* dialog0;
  11. extern "C" {
  12.   #include "htsbase.h"
  13.   HTS_INLINE int fspc(FILE* fp,char* type);
  14. }
  15.  
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. extern HICON httrack_icon;
  22.  
  23. #include "winhttrack.h"
  24. extern CWinHTTrackApp* this_app;
  25.  
  26. #include "inprogress.h"
  27. extern Cinprogress* inprogress;
  28.  
  29. /* Externe C */
  30. extern "C" {
  31.   #include "htslib.h"
  32. }
  33.  
  34. ///extern "C" int fexist(char*);
  35. //extern char* fconcat(char*,char*);
  36.  
  37. // Helper
  38. extern LaunchHelp* HtsHelper;
  39.  
  40. /* Main splitter frame */
  41. #include "DialogContainer.h"
  42. #include "splitter.h"
  43. extern CSplitterFrame* this_CSplitterFrame;
  44.  
  45. /* Main WizTab frame */
  46. #include "WizTab.h"
  47. extern CWizTab* this_CWizTab;
  48. extern CWizTab* this_intCWizTab2;
  49.  
  50. /* Objet lui mÍme */
  51. Cinfoend* this_Cinfoend=NULL;
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // Cinfoend dialog
  55.  
  56. IMPLEMENT_DYNCREATE(Cinfoend, CPropertyPage)
  57.  
  58. Cinfoend::Cinfoend()
  59.     : CPropertyPage(Cinfoend::IDD)
  60. {
  61.   this_Cinfoend=this;
  62.     //{{AFX_DATA_INIT(Cinfoend)
  63.     //}}AFX_DATA_INIT
  64. }
  65.  
  66. Cinfoend::~Cinfoend() {
  67.   this_Cinfoend=NULL;
  68. }
  69.  
  70. void Cinfoend::DoDataExchange(CDataExchange* pDX)
  71. {
  72.     CPropertyPage::DoDataExchange(pDX);
  73.     //{{AFX_DATA_MAP(Cinfoend)
  74.     //}}AFX_DATA_MAP
  75. }
  76.  
  77.  
  78. BEGIN_MESSAGE_MAP(Cinfoend, CPropertyPage)
  79.     //{{AFX_MSG_MAP(Cinfoend)
  80.     ON_BN_CLICKED(IDlog, Onlog)
  81.     ON_BN_CLICKED(IDbrowse, Onbrowse)
  82.     ON_WM_HELPINFO()
  83.     ON_WM_TIMER()
  84.     ON_WM_DESTROY()
  85.     //}}AFX_MSG_MAP
  86.   ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  87.   ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  88.   ON_COMMAND(ID_HELP,OnHelpInfo2)
  89.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  90. END_MESSAGE_MAP()
  91.  
  92. /////////////////////////////////////////////////////////////////////////////
  93. // Cinfoend message handlers
  94.  
  95. BOOL Cinfoend::OnInitDialog() 
  96. {
  97.   UpdateData(false);      // force to call DoDataExchange
  98.  
  99.     //CPropertyPage::OnInitDialog();
  100.     
  101.   SetIcon(httrack_icon,false);
  102.   SetIcon(httrack_icon,true);  
  103.   EnableToolTips(true);     // TOOL TIPS
  104.   SetForegroundWindow();   // yop en premier plan!
  105.  
  106.   // Patcher l'interface pour les FranÁais ;-)
  107.   if (LANG_T(-1)) {    // Patcher en franÁais
  108.     //SetDlgItemText(,"");
  109.     //SetWindowText(LANG(LANG_D6) /*"Fin du miroir"*/);
  110.     SetDlgItemText(IDlog,LANG(LANG_D7) /*"Voir fichier d'audit"*/);
  111.     SetDlgItemText(IDbrowse,LANG(LANG_D8) /*"Lancer Web"*/);
  112.     this_CWizTab->SetDlgItemText(IDCANCEL,LANG_QUIT);
  113.     //SetDlgItemText(IDC_NewProject,LANG_D9);
  114.     //SetDlgItemText(IDOK,LANG_OK);
  115.   }
  116.  
  117.   int error = HTS_STAT.stat_errors;
  118.   if (error) {
  119.     SetDlgItemText(IDlog,LANG_O14);
  120.     tm=SetTimer(WM_TIMER,250,NULL);
  121.   }
  122.  
  123.     return TRUE;
  124. }
  125.  
  126. void Cinfoend::Onlog() 
  127. {
  128.   char pathlog[HTS_URLMAXSIZE*2];
  129.   strcpybuff(pathlog,dialog0->GetPath());
  130.   Ciplog form;
  131.   if (strlen(pathlog)>0)
  132.   if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\'))
  133.     strcatbuff(pathlog,"/");
  134.   // fichier log existe ou on est tÈlÈcommandÈ par un !
  135.   if ( (fexist(fconcat(pathlog,"hts-err.txt"))) || (fexist(fconcat(pathlog,"hts-log.txt"))) ) {
  136.     strcpybuff(form.pathlog,pathlog);
  137.     form.DoModal();
  138.   } else {
  139.     char s[HTS_URLMAXSIZE*2];
  140.     sprintf(s,LANG(LANG_D1 /*"No log files in %s!"*/ ),pathlog);
  141.     AfxMessageBox(s,MB_OK+MB_ICONEXCLAMATION);
  142.   }
  143. }
  144.  
  145. void Cinfoend::Onbrowse() 
  146. {
  147.   char pathlog[HTS_URLMAXSIZE*2];
  148.   strcpybuff(pathlog,dialog0->GetPath());
  149.   if (strlen(pathlog)==0)
  150.     strcpybuff(pathlog,dialog0->GetPath());
  151.   Ciplog form;
  152.   if (strlen(pathlog)>0)
  153.   if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\'))
  154.     strcatbuff(pathlog,"\\");
  155.   if ( fexist(fconcat(pathlog,"index.html")) ) {
  156.     ShellExecute(this->m_hWnd,"open",fconcat(pathlog,"index.html"),"","",SW_RESTORE);    
  157.   } else {
  158.     char s[HTS_URLMAXSIZE*2];
  159.     sprintf(s,LANG(LANG_D2 /*"No index.html file in %s!"*/ ),pathlog);
  160.     AfxMessageBox(s,MB_OK+MB_ICONEXCLAMATION);
  161.   }
  162. }
  163.  
  164.  
  165.  
  166. // ------------------------------------------------------------
  167. // TOOL TIPS
  168. //
  169. // ajouter dans le .cpp:
  170. // remplacer les deux Wid1:: par le nom de la classe::
  171. // dans la message map, ajouter
  172. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  173. // dans initdialog ajouter
  174. // EnableToolTips(true);     // TOOL TIPS
  175. //
  176. // ajouter dans le .h:
  177. // char* GetTip(int id);
  178. // et en generated message map
  179. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  180. BOOL Cinfoend::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  181. {
  182.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  183.   UINT nID =pNMHDR->idFrom;
  184.   if (pTTT->uFlags & TTF_IDISHWND)
  185.   {
  186.     // idFrom is actually the HWND of the tool
  187.     nID = ::GetDlgCtrlID((HWND)nID);
  188.     if(nID)
  189.     {
  190.       char* st=GetTip(nID);
  191.       if (st != "") {
  192.         pTTT->lpszText = st;
  193.         pTTT->hinst = AfxGetResourceHandle();
  194.         return(TRUE);
  195.       }
  196.     }
  197.   }
  198.   return(FALSE);
  199. }
  200. char* Cinfoend::GetTip(int ID)
  201. {
  202.   switch(ID) {
  203.     case IDOK:     return LANG(LANG_D3 /*"Click to quit WinHTTrack"*/ ); break;
  204.     case IDlog:    return LANG(LANG_D4 /*"View log files"*/ ); break;
  205.     case IDbrowse: return LANG(LANG_D5 /*"Browse html start page"*/ ); break;
  206.     //case : return ""; break;
  207.   }
  208.   return "";
  209. }
  210. // TOOL TIPS
  211. // ------------------------------------------------------------
  212.  
  213.  
  214.  
  215. // Appel aide
  216. BOOL Cinfoend::OnHelpInfo2() {
  217.   return OnHelpInfo(NULL);
  218. }
  219.  
  220. BOOL Cinfoend::OnHelpInfo(HELPINFO* dummy) 
  221. {
  222.   //return CPropertyPage::OnHelpInfo(pHelpInfo);
  223.   HtsHelper->Help("step5.html");
  224.   return true;
  225.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  226.   //return true;
  227. }
  228.  
  229. void Cinfoend::OnBye() 
  230. {
  231.   //this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));    
  232.   // // // this_CWizTab2->DestroyWindow(); // crash!!
  233.  
  234.   //delete this_intCWizTab2->m_tabprogress;  // agh..
  235.   //this_intCWizTab2->m_tabprogress=NULL; inprogress=NULL; this_app->m_tabprogress=NULL;    // re agh..
  236.  
  237.   /* tout effacer */
  238.   //##while(this_intCWizTab2->GetPageCount()>0)
  239.   //##  this_intCWizTab2->RemovePage(0);
  240.   
  241.   //##this_intCWizTab2=NULL;
  242.   AfxGetMainWnd()->SendMessage(WM_COMMAND,wm_ViewRestart,0);
  243. }
  244.  
  245. BOOL Cinfoend::OnQueryCancel( ) {
  246.   //if (AfxMessageBox(LANG(LANG_J1),MB_OKCANCEL)==IDOK) {
  247.   /* Envoyer un WM_CLOSE ‡ notre fenÍtre principale */
  248.   AfxGetMainWnd()->SendMessage(WM_CLOSE,0,0);
  249.   //}
  250.   return FALSE;
  251. }
  252.  
  253. BOOL Cinfoend::OnSetActive( ) {
  254.   // dÈtruire ICI sinon crash!!!!
  255.   WHTT_LOCATION("Infoend");
  256.   if (this_intCWizTab2) {
  257.     this_intCWizTab2->DestroyWindow();
  258.     delete this_intCWizTab2;
  259.     this_intCWizTab2=NULL;
  260.   }
  261.  
  262.   this_CWizTab->SetWizardButtons(PSWIZB_FINISH);
  263.   this_app->GetMainWnd()->SetWindowText(LANG_F18b);
  264.   this_CWizTab->SetDlgItemText(IDCANCEL,LANG_QUIT);
  265.   return 1;
  266. }
  267.  
  268. BOOL Cinfoend::OnWizardFinish( ) {
  269.   OnBye();
  270.     return 0;
  271. }
  272.  
  273.  
  274. void Cinfoend::OnTimer(UINT nIDEvent) 
  275. {
  276.   static wflag=FALSE;
  277.  
  278.   wflag=!wflag;
  279.  
  280.   CWnd* wnd=GetDlgItem(IDlog);
  281.   if (wnd) {
  282.     CString st="";
  283.     if (wflag)
  284.       st=LANG_O14;
  285.     SetDlgItemText(IDlog,st);
  286.   }
  287.   
  288.     CPropertyPage::OnTimer(nIDEvent);
  289. }
  290.  
  291. void Cinfoend::OnDestroy() 
  292. {
  293.   if (tm!=0) {
  294.     KillTimer(tm); 
  295.     tm=-1; 
  296.   }
  297.     CPropertyPage::OnDestroy();
  298. }
  299.