home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / advopdlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.5 KB  |  126 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. // AdvOpDlg.cpp : implementation file
  19. // Called from srchfrm.cpp and used to customize search for the search messages dialog.
  20.  
  21. #include "stdafx.h"
  22. #include "AdvOpDlg.h"
  23. #include "prefapi.h"
  24.  
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CAdvSearchOptionsDlg dialog
  33.  
  34.  
  35. CAdvSearchOptionsDlg::CAdvSearchOptionsDlg(CWnd* pParent /*=NULL*/)
  36.     : CDialog(CAdvSearchOptionsDlg::IDD, pParent)
  37. {
  38.     m_pParent = pParent;
  39.     if (!CDialog::Create(CAdvSearchOptionsDlg::IDD, pParent))
  40.     {
  41.         TRACE0("Warning: creation of CAdvSearchOptionsDlg dialog failed\n");
  42.         return;
  43.     }
  44.     if( m_pParent && ::IsWindow(m_pParent->m_hWnd) ){
  45.         m_pParent->EnableWindow(FALSE);
  46.     }
  47.  
  48.     this->EnableWindow(TRUE);
  49.     //{{AFX_DATA_INIT(CAdvSearchOptionsDlg)
  50.     m_bIncludeSubfolders = FALSE;
  51.     m_iSearchArea = 0;  
  52.     //}}AFX_DATA_INIT
  53.     m_bChanges= FALSE;
  54. }
  55.  
  56.  
  57. void CAdvSearchOptionsDlg::DoDataExchange(CDataExchange* pDX)
  58. {
  59.     CDialog::DoDataExchange(pDX);
  60.     //{{AFX_DATA_MAP(CAdvSearchOptionsDlg)
  61.     DDX_Check(pDX, IDC_CHECK_SUBFOLDERS, m_bIncludeSubfolders);
  62.     DDX_Radio(pDX, IDC_RADIO_SEARCH_LOCAL, m_iSearchArea);
  63.     //}}AFX_DATA_MAP
  64. }
  65.  
  66. BOOL CAdvSearchOptionsDlg::OnInitDialog()
  67. {
  68.     CDialog::OnInitDialog();
  69.     XP_Bool bSubFolders   = FALSE;
  70.     XP_Bool bSearchServer = FALSE;
  71.     PREF_GetBoolPref("mailnews.searchSubFolders",&bSubFolders);
  72.     m_bIncludeSubfolders = bSubFolders;
  73.     PREF_GetBoolPref("mailnews.searchServer",&bSearchServer);
  74.     m_iSearchArea = !bSearchServer ? 0 : 1; 
  75.     UpdateData(FALSE);
  76.  
  77.  
  78.     return TRUE;
  79. }
  80.  
  81. void CAdvSearchOptionsDlg::OnOK()
  82. {
  83.     UpdateData();
  84.     PREF_SetBoolPref("mailnews.searchSubFolders",(XP_Bool)m_bIncludeSubfolders);
  85.     XP_Bool bSearchServer = m_iSearchArea ? 1 : 0;
  86.     PREF_SetBoolPref("mailnews.searchServer", bSearchServer);
  87.     m_bChanges = TRUE;
  88.     GetParent()->PostMessage(WM_ADVANCED_OPTIONS_DONE);
  89.     OnClose();
  90. }
  91.  
  92. void CAdvSearchOptionsDlg::OnHelp()
  93. {
  94.     //!!TODO  add NetHelp(..) call here.
  95. }
  96.  
  97. void CAdvSearchOptionsDlg::PostNcDestroy()
  98. {
  99.     CDialog::PostNcDestroy();
  100.     if( m_pParent && ::IsWindow(m_pParent->m_hWnd) ){
  101.         m_pParent->EnableWindow(TRUE);
  102.         // Return focus to parent window
  103.         m_pParent->SetActiveWindow();
  104.         m_pParent->SetFocus();
  105.     }
  106.     delete this;
  107. }
  108.  
  109.  
  110. void CAdvSearchOptionsDlg::OnClose()
  111. {
  112.     DestroyWindow();
  113. }
  114.  
  115.  
  116. BEGIN_MESSAGE_MAP(CAdvSearchOptionsDlg, CDialog)
  117.     //{{AFX_MSG_MAP(CAdvSearchOptionsDlg)
  118.     ON_BN_CLICKED( IDOK, OnOK)
  119.     ON_BN_CLICKED( IDC_ADVANCED_SEARCH_HELP, OnHelp)
  120.     ON_COMMAND(IDCANCEL, OnClose)
  121.     //}}AFX_MSG_MAP
  122. END_MESSAGE_MAP()
  123.  
  124. /////////////////////////////////////////////////////////////////////////////
  125. // CAdvSearchOptionsDlg message handlers
  126.