home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / viewerse.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.7 KB  |  179 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. #include "viewerse.h"
  21.  
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CViewerSecurity dialog
  29.  
  30.  
  31. CViewerSecurity::CViewerSecurity(CWnd* pParent /*=NULL*/)
  32.     : CDialog(CViewerSecurity::IDD, pParent)
  33. {
  34.     //{{AFX_DATA_INIT(CViewerSecurity)
  35.     m_csMessage = _T("");
  36.     m_bAskNoMore = FALSE;
  37.     m_csDontAskText = _T("");
  38.     //}}AFX_DATA_INIT
  39. }
  40.  
  41.  
  42. void CViewerSecurity::DoDataExchange(CDataExchange* pDX)
  43. {
  44.     CDialog::DoDataExchange(pDX);
  45.     //{{AFX_DATA_MAP(CViewerSecurity)
  46.     DDX_Text(pDX, IDC_MESSAGE, m_csMessage);
  47.     DDX_Check(pDX, IDC_DONTASKAGAIN, m_bAskNoMore);
  48.     DDX_Text(pDX, IDC_DONTASKTEXT, m_csDontAskText);
  49.     //}}AFX_DATA_MAP
  50. }
  51.  
  52.  
  53. BEGIN_MESSAGE_MAP(CViewerSecurity, CDialog)
  54.     //{{AFX_MSG_MAP(CViewerSecurity)
  55.     //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57.  
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CViewerSecurity message handlers
  61.  
  62. void CViewerSecurity::OnCancel() 
  63. {
  64.     // TODO: Add extra cleanup here
  65.     m_bCanceled = TRUE;
  66.  
  67.     //  Call the OnOK handler to save the items therein.
  68.     CDialog::OnOK();
  69. }
  70.  
  71. void CViewerSecurity::OnOK() 
  72. {
  73.     // TODO: Add extra validation here
  74.     m_bCanceled = FALSE;
  75.     
  76.     CDialog::OnOK();
  77. }
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CLaunchHelper dialog
  81.  
  82. // XXX - this should become part of our general part utility routines...
  83. static LPSTR
  84. PathFindFileName(LPCSTR lpszPath)
  85. {
  86.     for (LPCSTR lpszFilename = lpszPath; *lpszPath; lpszPath = AnsiNext(lpszPath)) {
  87.         if ((lpszPath[0] == '\\' || lpszPath[0] == ':') && lpszPath[1] && (lpszPath[1] != '\\'))
  88.             lpszFilename = lpszPath + 1;
  89.     }
  90.  
  91.     return (LPSTR)lpszFilename;
  92. }
  93.  
  94. CLaunchHelper::CLaunchHelper(LPCSTR lpszFilename, LPCSTR lpszHelperApp, BOOL canDoOLE, CWnd* pParent)
  95.     : CDialog(CLaunchHelper::IDD, pParent)
  96. {
  97.     //{{AFX_DATA_INIT(CLaunchHelper)
  98.     m_strMessage = _T("");
  99.     m_bAlwaysAsk = FALSE;
  100.     m_nAction = HELPER_OPEN_IT;
  101.     m_bHandleByOLE = FALSE;
  102.     //}}AFX_DATA_INIT
  103.  
  104.     m_doc = lpszFilename;
  105.     m_canDoOLE = canDoOLE;
  106.     // Build the message string that's based on the name of the application. Just use
  107.     // the filename and extension part of the helper app
  108.     m_strMessage.Format(szLoadString(IDS_OPENING_FILE), lpszFilename, PathFindFileName(lpszHelperApp));
  109.  
  110.  
  111. }
  112.  
  113. BOOL
  114. CLaunchHelper::OnInitDialog()
  115. {
  116.     // Set the icon
  117.     ::SendMessage(::GetDlgItem(m_hWnd, IDC_ICON1), STM_SETICON, (WPARAM)::LoadIcon(NULL, IDI_QUESTION), 0L);
  118.  
  119.     if (!m_canDoOLE) {
  120.         EnableOLECheck(FALSE);
  121.         m_bHandleByOLE = FALSE;
  122.         ::ShowWindow(::GetDlgItem(m_hWnd, IDC_HANDLEBYOLE), SW_HIDE);
  123.  
  124.     }
  125.     else {
  126.         if (m_nAction == HELPER_OPEN_IT) {
  127.             EnableOLECheck(TRUE);
  128.         }
  129.         else {
  130.             EnableOLECheck(FALSE);
  131.         }
  132.     }
  133.     return CDialog::OnInitDialog();
  134. }
  135.  
  136. void CLaunchHelper::DoDataExchange(CDataExchange* pDX)
  137. {
  138.     CDialog::DoDataExchange(pDX);
  139.     //{{AFX_DATA_MAP(CViewerSecurity)
  140.     DDX_Text(pDX, IDC_MESSAGE, m_strMessage);
  141.     DDX_Check(pDX, IDC_CHECK1, m_bAlwaysAsk);
  142.     DDX_Check(pDX, IDC_HANDLEBYOLE, m_bHandleByOLE);
  143.     DDX_Radio(pDX, IDC_RADIO1, m_nAction);
  144.     //}}AFX_DATA_MAP
  145. }
  146. void CLaunchHelper::EnableOLECheck(BOOL enable)
  147. {
  148.     CWnd * pcWin = GetDlgItem(IDC_HANDLEBYOLE);
  149.     if (enable) {
  150.         pcWin->EnableWindow(TRUE);
  151.     }
  152.     else  // if this app does not have an ole inplace server, gray out the check box.
  153.         pcWin->EnableWindow(FALSE);
  154. }
  155.  
  156. void CLaunchHelper::OnOpenit()
  157. {
  158.     if (!m_canDoOLE) {
  159.         EnableOLECheck(FALSE);
  160.         m_bHandleByOLE = FALSE;
  161.         ::ShowWindow(::GetDlgItem(m_hWnd, IDC_HANDLEBYOLE), SW_HIDE);
  162.     }
  163.     else {
  164.         EnableOLECheck(TRUE);
  165.     }
  166. }
  167. void CLaunchHelper::OnSaveit()
  168. {
  169.     EnableOLECheck(FALSE);
  170. }
  171.  
  172. BEGIN_MESSAGE_MAP(CLaunchHelper, CDialog)
  173.     //{{AFX_MSG_MAP(CLaunchHelper)
  174.     ON_BN_CLICKED( IDC_RADIO1, OnOpenit)
  175.     ON_BN_CLICKED( IDC_RADIO2, OnSaveit)
  176.     //}}AFX_MSG_MAP
  177. END_MESSAGE_MAP()
  178.  
  179.