home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / dialog.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  23.1 KB  |  917 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "stdafx.h"
  20.  
  21. #include "dialog.h"
  22.  
  23. #include "helper.h"
  24. #include "nethelp.h"
  25.  
  26. #ifdef _DEBUG
  27. #undef THIS_FILE
  28. static char BASED_CODE THIS_FILE[] = __FILE__;
  29. #endif
  30.  
  31. extern "C" void sample_exit_routine(URL_Struct *URL_s,int status,MWContext *window_id);
  32.  
  33. static CString url_string = "";
  34. // Retain radio button setting across dialog calls
  35. // 0 = Load URL into Browser, 1 = Editor
  36. static int browse_or_edit = 0;
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CDialogURL dialog
  39.  
  40.  
  41. CDialogURL::CDialogURL(CWnd* pParent, MWContext * context)
  42.     : CDialog(CDialogURL::IDD, pParent)
  43. {
  44.     //{{AFX_DATA_INIT(CDialogURL)
  45.     m_csURL = url_string;
  46.     //}}AFX_DATA_INIT
  47.     ASSERT(context);
  48.     m_Context = context;
  49. }
  50.  
  51.  
  52. BOOL CDialogURL::OnInitDialog() 
  53. {
  54.     CDialog::OnInitDialog();
  55.  
  56.     CEdit * pBox = (CEdit *) GetDlgItem(IDC_URL); 
  57.  
  58.     if(pBox) {
  59.         pBox->SetWindowText((const char *) url_string);
  60.         pBox->SetFocus();
  61.         pBox->SetSel(0, -1);
  62. #ifdef EDITOR
  63.         // Communicator version has radio buttons to select 
  64.         //  loading URL into a browser or editor
  65.         if ( EDT_IS_EDITOR(m_Context) ){
  66.             ((CButton *)GetDlgItem(IDC_OPEN_URL_EDITOR))->SetCheck(1);
  67.         } else {
  68.             ((CButton *)GetDlgItem(IDC_OPEN_URL_BROWSER))->SetCheck(1);
  69.         }
  70. #endif // EDITOR
  71.         return(0);
  72.     } 
  73.     return(1);
  74. }
  75.  
  76. BEGIN_MESSAGE_MAP(CDialogURL, CDialog)
  77.     //{{AFX_MSG_MAP(CDialogURL)
  78.     ON_BN_CLICKED(IDC_BROWSE_FILE, OnBrowseForFile)
  79.     ON_COMMAND(ID_HELP, OnHelp)
  80.     //}}AFX_MSG_MAP
  81. END_MESSAGE_MAP()
  82.  
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CDialogURL message handlers
  85. /////////////////////////////////////////////////////////////////////////////
  86.  
  87. void CDialogURL::OnBrowseForFile()
  88. {
  89.     int type = HTM;
  90. #ifdef EDITOR
  91.     // Restrict to only *.HTML and allow *.SHTML if loading in Composer
  92.     if( ((CButton *)GetDlgItem(IDC_OPEN_URL_EDITOR))->GetCheck() ){
  93.         type = HTM_ONLY;
  94.     }
  95. #endif
  96.     char * pName = wfe_GetExistingFileName( this->m_hWnd, szLoadString(IDS_OPEN), type, TRUE, NULL);
  97.     if( pName ){
  98.         GetDlgItem(IDC_URL)->SetWindowText(pName);
  99.         XP_FREE(pName);
  100.         // Set focus to Open button so Enter can be used 
  101.         // immediately after choosing file
  102.         GotoDlgCtrl(GetDlgItem(IDOK));
  103.     }
  104. }
  105.  
  106. void CDialogURL::OnHelp()
  107. {
  108.  
  109.     NetHelp( HELP_OPEN_PAGE );
  110. }
  111.  
  112. void CDialogURL::OnOK()
  113. {
  114.  
  115.     CEdit * pBox = (CEdit *) GetDlgItem(IDC_URL); 
  116.  
  117.     if(pBox) {
  118.         pBox->GetWindowText(url_string);
  119.     }
  120.  
  121.     CDialog::OnOK();
  122. #ifdef XP_WIN32
  123.     url_string.TrimLeft();
  124.     url_string.TrimRight();
  125. #endif
  126.  
  127.     // this was typed in so no referrer -> OK to do an OnNormalLoad
  128.     if(!url_string.IsEmpty()) {
  129.  
  130. #ifdef EDITOR
  131.         BOOL bEdit = ((CButton *)GetDlgItem(IDC_OPEN_URL_EDITOR))->GetCheck() != 0;
  132.  
  133.         if (bEdit || EDT_IS_EDITOR(m_Context)) {
  134.             FE_LoadUrl((char*)LPCSTR(url_string), bEdit);
  135.         } else
  136. #endif
  137.             // Load the URL into the same window only if called from an existing browser
  138.             ABSTRACTCX(m_Context)->NormalGetUrl(url_string);
  139.     }
  140.  
  141. }
  142.  
  143.  
  144. /////////////////////////////////////////////////////////////////////////////
  145. /////////////////////////////////////////////////////////////////////////////
  146. /////////////////////////////////////////////////////////////////////////////
  147. /////////////////////////////////////////////////////////////////////////////
  148. /////////////////////////////////////////////////////////////////////////////
  149. // CDialogLicense dialog
  150.  
  151. CDialogLicense::CDialogLicense(CWnd* pParent /*=NULL*/)
  152.     : CDialog(CDialogLicense::IDD, pParent)
  153. {
  154. }
  155.  
  156. BEGIN_MESSAGE_MAP(CDialogLicense, CDialog)
  157. END_MESSAGE_MAP()
  158.  
  159. int CDialogLicense::DoModal()
  160. {
  161.     int status;
  162.     
  163.     status = CDialog::DoModal();
  164.  
  165.     if(status == IDOK)
  166.         return(TRUE);
  167.     else
  168.         return(FALSE);
  169.  
  170. }
  171.  
  172. BOOL CDialogLicense::OnInitDialog() 
  173. {
  174.     CDialog::OnInitDialog();
  175.  
  176.     CEdit * edit = (CEdit *) GetDlgItem(IDC_EDIT1);  
  177.     if(edit) {
  178.         LPSTR    lpszLicenseText = wfe_LoadResourceString("license");
  179.  
  180.         if (lpszLicenseText) {
  181.             edit->SetWindowText(lpszLicenseText);
  182.             CDC * pdc = GetDC();
  183.             LOGFONT lf;            // Instead of using ANSI_VAR_FONT for i18n
  184.             XP_MEMSET(&lf,0,sizeof(LOGFONT));
  185.             lf.lfPitchAndFamily = FF_MODERN | FIXED_PITCH;
  186.             lf.lfCharSet = DEFAULT_CHARSET;
  187.             strcpy(lf.lfFaceName, szLoadString(IDS_FONT_FIXNAME));
  188.                lf.lfHeight = -MulDiv(10,pdc->GetDeviceCaps(LOGPIXELSY), 72);
  189.             lf.lfQuality = PROOF_QUALITY;    
  190.             m_cfTextFont.CreateFontIndirect ( &lf );
  191.             edit->SetFont( &m_cfTextFont );
  192.             ReleaseDC(pdc);
  193.             XP_FREE(lpszLicenseText);
  194.         }
  195.     }
  196.  
  197.     return(1);
  198. }
  199.  
  200.  
  201. /////////////////////////////////////////////////////////////////////////////
  202. /////////////////////////////////////////////////////////////////////////////
  203. /////////////////////////////////////////////////////////////////////////////
  204. /////////////////////////////////////////////////////////////////////////////
  205. /////////////////////////////////////////////////////////////////////////////
  206. // CDialogSecurity dialog
  207.  
  208. CDialogSecurity::CDialogSecurity(int myType, XP_Bool *returnPref, CWnd* pParent /*=NULL*/)
  209.     : CDialog(CDialogSecurity::IDD, pParent)
  210. {   
  211.     if((myType < 0) || (myType > MAX_SECURITY_CHECKS - 1))
  212.         myType = 0;
  213.  
  214.     m_Type = myType;
  215.  
  216.     returnpref = returnPref;
  217. }
  218.  
  219. BEGIN_MESSAGE_MAP(CDialogSecurity, CDialog)
  220. END_MESSAGE_MAP()
  221.  
  222. int CDialogSecurity::DoModal()
  223. {
  224.     int status;
  225.     
  226.     status = CDialog::DoModal();
  227.  
  228.     if(status == IDOK)
  229.         return(TRUE);
  230.     else
  231.         return(FALSE);
  232.  
  233. }
  234.  
  235. //
  236. // If we've gotten here then obviously the dialog is enabled so
  237. //   turn the little button thingie on and shove the proper text into
  238. //   the edit area
  239. //
  240. BOOL CDialogSecurity::OnInitDialog() 
  241. {   
  242.     Bool      allowTurnOff = TRUE;
  243.     Bool      allowCancel  = TRUE;
  244.     CButton * button;
  245.  
  246.     CDialog::OnInitDialog();
  247.  
  248.     if ( returnpref == NULL ) {
  249.         allowTurnOff = FALSE;
  250.     }
  251.     CEdit * edit = (CEdit *) GetDlgItem(IDC_SECUREALERTEDIT);  
  252.     if(edit) {
  253.         switch(m_Type) {
  254.           case SD_ENTERING_SECURE_SPACE:
  255.               edit->SetWindowText(szLoadString(IDS_ENTER_SECURE_0));
  256.               allowCancel = FALSE;
  257.               break;
  258.         case SD_LEAVING_SECURE_SPACE:
  259.               edit->SetWindowText(szLoadString(IDS_LEAVE_SECURE_0));
  260.               break;
  261.         case SD_INSECURE_POST_FROM_INSECURE_DOC:
  262.               edit->SetWindowText(szLoadString(IDS_NONSEC_POST_FR_NONSEC_0));
  263.               break;  
  264.         case SD_INSECURE_POST_FROM_SECURE_DOC:
  265.               edit->SetWindowText(szLoadString(IDS_NONSEC_POST_FR_SEC_0));
  266.               break;  
  267.         case SD_INSECURE_DOCS_WITHIN_SECURE_DOCS_NOT_SHOWN:
  268.               edit->SetWindowText(szLoadString(IDS_NONSEC_INLINES_0));
  269.               allowCancel = FALSE;
  270.               break;  
  271.         case SD_REDIRECTION_TO_INSECURE_DOC:
  272.               edit->SetWindowText(szLoadString(IDS_NONSEC_REDIRECT_0)); 
  273.               break;  
  274.         case SD_REDIRECTION_TO_SECURE_SITE:
  275.               edit->SetWindowText(szLoadString(IDS_REDIRECT_TO_SECURE)); 
  276.               break;  
  277.         default:
  278.           edit->SetWindowText(szLoadString(IDS_NONSEC_UNKNOWN));
  279.         } 
  280.     }
  281.   
  282.     button = (CButton *) GetDlgItem(IDC_SECURESHOWAGAIN);
  283.     if(button)
  284.       button->SetCheck(TRUE);  
  285.  
  286.     // can't turn off redirection warning
  287.     if(!allowTurnOff && button)
  288.         button->ShowWindow(SW_HIDE);
  289.  
  290.  
  291.     button = (CButton *) GetDlgItem(IDCANCEL);
  292.     if(!allowCancel)
  293.         button->EnableWindow(FALSE);
  294.   
  295.     return(1);
  296. }
  297.  
  298. void CDialogSecurity::OnOK()
  299.  
  300.     CButton * button = (CButton *) GetDlgItem(IDC_SECURESHOWAGAIN);
  301.     if(button) {
  302.         theApp.m_nSecurityCheck[m_Type] = button->GetCheck(); 
  303.         if ( returnpref ) {
  304.             if ( theApp.m_nSecurityCheck[m_Type] ) {
  305.                 *returnpref = TRUE;
  306.             } else {
  307.                 *returnpref = FALSE;
  308.             }
  309.         }
  310.     }
  311.  
  312.     CDialog::OnOK();
  313. }
  314.  
  315.  
  316. /////////////////////////////////////////////////////////////////////////////
  317. /////////////////////////////////////////////////////////////////////////////
  318. /////////////////////////////////////////////////////////////////////////////
  319. // CDialogPRMT dialog
  320.  
  321. CDialogPRMT::CDialogPRMT(CWnd* pParent /*=NULL*/)
  322.     : CDialog(CDialogPRMT::IDD, pParent)
  323. {
  324.     m_csTitle = _T("");
  325.     
  326.     //{{AFX_DATA_INIT(CDialogPRMT)
  327.     m_csAns = "";
  328.     //}}AFX_DATA_INIT
  329. }
  330.  
  331. void CDialogPRMT::DoDataExchange(CDataExchange* pDX)
  332. {
  333.     CDialog::DoDataExchange(pDX);
  334.     //{{AFX_DATA_MAP(CDialogPRMT)
  335.     DDX_Text(pDX, IDC_PROMPT_ASK, m_csAsk);
  336.     DDX_Text(pDX, IDC_PROMPT_ANS, m_csAns);
  337.     //}}AFX_DATA_MAP
  338. }
  339.  
  340. BEGIN_MESSAGE_MAP(CDialogPRMT, CDialog)
  341.     //{{AFX_MSG_MAP(CDialogPRMT)
  342.         // NOTE: the ClassWizard will add message map macros here
  343.     //}}AFX_MSG_MAP
  344. END_MESSAGE_MAP()
  345.  
  346. /////////////////////////////////////////////////////////////////////////////
  347. // CDialogPRMT message handlers
  348.  
  349. char * CDialogPRMT::DoModal(const char * Msg, const char * Dflt, const char *pszCaption)
  350. {
  351.     int status;
  352.     if(!m_csAsk.IsEmpty()) 
  353.         m_csAsk.Empty();
  354.  
  355.     if(!m_csAns.IsEmpty())
  356.         m_csAns.Empty();
  357.  
  358.     m_csAsk = Msg;
  359.     m_csAns = Dflt;
  360.     if (pszCaption)
  361.         m_csCaption = pszCaption;
  362.     else
  363.         m_csCaption.Format(szLoadString(IDS_USER_PROMPT), szLoadString(AFX_IDS_APP_TITLE));
  364.  
  365.  
  366.     status = CDialog::DoModal();
  367.  
  368.     if(status == IDOK)
  369.         return(XP_STRDUP((const char *) m_csAns));
  370.     else    
  371.         return(NULL);
  372. }                        
  373.  
  374. int CDialogPRMT::OnInitDialog()
  375. {   
  376.     if( !m_csTitle.IsEmpty() )
  377.         SetWindowText( (LPCSTR)m_csTitle );
  378.     else
  379.         SetWindowText(m_csCaption);   
  380.     
  381.     CWnd *pWnd = GetDlgItem(IDC_PROMPT_ASK);
  382.     if (pWnd)
  383.         pWnd->SetWindowText(m_csAsk);
  384.  
  385.     CEdit *edit = (CEdit *) GetDlgItem(IDC_PROMPT_ANS);
  386.     if (edit) {
  387.         edit->SetWindowText(m_csAns);
  388.         edit->SetFocus();
  389.         edit->SetSel(0, -1);
  390.         return(0);
  391.     }
  392.  
  393.     return(TRUE);
  394. }
  395.  
  396. /////////////////////////////////////////////////////////////////////////////
  397. /////////////////////////////////////////////////////////////////////////////
  398. /////////////////////////////////////////////////////////////////////////////
  399. // CDialogPASS dialog
  400.  
  401. CDialogPASS::CDialogPASS(CWnd* pParent /*=NULL*/)
  402.     : CDialog(CDialogPASS::IDD, pParent)
  403. {
  404.     m_csTitle = _T("");
  405.     
  406.     //{{AFX_DATA_INIT(CDialogPASS)
  407.     m_csAns = "";
  408.     //}}AFX_DATA_INIT
  409. }
  410.  
  411. void CDialogPASS::DoDataExchange(CDataExchange* pDX)
  412. {
  413.     CDialog::DoDataExchange(pDX);
  414.     //{{AFX_DATA_MAP(CDialogPASS)
  415.     DDX_Text(pDX, IDC_PROMPT_ASK, m_csAsk);
  416.     DDX_Text(pDX, IDC_PROMPT_ANS, m_csAns);
  417.     //}}AFX_DATA_MAP
  418. }
  419.  
  420. BEGIN_MESSAGE_MAP(CDialogPASS, CDialog)
  421.     //{{AFX_MSG_MAP(CDialogPASS)
  422.         // NOTE: the ClassWizard will add message map macros here
  423.     //}}AFX_MSG_MAP
  424. END_MESSAGE_MAP()
  425.  
  426. /////////////////////////////////////////////////////////////////////////////
  427. // CDialogPASS message handlers
  428.  
  429. char * CDialogPASS::DoModal(const char * Msg)
  430. {
  431.     int status;
  432.     if(!m_csAsk.IsEmpty()) 
  433.         m_csAsk.Empty();
  434.  
  435.     if(!m_csAns.IsEmpty())
  436.         m_csAns.Empty();
  437.  
  438.     m_csAsk = Msg;
  439.     status = CDialog::DoModal();
  440.  
  441.     if(status == IDOK)
  442.         return(XP_STRDUP((const char *) m_csAns));
  443.     else    
  444.         return(NULL);
  445. }
  446.                                                              
  447.                                                              
  448. int CDialogPASS::OnInitDialog()
  449. {
  450.  
  451.     CDialog::OnInitDialog();
  452.  
  453. #ifndef XP_WIN32
  454.     //win16 only
  455.     if ( m_hWnd ) {
  456.         BringWindowToTop();
  457.         SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
  458.     }
  459. #endif
  460.  
  461.     if( !m_csTitle.IsEmpty() )
  462.         SetWindowText( (LPCSTR)m_csTitle );
  463.     
  464.     CEdit * edit = (CEdit *) GetDlgItem(IDC_PROMPT_ANS);
  465.  
  466.     if(edit) {
  467.         edit->SetFocus();
  468.         edit->SetSel(0, -1);
  469.         return(0);
  470.     }
  471.  
  472.     return(1);
  473.  
  474. }
  475.  
  476.                                                              
  477. /////////////////////////////////////////////////////////////////////////////
  478. // CDialogUPass dialog
  479.  
  480.  
  481. CDialogUPass::CDialogUPass(CWnd* pParent /*=NULL*/)
  482.   : CDialog(CDialogUPass::IDD, pParent)
  483. {
  484.   //{{AFX_DATA_INIT(CDialogUPass)
  485.     // NOTE: the ClassWizard will add member initialization here
  486.   //}}AFX_DATA_INIT
  487. }
  488.  
  489. void CDialogUPass::DoDataExchange(CDataExchange* pDX)
  490. {
  491.     CDialog::DoDataExchange(pDX);
  492.     //{{AFX_DATA_MAP(CDialogUPass)
  493.     DDX_Text(pDX, IDC_PROMPT, m_csMessage);
  494.     DDX_Text(pDX, IDC_EDIT1, m_csUser);
  495.     DDX_Text(pDX, IDC_EDIT2, m_csPasswd);
  496.     //}}AFX_DATA_MAP
  497. }
  498.  
  499. BEGIN_MESSAGE_MAP(CDialogUPass, CDialog)
  500.   //{{AFX_MSG_MAP(CDialogUPass)
  501.     // NOTE: the ClassWizard will add message map macros here
  502.   //}}AFX_MSG_MAP
  503. END_MESSAGE_MAP()
  504.  
  505.  
  506. /////////////////////////////////////////////////////////////////////////////
  507. // CDialogUPass message handlers
  508.  
  509. int CDialogUPass::DoModal(char * message, char ** user, char ** passwd)
  510. {
  511.  
  512.     int status;
  513.  
  514.     if(!user || !passwd)
  515.         return(FALSE);
  516.  
  517.     if(message)
  518.         m_csMessage = message;
  519.     else
  520.         m_csMessage = szLoadString(IDS_AUTH_DEFAULT);
  521.  
  522.     if(*user)
  523.         m_csUser   = *user;
  524.     else
  525.         m_csUser   = "";
  526.  
  527.     m_csPasswd = "";
  528.  
  529.     status = CDialog::DoModal();
  530.  
  531.     if(status != IDOK)
  532.         return(FALSE);
  533.   
  534.     *user   = XP_STRDUP((const char *) m_csUser);
  535.     *passwd = XP_STRDUP((const char *) m_csPasswd);
  536.  
  537.     return(TRUE);
  538.  
  539. }
  540.  
  541. int CDialogUPass::OnInitDialog()
  542. {
  543.     CDialog::OnInitDialog();
  544.  
  545. #ifndef XP_WIN32
  546.     //win16 only
  547.     if ( m_hWnd ) {
  548.         BringWindowToTop();
  549.         SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
  550.     }
  551. #endif
  552.  
  553.     if( !m_csTitle.IsEmpty() )
  554.         SetWindowText( (LPCSTR)m_csTitle );
  555.     
  556.     return(1);
  557. }
  558.  
  559.  
  560. /////////////////////////////////////////////////////////////////////////////
  561. // CUnknownTypeDlg dialog
  562.  
  563.  
  564. CUnknownTypeDlg::CUnknownTypeDlg(CWnd* pParent /*=NULL*/, char * filetype,CHelperApp * app)
  565.   : CDialog(CUnknownTypeDlg::IDD, pParent)
  566. {
  567.     //{{AFX_DATA_INIT(CUnknownTypeDlg)
  568.     m_FileType = filetype;
  569.     m_app = app;
  570.     //}}AFX_DATA_INIT
  571. }
  572.  
  573. void CUnknownTypeDlg::DoDataExchange(CDataExchange* pDX)
  574. {
  575.     CDialog::DoDataExchange(pDX);
  576.     //{{AFX_DATA_MAP(CUnknownTypeDlg)
  577.     DDX_Text(pDX, IDC_FILETYPE, m_FileType);
  578.     //}}AFX_DATA_MAP
  579. }
  580.  
  581. BEGIN_MESSAGE_MAP(CUnknownTypeDlg, CDialog)
  582.     //{{AFX_MSG_MAP(CUnknownTypeDlg)
  583.     ON_BN_CLICKED(ID_CONFIGUREVIEWER, OnConfigureviewer)
  584.     ON_BN_CLICKED(ID_SAVETODISK, OnSavetodisk)
  585.     ON_BN_CLICKED(IDC_MORE_INFO, OnMoreInfo)
  586.     //}}AFX_MSG_MAP
  587. END_MESSAGE_MAP()
  588.  
  589.  
  590. /////////////////////////////////////////////////////////////////////////////
  591. // CUnknownTypeDlg message handlers
  592.  
  593. void CUnknownTypeDlg::OnConfigureviewer()
  594. {
  595.     CConfigureViewerSmall dlg(this, (const char *)m_FileType, m_app);
  596.  
  597.     if (dlg.DoModal() == IDOK) {
  598.         //    Ensure the app points to what the user actually typed in.
  599.         m_app->csCmd = dlg.m_AppName;
  600.         m_app->bChanged = TRUE;
  601.         m_app->how_handle = HANDLE_EXTERNAL;
  602.         EndDialog(HANDLE_EXTERNAL);
  603.     }
  604. }
  605.  
  606. void CUnknownTypeDlg::OnSavetodisk()
  607. {
  608.     EndDialog(HANDLE_SAVE); 
  609. }
  610.  
  611. void CUnknownTypeDlg::OnCancel()
  612. {
  613.     CDialog::OnCancel();
  614. }
  615.  
  616. void CUnknownTypeDlg::OnMoreInfo()
  617. {
  618.     EndDialog(HANDLE_MOREINFO); 
  619. }
  620. /////////////////////////////////////////////////////////////////////////////
  621. // CNewMimeType dialog
  622.  
  623.  
  624. CNewMimeType::CNewMimeType(CWnd* pParent /*=NULL*/)
  625.   : CDialog(CNewMimeType::IDD, pParent)
  626. {
  627.     //{{AFX_DATA_INIT(CNewMimeType)
  628.     m_MimeSubtype = "";
  629.     m_MimeType = "";
  630.     //}}AFX_DATA_INIT
  631. }
  632.  
  633. void CNewMimeType::DoDataExchange(CDataExchange* pDX)
  634. {
  635.     CDialog::DoDataExchange(pDX);
  636.     //{{AFX_DATA_MAP(CNewMimeType)
  637.     DDX_Text(pDX, IDC_MIMESUBTYPE_EDIT, m_MimeSubtype);
  638.     DDX_Text(pDX, IDC_MIMETYPE_EDIT, m_MimeType);
  639.     //}}AFX_DATA_MAP
  640. }
  641.  
  642. BEGIN_MESSAGE_MAP(CNewMimeType, CDialog)
  643.   //{{AFX_MSG_MAP(CNewMimeType)
  644.     // NOTE: the ClassWizard will add message map macros here
  645.   //}}AFX_MSG_MAP
  646. END_MESSAGE_MAP()
  647.  
  648.  
  649. /////////////////////////////////////////////////////////////////////////////
  650. // CNewMimeType message handlers
  651. /////////////////////////////////////////////////////////////////////////////
  652. // CConfigureViewerSmall dialog
  653.  
  654.  
  655. CConfigureViewerSmall::CConfigureViewerSmall(CWnd* pParent /*=NULL*/, const char * filetype,  CHelperApp * app)
  656.   : CDialog(CConfigureViewerSmall::IDD, pParent)
  657. {
  658.     //{{AFX_DATA_INIT(CConfigureViewerSmall)
  659.     m_MimeType = filetype;
  660.     m_AppName = _T("");
  661.     //}}AFX_DATA_INIT
  662.  
  663.     m_app = app;
  664. }
  665.  
  666. void CConfigureViewerSmall::DoDataExchange(CDataExchange* pDX)
  667. {
  668.     CDialog::DoDataExchange(pDX);
  669.     //{{AFX_DATA_MAP(CConfigureViewerSmall)
  670.     DDX_Text(pDX, IDC_MIMETYPE_EDIT, m_MimeType);
  671.     DDX_Text(pDX, IDC_HELPER_PATH, m_AppName);
  672.     //}}AFX_DATA_MAP
  673. }
  674.  
  675. BEGIN_MESSAGE_MAP(CConfigureViewerSmall, CDialog)
  676.   //{{AFX_MSG_MAP(CConfigureViewerSmall)
  677.   ON_BN_CLICKED(IDC_HELPER_BROWSE, OnHelperBrowse)
  678.   //}}AFX_MSG_MAP
  679. END_MESSAGE_MAP()
  680.  
  681.  
  682. /////////////////////////////////////////////////////////////////////////////
  683. // CConfigureViewerSmall message handlers
  684.  
  685. void CConfigureViewerSmall::OnHelperBrowse()
  686. {
  687.     char * name;
  688.  
  689.     name = wfe_GetExistingFileName(m_hWnd,
  690.                           szLoadString(IDS_SELECT_APPROPRIATE_VIEWER), EXE, TRUE);
  691.  
  692.     // user selected a file
  693.     if(name) {
  694.         CStatic   * pIcon = (CStatic *)GetDlgItem(IDC_HELPER_STATIC4);
  695.         HICON hIcon;
  696.  
  697.         //    NT can't handle paths with spaces
  698.         //    We don't deal with it here, so it's up to the user.
  699.         //    If they quote it in their registry, then we preserve their string.
  700.  
  701.         //    Force redraw of the name they enetered.
  702.         CEdit *pEdit = (CEdit *)GetDlgItem(IDC_HELPER_PATH);
  703.         if(pEdit)    {
  704.             pEdit->SetWindowText(name);
  705.         }
  706.  
  707.         hIcon = ExtractIcon(theApp.m_hInstance,(const char *)m_AppName,0);
  708.         pIcon->SetIcon(hIcon);
  709.         XP_FREE(name);    
  710.     } 
  711. }
  712.  
  713.  
  714. /****************************************************************************
  715. *
  716. *    Class: CDefaultBrowserDlg
  717. *
  718. *    DESCRIPTION:
  719. *        This provides a dialog for notifying the user that another application
  720. *        has made themselves the "default browser" by changing our registry
  721. *        entries.
  722. *
  723. ****************************************************************************/
  724.  
  725. BEGIN_MESSAGE_MAP(CDefaultBrowserDlg, CDefaultBrowserDlgBase)
  726.     //{{AFX_MSG_MAP(CDefaultBrowserDlg)
  727.     ON_BN_CLICKED(ID_NO, OnNo)
  728.     ON_WM_PAINT()
  729.     //}}AFX_MSG_MAP
  730. END_MESSAGE_MAP()
  731.  
  732. /****************************************************************************
  733. *
  734. *    CDefaultBrowserDlg::CDefaultBrowserDlg
  735. *
  736. *    PARAMETERS:
  737. *        pParent    - pointer to parent window (= NULL)
  738. *
  739. *    RETURNS:
  740. *        N/A
  741. *
  742. *    DESCRIPTION:
  743. *        Standard dialog constructor.
  744. *
  745. ****************************************************************************/
  746.  
  747. CDefaultBrowserDlg::CDefaultBrowserDlg(CWnd* pParent /*=NULL*/)
  748.     : CDefaultBrowserDlgBase(CDefaultBrowserDlg::IDD, pParent)
  749. {
  750.     //{{AFX_DATA_INIT(CDefaultBrowserDlg)
  751.     m_bIgnore = FALSE;
  752.     //}}AFX_DATA_INIT
  753.     
  754. } // END OF    FUNCTION CDefaultBrowserDlg::CDefaultBrowserDlg()
  755.  
  756. /****************************************************************************
  757. *
  758. *    CDefaultBrowserDlg::DoDataExchange
  759. *
  760. *    PARAMETERS:
  761. *        pDX    - the usual CDataExchange pointer
  762. *
  763. *    RETURNS:
  764. *        void
  765. *
  766. *    DESCRIPTION:
  767. *        Standard dialog data exchange function.
  768. *
  769. ****************************************************************************/
  770.  
  771. void CDefaultBrowserDlg::DoDataExchange(CDataExchange* pDX)
  772. {
  773.     CDefaultBrowserDlgBase::DoDataExchange(pDX);
  774.     
  775.     //{{AFX_DATA_MAP(CDefaultBrowserDlg)
  776.     DDX_Check(pDX, IDC_IGNORE, m_bIgnore);
  777.     DDX_Control(pDX, IDC_LIST1, m_Listbox);
  778.     //}}AFX_DATA_MAP
  779.     
  780. } // END OF    FUNCTION CDefaultBrowserDlg::DoDataExchange()
  781.  
  782. /****************************************************************************
  783. *
  784. *    CDefaultBrowserDlg::OnNo
  785. *
  786. *    PARAMETERS:
  787. *        None
  788. *
  789. *    RETURNS:
  790. *        void
  791. *
  792. *    DESCRIPTION:
  793. *        This handles the 'No' button. We treat it just like OnOK, except
  794. *        for the return value.
  795. *
  796. ****************************************************************************/
  797.  
  798. void CDefaultBrowserDlg::OnNo() 
  799. {
  800.     if (UpdateData(TRUE))
  801.     {
  802.         EndDialog(ID_NO);
  803.     }  /* end if */
  804.     
  805. } // END OF    FUNCTION CDefaultBrowserDlg::OnNo()
  806.  
  807. /****************************************************************************
  808. *
  809. *    CDefaultBrowserDlg::OnPaint
  810. *
  811. *    PARAMETERS:
  812. *        None
  813. *
  814. *    RETURNS:
  815. *        void
  816. *
  817. *    DESCRIPTION:
  818. *        We use this WM_PAINT handler to draw the standard Windows question
  819. *        icon on the dialog, so it looks more like a message box.
  820. *
  821. ****************************************************************************/
  822.  
  823. void CDefaultBrowserDlg::OnPaint() 
  824. {
  825.     CPaintDC dc(this);
  826.     
  827.     // Draw the Windows question icon in the placeholder
  828.     CWnd * pwndIcon = GetDlgItem(IDC_WARNING_ICON);
  829.     ASSERT(pwndIcon != NULL);
  830.     if (pwndIcon != NULL)
  831.     {
  832.         CRect rc;
  833.         pwndIcon->GetWindowRect(rc);
  834.         ScreenToClient(rc);
  835.         dc.DrawIcon(rc.TopLeft(), ::LoadIcon(NULL, IDI_EXCLAMATION));
  836.     }  /* end if */
  837.     
  838.     // Do not call CDefaultBrowserDlgBase::OnPaint() for painting messages
  839.     
  840. } // END OF    FUNCTION CDefaultBrowserDlg::OnPaint()
  841.  
  842. BOOL CDefaultBrowserDlg::OnInitDialog()
  843. {
  844.     BOOL res = CDialog::OnInitDialog();
  845.  
  846.     // Fill in the dialog's list box
  847.     CPtrArray* lostList = theApp.m_OwnedAndLostList.GetLostList();
  848.     
  849.     // Add to list
  850.     int size = lostList->GetSize();
  851.     for (int i = 0; i < size; i++)
  852.     {
  853.         COwnedLostItem* theItem = (COwnedLostItem*)((*lostList)[i]);
  854.  
  855.         if (!theItem->m_bIgnored)
  856.         {
  857.             theItem->FetchPrettyName();
  858.             if (theItem->m_csPrettyName != "")
  859.             {
  860.                 int index = m_Listbox.AddString(theItem->m_csPrettyName);
  861.                 m_Listbox.SetItemDataPtr(index, theItem);
  862.             }
  863.         }
  864.  
  865.         m_Listbox.SetSel(-1);
  866.     }
  867.  
  868.     return res;
  869. }
  870.  
  871. static BOOL IsListItemSelected(int* selArray, int count, int i)
  872. {
  873.     for (int x = 0; x < count; x++)
  874.     {
  875.         int item = selArray[x];
  876.         if (i == item)
  877.             return TRUE;
  878.     }
  879.     return FALSE;
  880. }
  881.  
  882. void CDefaultBrowserDlg::OnOK()
  883. {
  884.     // Let's do it. Selected items become owned.
  885.     // Unselected items become ignored (if the checkbox is checked)
  886.     CDefaultBrowserDlgBase::OnOK();
  887.  
  888.     int count = m_Listbox.GetCount();
  889.     int* selArray = new int[count];
  890.  
  891.     int nSelectedArraySize = m_Listbox.GetSelItems(count, selArray);
  892.         
  893.     for (int i = 0; i < count; i++)
  894.     {
  895.         COwnedLostItem* theItem = (COwnedLostItem*)(m_Listbox.GetItemDataPtr(i));
  896.         
  897.         if (IsListItemSelected(selArray, count, i))
  898.         {
  899.             // Remove it from the lost list.
  900.             theApp.m_OwnedAndLostList.RemoveFromLostList(theItem->m_csMimeType);
  901.             
  902.             // Add it to the owned list.
  903.             theApp.m_OwnedAndLostList.GetOwnedList()->Add(theItem);
  904.  
  905.             // Modify the HelperApp information (write to the registry)
  906.             // Fun fun fun!
  907.             theItem->GiveControlToNetscape();
  908.         }
  909.         else if (m_bIgnore)
  910.         {
  911.             // User wants to ignore this item. Add it to the ignore list.
  912.             theItem->SetIgnored(TRUE);
  913.         }
  914.     }    
  915. }
  916.