home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / askmedlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.9 KB  |  145 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. // AskMeDlg.cpp : implementation file
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "askmedlg.h"
  24. #include "prefapi.h"
  25.  
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32. void AskMeDlg(void)
  33. {
  34.         int32 nPromptAskMe = FALSE;
  35.         PREF_GetIntPref("offline.startup_mode", &nPromptAskMe);
  36.         if (nPromptAskMe==0)            //online
  37.             PREF_SetBoolPref("network.online", TRUE);
  38.         else if (nPromptAskMe==1)       //offline
  39.             PREF_SetBoolPref("network.online", FALSE);
  40.         else if (nPromptAskMe==2)   //ask me
  41.         {
  42.             CAskMeDlg rAskMeDlg(nPromptAskMe);
  43.             rAskMeDlg.DoModal();
  44.         }
  45. }
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CAskMeDlg dialog
  49.  
  50.  
  51. CAskMeDlg::CAskMeDlg(BOOL bDefault/*FALSE*/, int nOnOffLine/*0-the default*/,
  52.                      CWnd* pParent /*=NULL*/)
  53.     : CDialog(CAskMeDlg::IDD, pParent)
  54. {
  55.     XP_Bool bOnline = TRUE;
  56.     PREF_GetBoolPref("network.online", &bOnline);
  57.  
  58.     //{{AFX_DATA_INIT(CAskMeDlg)
  59.     m_nStartupSelection = (bOnline == 1 ? 0 : 1);
  60.     m_bAskMeDefault = 0;
  61.     //}}AFX_DATA_INIT
  62. }
  63.  
  64.  
  65. void CAskMeDlg::DoDataExchange(CDataExchange* pDX)
  66. {
  67.     CDialog::DoDataExchange(pDX);
  68.     //{{AFX_DATA_MAP(CAskMeDlg)
  69.     DDX_Radio(pDX, IDC_RADIO_ONLINE, m_nStartupSelection);
  70.     DDX_Check(pDX, IDC_CHECK_ASKME_DEFAULT, m_bAskMeDefault);
  71.     //}}AFX_DATA_MAP
  72. }
  73.  
  74.  
  75. BEGIN_MESSAGE_MAP(CAskMeDlg, CDialog)
  76.     //{{AFX_MSG_MAP(CAskMeDlg)
  77.     ON_BN_CLICKED(IDC_CHECK_ASKME_DEFAULT, OnCheckAskMeDefault)
  78.     //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CAskMeDlg message handlers
  83.  
  84. void CAskMeDlg::OnOK() 
  85. {
  86.     //Save any preference settings that may have been chosen
  87.     CDialog::OnOK();
  88.     UpdateData();
  89.     if (IsDlgButtonChecked(IDC_CHECK_ASKME_DEFAULT))
  90.     {
  91.         if (IsDlgButtonChecked(IDC_RADIO_ONLINE))
  92.         {
  93.             PREF_SetBoolPref("network.online", TRUE);
  94.             PREF_SetIntPref("offline.startup_mode",0);
  95.         }
  96.         else  
  97.         {
  98.             PREF_SetBoolPref("network.online", FALSE);
  99.             PREF_SetIntPref("offline.startup_mode",1);
  100.         }
  101.     }
  102.     else
  103.     {
  104.         if (IsDlgButtonChecked(IDC_RADIO_ONLINE))
  105.             PREF_SetBoolPref("network.online", TRUE);
  106.         else  
  107.             PREF_SetBoolPref("network.online", FALSE);
  108.     }
  109.  
  110. }
  111.  
  112. void CAskMeDlg::OnCheckAskMeDefault() 
  113. {   
  114. }
  115.  
  116.  
  117. void CAskMeDlg::EnableDisableItem(BOOL bState, UINT nIDC)
  118. {
  119.     CWnd *pWnd = GetDlgItem(nIDC);
  120.     if (pWnd)
  121.     {
  122.         pWnd->EnableWindow(bState);
  123.     }
  124. }
  125.  
  126. BOOL CAskMeDlg::OnInitDialog() 
  127. {
  128.     BOOL bReturn = CDialog::OnInitDialog();
  129.     CWnd *pWnd = NULL;
  130.  
  131.     HFONT hFont = (HFONT)this->SendMessage(WM_GETFONT);
  132.     if (hFont != NULL)
  133.     {   //make the title bold
  134.         VERIFY(::GetObject(hFont, sizeof(LOGFONT), &m_LogFont));
  135.         m_LogFont.lfWeight=FW_BOLD;
  136.         m_hFont = theApp.CreateAppFont( m_LogFont );
  137.         ::SendMessage(::GetDlgItem(m_hWnd, IDC_STATIC_TITLE), WM_SETFONT, (WPARAM)m_hFont, FALSE);
  138.         ::SendMessage(::GetDlgItem(m_hWnd, IDC_RADIO_ONLINE), WM_SETFONT, (WPARAM)m_hFont, FALSE);
  139.         ::SendMessage(::GetDlgItem(m_hWnd, IDC_RADIO_OFFLINE), WM_SETFONT, (WPARAM)m_hFont, FALSE);
  140.         ::SendMessage(::GetDlgItem(m_hWnd, IDC_CHECK_ASKME_DEFAULT), WM_SETFONT, (WPARAM)m_hFont, FALSE);
  141.     }
  142.  
  143.     return bReturn; 
  144. }
  145.