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 / WizTab.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-06  |  7.5 KB  |  344 lines

  1. // Tab Control Principal
  2.  
  3. #include "stdafx.h"
  4. #include "Shell.h"
  5. #include "WizTab.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. CWizTab* this_CWizTab;
  22. CWizTab* this_intCWizTab;
  23. CWizTab* this_intCWizTab2;
  24.  
  25. // Icone HTTrack
  26. extern HICON httrack_icon;
  27.  
  28. // Instance WinHTTrack
  29. #include "WinHTTrack.h"
  30. extern CWinHTTrackApp* this_app;
  31.  
  32. // Helper
  33. extern LaunchHelp* HtsHelper;
  34. extern CMainTab* maintab;
  35.  
  36. /* Main splitter frame */
  37. #include "DialogContainer.h"
  38. #include "splitter.h"
  39. extern CSplitterFrame* this_CSplitterFrame;
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CWizTab
  43.  
  44. IMPLEMENT_DYNAMIC(CWizTab, CPropertySheet)
  45.  
  46. CWizTab::CWizTab(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  47. :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  48. {
  49.   AddControlPages();
  50. }
  51.  
  52. CWizTab::CWizTab(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
  53. :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  54. {
  55.   AddControlPages();
  56. }
  57.  
  58. CWizTab::CWizTab(LPCTSTR pszCaption, int num, CWnd* pParentWnd, UINT iSelectPage)
  59. :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  60. {
  61.   is_inProgress=num;
  62.   AddControlPages();
  63. }
  64.  
  65. CWizTab::~CWizTab()
  66. {
  67.   ClearInits();
  68. }
  69.  
  70. void CWizTab::DoInits() {
  71.   m_tab0=NULL;
  72.   m_tab1=NULL;
  73.   m_tab2=NULL;
  74.   m_tab3=NULL;
  75.   m_tabend=NULL;
  76.   m_tabprogress=NULL;
  77.   if (!is_inProgress) {
  78.     m_tab0=this_app->m_tab0;
  79.     m_tab1=this_app->m_tab1;
  80.     m_tab2=this_app->m_tab2;
  81.     m_tab3=this_app->m_tab3;
  82.     m_tabend=this_app->m_tabend;
  83.   } else {
  84.     m_tabprogress=this_app->m_tabprogress;
  85.   }
  86.   // Lecture du profile par dΘfaut
  87.   maintab = new CMainTab("WinHTTrack");
  88.   //if (!is_inProgress)   // sinon buggue
  89.   Read_profile("",0);
  90. }
  91.  
  92. void CWizTab::ClearInits() {
  93.   if (maintab)
  94.     delete maintab;
  95.   maintab=NULL;
  96.   if (!is_inProgress)
  97.     this_intCWizTab=NULL;
  98.   else
  99.     this_intCWizTab2=NULL;
  100. }
  101.  
  102. void CWizTab::AddControlPages()
  103. {
  104.   m_hIcon = httrack_icon;
  105.   m_psh.dwFlags |= PSP_USEHICON;  // utiliser ic⌠ne
  106.   m_psh.dwFlags &= ~PSH_HASHELP;  // pas de bouton help
  107.   m_psh.hIcon = m_hIcon;
  108.   //m_psh.pszIcon = "test";
  109.  
  110.   // objet lui mΩme
  111.   if (!is_inProgress)
  112.     this_intCWizTab=this;
  113.   else
  114.     this_intCWizTab2=this;
  115.  
  116.   if (!is_inProgress)
  117.     this_CWizTab=this;
  118.  
  119.   // pas de "apply"
  120.   this->m_psh.dwFlags|=PSH_NOAPPLYNOW;
  121.  
  122.   DoInits();
  123.  
  124.   // Ajout des Control TAB dans la feuille principale (MainTab)
  125.   if (!is_inProgress) {
  126.     AddPage(m_tab0);
  127.     AddPage(m_tab1);
  128.     AddPage(m_tab2);
  129.     AddPage(m_tab3);
  130.   }
  131.  
  132.   /* uniquement pour calibrer la page, retirΘ lors de initdialog */
  133.   if (is_inProgress)
  134.     AddPage(m_tabprogress);
  135.  
  136.   if (!is_inProgress)
  137.     AddPage(m_tabend);
  138.  
  139.   //SetActivePage(0);
  140.   SetWizardMode(); 
  141. }
  142.  
  143. void CWizTab::FinalInProgress()
  144. {
  145.   if (is_inProgress) {
  146.     /* tout effacer */
  147.     while(GetPageCount()>0)
  148.       RemovePage(0);
  149.     /* page finale */
  150.     SetWizardButtons(0);
  151.     AddPage(m_tabprogress);
  152.     SetActivePage(0);
  153.     
  154.     /* enable ext. entries */
  155.     this_CSplitterFrame->EnableExtEntries(TRUE);
  156.   }
  157. }
  158.  
  159. void CWizTab::EndInProgress()
  160. {
  161.   if (!is_inProgress) {
  162.     /* unhide */
  163.     this_CSplitterFrame->CheckRestore();
  164.     /* tout effacer */
  165.     while(GetPageCount()>0)
  166.       RemovePage(0);
  167.     
  168.     /* page fin */
  169.     SetWizardButtons(0);
  170.     AddPage(m_tabend);
  171.     SetActivePage(0);
  172.     
  173.     /* disable ext. entries */
  174.     this_CSplitterFrame->EnableExtEntries(FALSE);
  175.   }
  176. }
  177.  
  178. BEGIN_MESSAGE_MAP(CWizTab, CPropertySheet)
  179. //{{AFX_MSG_MAP(CWizTab)
  180. ON_WM_HELPINFO()
  181.     //}}AFX_MSG_MAP
  182. ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  183. ON_COMMAND(ID_HELP,OnHelpInfo2)
  184. ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  185. //ON_BN_CLICKED(IDOK, OnOK)
  186. //ON_BN_CLICKED(IDCANCEL, OnCancel)
  187. ON_COMMAND(ID_APPLY_NOW,OnApplyNow)
  188. ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  189. END_MESSAGE_MAP()
  190.  
  191. /////////////////////////////////////////////////////////////////////////////
  192. // CWizTab message handlers
  193.  
  194. BOOL CWizTab::OnInitDialog()
  195. {
  196.   // IDM_ABOUTBOX must be in the system command range.
  197.   //ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  198.   //ASSERT(IDM_ABOUTBOX < 0xF000);
  199.   
  200.   SetIcon(m_hIcon, TRUE);
  201.   SetIcon(m_hIcon, FALSE);
  202.   EnableToolTips(true);     // TOOL TIPS
  203.  
  204. /*
  205.   CMenu* pSysMenu = GetSystemMenu(FALSE);
  206.   if (pSysMenu != NULL)
  207.   {
  208.     CString strAboutMenu;
  209.     strAboutMenu.LoadString(IDS_ABOUTBOX);
  210.     if (!strAboutMenu.IsEmpty())
  211.     {
  212.       pSysMenu->AppendMenu(MF_SEPARATOR);
  213.       pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  214.     }
  215.   }
  216. */  
  217.   // Chargement des prΘfΘrences
  218.   if (!is_inProgress)
  219.     LoadPrefs();
  220.   
  221.   // Appliquer prΘfΘrences
  222.   Apply();
  223.   
  224.   int r = CPropertySheet::OnInitDialog();
  225.   //xx RemovePage(m_tabprogress);
  226.   //xx RemovePage(m_tabend);
  227.   SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);
  228.   SetWindowPos(&wndTop,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOOWNERZORDER);
  229.   SetActivePage(0);
  230.  
  231.   return r;
  232. }
  233.  
  234. // L'utilisateur a appuyΘ sur "Apply"
  235. void CWizTab::OnApplyNow()
  236. {
  237.   EnableWindow(false);
  238.   Default();
  239.   ApplyAndSave();
  240.   EnableWindow(true);
  241. }
  242.  
  243. // Sauver et appliquer les prΘfΘrences
  244. void CWizTab::ApplyAndSave() {
  245.   CWaitCursor wait;      // Afficher curseur sablier
  246.   bool err=false;  // Erreur lors de l'Θcriture des paramΦtres
  247.   
  248.   // Appliquer les prΘfΘrences
  249.   Apply();
  250.   
  251.   // Sauver prΘfΘrences
  252.   CWinApp* pApp = AfxGetApp();
  253.  
  254.   if (err)
  255.     AfxMessageBox(LANG(LANG_DIAL2));
  256. }
  257.  
  258. // Appliquer prΘfΘrences
  259. void CWizTab::Apply() {
  260.   // Appliquer prΘfΘrences
  261. }
  262.  
  263. // Chargement des prΘfΘrences
  264. void CWizTab::LoadPrefs() {
  265.   CWinApp* pApp = AfxGetApp();
  266.   //n = pApp->GetProfileInt("Driver", "DriverId",0);   // No du driver
  267. }
  268.  
  269. // Appel aide
  270. BOOL CWizTab::OnHelpInfo2() {
  271.   return OnHelpInfo(NULL);
  272. }
  273.  
  274. BOOL CWizTab::OnHelpInfo(HELPINFO* dummy) 
  275. {
  276.   //return CDialog::OnHelpInfo(pHelpInfo);
  277.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  278.   //LaunchHelp(pHelpInfo);
  279.  
  280.   /*if (this->GetActivePage() == m_tab1)
  281.     HtsHelper->Help("xxc");
  282.   else*/
  283.     HtsHelper->Help();
  284.   return true;
  285. }
  286.  
  287.  
  288. /*
  289. // Capturer OK et Cancel
  290. void CWizTab::OnOK( ) {
  291.   // Sauver et appliquer prΘfΘrences
  292.   ApplyAndSave();
  293. }
  294. void CWizTab::OnCancel( ) {
  295.   // Recharger prΘfΘrences
  296.   LoadPrefs();
  297. }
  298. */
  299.  
  300.  
  301. // ------------------------------------------------------------
  302. // TOOL TIPS
  303. //
  304. // ajouter dans le .cpp:
  305. // remplacer les deux <nom classe>:: par le nom de la classe::
  306. // dans la message map, ajouter
  307. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  308. // dans initdialog ajouter
  309. // EnableToolTips(true);     // TOOL TIPS
  310. //
  311. // ajouter dans le .h:
  312. // char* GetTip(int id);
  313. // et en generated message map
  314. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  315. char* CWizTab::GetTip(int ID)
  316. {
  317.   /*switch(ID) {
  318.   }*/
  319.   return "";
  320. }
  321. BOOL CWizTab::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  322. {
  323.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  324.   UINT nID =pNMHDR->idFrom;
  325.   if (pTTT->uFlags & TTF_IDISHWND)
  326.   {
  327.     // idFrom is actually the HWND of the tool
  328.     nID = ::GetDlgCtrlID((HWND)nID);
  329.     if(nID)
  330.     {
  331.       char* st=GetTip(nID);
  332.       if (st != "") {
  333.         pTTT->lpszText = st;
  334.         pTTT->hinst = AfxGetResourceHandle();
  335.         return(TRUE);
  336.       }
  337.     }
  338.   }
  339.   return(FALSE);
  340. }
  341. // TOOL TIPS
  342. // ------------------------------------------------------------
  343.  
  344.