home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2002 February / Practical Internet February 2002.iso / pc / Software / Browsing / httrack-3.09e2.exe / {app} / src_win / WinHTTrack / MainTab.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-21  |  11.7 KB  |  366 lines

  1. // Tab Control Principal
  2.  
  3. #include "stdafx.h"
  4. #include "Shell.h"
  5. #include "Maintab.h"
  6. #include "direct.h"
  7.  
  8. #include "winsvc.h "
  9.  
  10. #include "windows.h"
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14.  
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20.  
  21. // Icone HTTrack
  22. extern HICON httrack_icon;
  23.  
  24. // Helper
  25. extern LaunchHelp* HtsHelper;
  26.  
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CMainTab
  30.  
  31. //IMPLEMENT_DYNAMIC(CMainTab, CPropertySheet)
  32.  
  33. //HINSTANCE hInst = NULL;
  34. //SC_HANDLE hSCMan = NULL;
  35.  
  36.  
  37. CMainTab::CMainTab(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  38. :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  39. {
  40.   AddControlPages();
  41. }
  42.  
  43. CMainTab::CMainTab(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
  44. :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  45. {
  46.   AddControlPages();
  47. }
  48.  
  49. CMainTab::~CMainTab()
  50. {
  51. }
  52.  
  53. void CMainTab::AddControlPages()
  54. {
  55.   m_hIcon = httrack_icon;
  56.   m_psh.dwFlags |= PSP_USEHICON;  // utiliser ic⌠ne
  57.   m_psh.dwFlags &= ~PSH_HASHELP;  // pas de bouton help
  58.   m_psh.hIcon = m_hIcon;
  59.   //m_psh.pszIcon = "test";
  60.  
  61.   // pas de "apply"
  62.   this->m_psh.dwFlags|=PSH_NOAPPLYNOW;
  63.  
  64.   // Ajout des Control TAB dans la feuille principale (MainTab)
  65.   AddPage(&m_option10);       /* Proxy */
  66.   AddPage(&m_option7);        /* Filters */
  67.   AddPage(&m_option5);        /* Limits */
  68.   AddPage(&m_option4);        /* Flow Control */
  69.   AddPage(&m_option1);        /* Links */
  70.   AddPage(&m_option2);        /* Build */
  71.   AddPage(&m_option8);        /* Spider */
  72.   AddPage(&m_option11);       /* MIME types */
  73.   AddPage(&m_option6);        /* Browser ID */
  74.   AddPage(&m_option9);        /* Log, Index, cache */
  75.   AddPage(&m_option3);        /* Expert */
  76. }
  77.  
  78. void CMainTab::DefineDefaultProxy()
  79. {
  80.   while(GetPageCount()>0)
  81.     RemovePage(0);
  82.   AddPage(&m_option10);       /* Only proxy */
  83. }
  84.  
  85. void CMainTab::UnDefineDefaultProxy() {
  86.   AddControlPages();
  87. }
  88.  
  89. BEGIN_MESSAGE_MAP(CMainTab, CPropertySheet)
  90. //{{AFX_MSG_MAP(CMainTab)
  91. ON_WM_QUERYDRAGICON()
  92. ON_WM_SYSCOMMAND()
  93. ON_WM_TIMER()
  94. ON_WM_HELPINFO()
  95. //}}AFX_MSG_MAP
  96. ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  97. ON_COMMAND(ID_HELP,OnHelpInfo2)
  98. ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  99. //ON_BN_CLICKED(IDOK, OnOK)
  100. //ON_BN_CLICKED(IDCANCEL, OnCancel)
  101. ON_COMMAND(ID_APPLY_NOW,OnApplyNow)
  102. ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  103. END_MESSAGE_MAP()
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CMainTab message handlers
  107.  
  108. BOOL CMainTab::OnInitDialog()
  109. {
  110.   // IDM_ABOUTBOX must be in the system command range.
  111.   //ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  112.   //ASSERT(IDM_ABOUTBOX < 0xF000);
  113.   
  114.   SetIcon(m_hIcon, TRUE);
  115.   SetIcon(m_hIcon, FALSE);
  116.   EnableToolTips(true);     // TOOL TIPS
  117.  
  118. /*
  119.   CMenu* pSysMenu = GetSystemMenu(FALSE);
  120.   if (pSysMenu != NULL)
  121.   {
  122.     CString strAboutMenu;
  123.     strAboutMenu.LoadString(IDS_ABOUTBOX);
  124.     if (!strAboutMenu.IsEmpty())
  125.     {
  126.       pSysMenu->AppendMenu(MF_SEPARATOR);
  127.       pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  128.     }
  129.   }
  130. */  
  131.   // Chargement des prΘfΘrences
  132.   LoadPrefs();
  133.   
  134.   // Appliquer prΘfΘrences
  135.   Apply();
  136.   
  137.   int r = CPropertySheet::OnInitDialog();
  138.   //SetActivePage(GetPageCount()-1);
  139.   SetActivePage(0);
  140.  
  141.   // Patcher l'interface pour les Franτais ;-)
  142.   /*
  143.   if (LANG_T(-1)) {    // Patcher en franτais
  144.     //SetDlgItemText(,"");
  145.     SetWindowText(LANG(LANG_I30)); // "Options (les champs laissΘs vides seront fixΘs sur les valeurs par dΘfaut)");
  146.     m_option1.SetDlgItemText(IDC_link,LANG(LANG_I31)); // "Capturer les fichiers non html proches (ex: fichiers ZIP situΘs α l'extΘrieur)");
  147.     m_option1.SetDlgItemText(IDC_testall,LANG(LANG_I32)); // "Tester tous les liens (mΩme ceux interdits)");
  148.     m_option1.SetDlgItemText(IDC_parseall,LANG(LANG_I32b));
  149.     m_option2.SetDlgItemText(IDC_STATIC_buildopt,LANG(LANG_I33)); // "Type de structure (maniΦre dont les liens sont sauvΘs)");
  150.     m_option2.SetDlgItemText(IDC_Cache,LANG(LANG_I34)); // "Utiliser un cache");
  151.     m_option2.SetDlgItemText(IDC_index,LANG(LANG_I35)); // "Faire un index");
  152.     m_option2.SetDlgItemText(IDC_logf,LANG(LANG_I36)); // "Fichiers d'audit");
  153.     m_option2.SetDlgItemText(IDC_dos,LANG(LANG_I37)); // "Noms DOS");
  154.     m_option2.SetDlgItemText(IDC_errpage,LANG(LANG_I38)); // "Pas de page d'erreur");
  155.     m_option3.SetDlgItemText(IDC_STATIC_primf,LANG(LANG_I39)); // "Filtre primaire");
  156.     m_option3.SetDlgItemText(IDC_STATIC_travel,LANG(LANG_I40)); // "Mode de parcours");
  157.     m_option4.SetDlgItemText(IDC_STATIC_flowc,LANG(LANG_I41)); // "Contr⌠le du flux");
  158.     m_option5.SetDlgItemText(IDC_STATIC_limits,LANG(LANG_I42)); // "Limites");
  159.     m_option6.SetDlgItemText(IDC_STATIC_browsid,LANG(LANG_I43)); // "IdentitΘ");
  160.     m_option4.SetDlgItemText(IDC_STATIC_mc,LANG(LANG_I44)); // "N# connexions");
  161.     m_option4.SetDlgItemText(IDC_remt,LANG(LANG_I45)); // "Abandon hote si erreur");
  162.     m_option4.SetDlgItemText(IDC_STATIC_mintr,LANG(LANG_I46)); // "Taux min transfert (B/s)");
  163.     m_option4.SetDlgItemText(IDC_rems,LANG(LANG_I47)); // "Abandon hote si lent");
  164.     m_option4.SetDlgItemText(IDC_STATIC_retr,LANG(LANG_I48)); // "Essais");
  165.     m_option5.SetDlgItemText(IDC_STATIC_fillim,LANG(LANG_I49)); // "Limite en taille");
  166.     m_option5.SetDlgItemText(IDC_STATIC_autre,LANG(LANG_I50)); // "Autres:");
  167.     m_option5.SetDlgItemText(IDC_STATIC_sitesize,LANG(LANG_I51)); // "Taille site max");
  168.     m_option5.SetDlgItemText(IDC_STATIC_tempmax,LANG(LANG_I52)); // "Temps max");
  169.     m_option5.SetDlgItemText(IDC_STATIC_ratemax,LANG(LANG_I54));
  170.     //m_option.SetDlgItemText(IDC_next2,LANG(LANG_BACK)); // "<- AVANT");
  171.     //m_option.SetDlgItemText(IDC_regdef,LANG(LANG_I53)); // "Sauver prefs");
  172.     //SetDlgItemText(IDOK,"OK");
  173.     SetDlgItemText(IDCANCEL,LANG(LANG_CANCEL)); // "ANNULER");
  174.     m_option2.SetDlgItemText(IDC_robots,LANG(LANG_I55));
  175.     m_option2.SetDlgItemText(IDC_external,LANG(LANG_I56)); // "Pas de page externes");
  176.     m_option2.SetDlgItemText(IDC_nopurge,LANG(LANG_I57)); // "nopurge");
  177.   }
  178.   */
  179.  
  180.   // mode modif α la volΘe
  181.   /*
  182.   if (modify==1) {
  183.     m_option2.GetDlgItem(IDC_build)   ->ModifyStyle(0,WS_DISABLED);
  184.     m_option2.GetDlgItem(IDC_buildopt)->ModifyStyle(0,WS_DISABLED);
  185.     m_option2.GetDlgItem(IDC_Cache)   ->ModifyStyle(0,WS_DISABLED);
  186.     m_option2.GetDlgItem(IDC_index)   ->ModifyStyle(0,WS_DISABLED);
  187.     m_option2.GetDlgItem(IDC_logf)    ->ModifyStyle(0,WS_DISABLED);
  188.     m_option2.GetDlgItem(IDC_dos)     ->ModifyStyle(0,WS_DISABLED);
  189.     m_option2.GetDlgItem(IDC_filter)  ->ModifyStyle(0,WS_DISABLED);
  190.     m_option2.GetDlgItem(IDC_travel)  ->ModifyStyle(0,WS_DISABLED);
  191.   } else {
  192.     m_option2.GetDlgItem(IDC_build)   ->ModifyStyle(WS_DISABLED,0);
  193.     m_option2.GetDlgItem(IDC_buildopt)->ModifyStyle(WS_DISABLED,0);
  194.     m_option2.GetDlgItem(IDC_Cache)   ->ModifyStyle(WS_DISABLED,0);
  195.     m_option2.GetDlgItem(IDC_index)   ->ModifyStyle(WS_DISABLED,0);
  196.     m_option2.GetDlgItem(IDC_logf)    ->ModifyStyle(WS_DISABLED,0);
  197.     m_option2.GetDlgItem(IDC_dos)     ->ModifyStyle(WS_DISABLED,0);
  198.     m_option2.GetDlgItem(IDC_filter)  ->ModifyStyle(WS_DISABLED,0);
  199.     m_option2.GetDlgItem(IDC_travel)  ->ModifyStyle(WS_DISABLED,0);
  200.   }
  201.   */
  202.   return r;
  203. }
  204. HCURSOR CMainTab::OnQueryDragIcon()
  205. {
  206.   return (HCURSOR) m_hIcon;
  207. }
  208.  
  209. BOOL CMainTab::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  210. {
  211.   //removing the default DS_CONTEXT_HELP style
  212.   //dwStyle= WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME | WS_VISIBLE;
  213.   return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  214. }
  215.  
  216. void CMainTab::OnSysCommand(UINT nID, LPARAM lParam)
  217. {
  218.   /*if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  219.   {
  220.     SetActivePage(GetPageCount()-1);    // Afficher informations sur le programme et affichant la derniΦre page des control TAB
  221.      }
  222.   else
  223.   {
  224.   */
  225.     CPropertySheet::OnSysCommand(nID, lParam);
  226.   /*}
  227.   */
  228. }
  229.  
  230. // L'utilisateur a appuyΘ sur "Apply"
  231. void CMainTab::OnApplyNow()
  232. {
  233.   EnableWindow(false);
  234.   Default();
  235.   ApplyAndSave();
  236.   EnableWindow(true);
  237. }
  238.  
  239. // Sauver et appliquer les prΘfΘrences
  240. void CMainTab::ApplyAndSave() {
  241.   CWaitCursor wait;      // Afficher curseur sablier
  242.   bool err=false;  // Erreur lors de l'Θcriture des paramΦtres
  243.   
  244.   // Appliquer les prΘfΘrences
  245.   Apply();
  246.   
  247.   // Sauver prΘfΘrences
  248.   CWinApp* pApp = AfxGetApp();
  249.   //if (!pApp->WriteProfileInt("Driver", "DriverId",numero_driver))          // No du driver
  250.   //  err=true;
  251.  
  252.   if (err)
  253.     AfxMessageBox(LANG(LANG_DIAL2));
  254. }
  255.  
  256. // Appliquer prΘfΘrences
  257. void CMainTab::Apply() {
  258.   // Appliquer prΘfΘrences
  259. }
  260.  
  261. // Chargement des prΘfΘrences
  262. void CMainTab::LoadPrefs() {
  263.   CWinApp* pApp = AfxGetApp();
  264.   //n = pApp->GetProfileInt("Driver", "DriverId",0);   // No du driver
  265. }
  266.  
  267. // Appel aide
  268. BOOL CMainTab::OnHelpInfo2() {
  269.   return OnHelpInfo(NULL);
  270. }
  271.  
  272. BOOL CMainTab::OnHelpInfo(HELPINFO* dummy) 
  273. {
  274.   //return CDialog::OnHelpInfo(pHelpInfo);
  275.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  276.   //LaunchHelp(pHelpInfo);
  277.  
  278.   if (this->GetActivePage() == &m_option1)
  279.     HtsHelper->Help("step9_opt1.html");
  280.   else if (this->GetActivePage() == &m_option5)
  281.     HtsHelper->Help("step9_opt2.html");
  282.   else if (this->GetActivePage() == &m_option4)
  283.     HtsHelper->Help("step9_opt3.html");
  284.   else if (this->GetActivePage() == &m_option7)
  285.     HtsHelper->Help("step9_opt4.html");
  286.   else if (this->GetActivePage() == &m_option2)
  287.     HtsHelper->Help("step9_opt5.html");
  288.   else if (this->GetActivePage() == &m_option8)
  289.     HtsHelper->Help("step9_opt6.html");
  290.   else if (this->GetActivePage() == &m_option10)
  291.     HtsHelper->Help("step9_opt7.html");
  292.   else if (this->GetActivePage() == &m_option6)
  293.     HtsHelper->Help("step9_opt8.html");
  294.   else if (this->GetActivePage() == &m_option9)
  295.     HtsHelper->Help("step9_opt9.html");
  296.   else if (this->GetActivePage() == &m_option3)
  297.     HtsHelper->Help("step9_opt10.html");
  298.   else if (this->GetActivePage() == &m_option11)
  299.     HtsHelper->Help("step9_opt11.html");
  300.   else
  301.     HtsHelper->Help();
  302.   return true;
  303. }
  304.  
  305.  
  306. /*
  307. // Capturer OK et Cancel
  308. void CMainTab::OnOK( ) {
  309.   // Sauver et appliquer prΘfΘrences
  310.   ApplyAndSave();
  311. }
  312. void CMainTab::OnCancel( ) {
  313.   // Recharger prΘfΘrences
  314.   LoadPrefs();
  315. }
  316. */
  317.  
  318.  
  319.  
  320. // ------------------------------------------------------------
  321. // TOOL TIPS
  322. //
  323. // ajouter dans le .cpp:
  324. // remplacer les deux <nom classe>:: par le nom de la classe::
  325. // dans la message map, ajouter
  326. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  327. // dans initdialog ajouter
  328. // EnableToolTips(true);     // TOOL TIPS
  329. //
  330. // ajouter dans le .h:
  331. // char* GetTip(int id);
  332. // et en generated message map
  333. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  334. char* CMainTab::GetTip(int ID)
  335. {
  336.   switch(ID) {
  337.     case IDOK:           return LANG(LANG_TIPOK); break;      
  338.     case IDCANCEL:       return LANG(LANG_TIPCANCEL); break;
  339.     case IDHELP:         return LANG_TIPHELP; break;
  340.   }
  341.   return "";
  342. }
  343. BOOL CMainTab::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  344. {
  345.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  346.   UINT nID =pNMHDR->idFrom;
  347.   if (pTTT->uFlags & TTF_IDISHWND)
  348.   {
  349.     // idFrom is actually the HWND of the tool
  350.     nID = ::GetDlgCtrlID((HWND)nID);
  351.     if(nID)
  352.     {
  353.       char* st=GetTip(nID);
  354.       if (st != "") {
  355.         pTTT->lpszText = st;
  356.         pTTT->hinst = AfxGetResourceHandle();
  357.         return(TRUE);
  358.       }
  359.     }
  360.   }
  361.   return(FALSE);
  362. }
  363. // TOOL TIPS
  364. // ------------------------------------------------------------
  365.  
  366.