home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / prefs / brpref / src / pages.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.0 KB  |  113 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 "pch.h"
  20. #include <assert.h>
  21. #include "dllcom.h"
  22. #include "pages.h"
  23. #include "xp_core.h"
  24. #include "prefapi.h"
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // Helper functions
  28.  
  29. int
  30. PREF_GetStringPref(LPCSTR lpszPref, CString &str)
  31. {
  32.     int        nBufLength = 0;
  33.  
  34.     if (PREF_GetCharPref(lpszPref, NULL, &nBufLength) == PREF_ERROR)
  35.         return PREF_ERROR;
  36.  
  37.     if (nBufLength <= 1) {
  38.         str.Empty();
  39.         return PREF_NOERROR;
  40.  
  41.     } else {
  42.         return PREF_GetCharPref(lpszPref, str.BufferSetLength(nBufLength - 1), &nBufLength);
  43.     }
  44. }
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CBrowserPropertyPage implementation
  48.  
  49. CBrowserPropertyPage::CBrowserPropertyPage(UINT nTemplateID, LPCSTR lpszHelpTopic)
  50.     : CPropertyPageEx(CComDll::m_hInstance, nTemplateID, lpszHelpTopic)
  51. {
  52. }
  53.  
  54. SIZE    CBrowserPropertyPage::m_size = {0, 0};
  55.  
  56. HRESULT
  57. CBrowserPropertyPage::GetPageSize(SIZE &size)
  58. {
  59.     // All of our pages are the same size. See if we already
  60.     // have the size
  61.     if (m_size.cx == 0) {
  62.         // Ask our base class to determine the size
  63.         HRESULT hres = CPropertyPageEx::GetPageSize(m_size);
  64.  
  65.         if (FAILED(hres))
  66.             return hres;
  67.     }
  68.  
  69.     // Use the cached size
  70.     assert(m_size.cx > 0 && m_size.cy > 0);
  71.     size = m_size;
  72.     return NOERROR;
  73. }
  74.  
  75. BOOL
  76. CBrowserPropertyPage::CheckIfLockedPref(LPCSTR lpszPref, UINT nCtlID)
  77. {
  78.     if (PREF_PrefIsLocked(lpszPref)) {
  79.         EnableDlgItem(nCtlID, FALSE);
  80.         return TRUE;
  81.     }
  82.  
  83.     return FALSE;
  84. }
  85.  
  86. // The ID must be the first in a group of auto radio buttons
  87. void
  88. CBrowserPropertyPage::DisableRadioButtonGroup(UINT nIDButton)
  89. {
  90.     HWND    hwndCtl = GetDlgItem(m_hwndDlg, nIDButton);
  91.  
  92.     assert(GetWindowStyle(hwndCtl) & WS_GROUP);
  93.     assert(SendMessage(hwndCtl, WM_GETDLGCODE, 0, 0) & DLGC_RADIOBUTTON);
  94.     
  95.     // Walk all the controls in the group. Stop when we get to the start of another group
  96.     // or there are no controls left
  97.     do {
  98.         if (SendMessage(hwndCtl, WM_GETDLGCODE, 0, 0) & DLGC_RADIOBUTTON) {
  99.             // Control is a radio button
  100.             EnableWindow(hwndCtl, FALSE);
  101. #ifdef _DEBUG
  102.         } else {
  103.             OutputDebugString("Warning: skipping non-radio button in group.\n");
  104. #endif
  105.         }
  106.  
  107.         hwndCtl = GetNextSibling(hwndCtl);
  108.  
  109.     } while (hwndCtl && !(GetWindowStyle(hwndCtl) & WS_GROUP));
  110. }
  111.  
  112.  
  113.