home *** CD-ROM | disk | FTP | other *** search
/ Using Visual Basic 5 (Platinum Edition) / vb5.iso / ACTIVEX / SRDVID / DATA.Z / pphsgen.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-10  |  4.1 KB  |  174 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //    ppHSGen.cpp : Implementation of the CHSGeneralPage class
  4. //
  5. /////////////////////////////////////////////////////////////////////////////
  6. //
  7. //  (C) Copyright Black Diamond Consulting, Inc 1996. All rights reserved.
  8. //
  9. //    You have a royalty-free right to use, modify, reproduce and 
  10. //    distribute the Sample Files (and/or any modified version) in 
  11. //    any way you find useful, provided that you agree that Black 
  12. //    Diamond Consulting has no warranty obligations or liability
  13. //    for any Sample Application Files which are modified. 
  14. //
  15. //    Revision History:
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18.  
  19. #include "stdafx.h"
  20.  
  21. #ifndef __PPHSGEN_H__
  22.     #include "ppHSGen.h"
  23. #endif
  24.  
  25. #ifndef __CHOTSPOT_H__
  26.     #include "CHotspot.h"
  27. #endif
  28.  
  29. #ifndef __SVDOC_H__
  30.     #include "svdoc.h"
  31. #endif
  32.  
  33. #ifdef _DEBUG
  34.     #undef THIS_FILE
  35.     static char BASED_CODE THIS_FILE[] = __FILE__;
  36. #endif
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CHSGeneralPage property page
  40.  
  41.  
  42. CHSGeneralPage::CHSGeneralPage( CSVViewerDoc* pDoc, CHotspot* pHotspot )
  43.     : CPropertyPage(CHSGeneralPage::IDD)
  44. {
  45.  
  46.     m_pDocument = pDoc;
  47.     m_pHotspot = pHotspot;
  48.  
  49.     //{{AFX_DATA_INIT(CHSGeneralPage)
  50.     //}}AFX_DATA_INIT
  51. }
  52.  
  53. void CHSGeneralPage::DoDataExchange(CDataExchange* pDX)
  54. {
  55.     CPropertyPage::DoDataExchange(pDX);
  56.     //{{AFX_DATA_MAP(CHSGeneralPage)
  57.     DDX_Text( pDX,    EB_NAME,        m_pHotspot->m_name );
  58.     DDX_Text( pDX,    EB_LATITUDE,    m_pHotspot->m_location.latitude );
  59.     DDV_MinMaxLong( pDX, m_pHotspot->m_location.latitude, -1*(MAX_ARCSECONDS/2), (MAX_ARCSECONDS/2) );
  60.     DDX_Text( pDX,    EB_LONGITUDE,    m_pHotspot->m_location.longitude );
  61.     DDV_MinMaxLong( pDX, m_pHotspot->m_location.longitude, 0, MAX_ARCSECONDS-1 );
  62.     DDX_Text( pDX,    EB_HEIGHT,        m_pHotspot->m_size.cy );
  63.     DDX_Text( pDX,    EB_WIDTH,        m_pHotspot->m_size.cx );
  64.     DDX_Check( pDX, CHK_LOCKED,        m_pHotspot->m_bLocked );
  65.     //}}AFX_DATA_MAP
  66. }
  67.  
  68. BEGIN_MESSAGE_MAP(CHSGeneralPage, CPropertyPage)
  69.  
  70.     //{{AFX_MSG_MAP(CHSGeneralPage)
  71.     ON_BN_CLICKED( CHK_LOCKED, OnUpdateControls )
  72.     //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CHSGeneralPage message handlers
  77.  
  78. BOOL CHSGeneralPage::OnInitDialog()
  79. {
  80.  
  81.     CPropertyPage::OnInitDialog();
  82.  
  83.      OnUpdateControls();
  84.  
  85.     return TRUE;  // return TRUE  unless you set the focus to a control
  86. }
  87.  
  88. void CHSGeneralPage::OnCancel()
  89. {
  90.     CPropertyPage::OnCancel();
  91.     m_pDocument->UpdateAllViews( NULL );
  92. }
  93.  
  94. void CHSGeneralPage::OnOK()
  95. {
  96.     CPropertyPage::OnOK();
  97.     
  98.     // Flag Document as dirty
  99.     m_pDocument->SetModifiedFlag();
  100.     
  101.     // Cause all views to invalidate
  102.     m_pDocument->UpdateAllViews( NULL );
  103. }
  104.  
  105. // OnUpdateControls()
  106. //
  107. // This routine uses the canned controls[] struct array to determine
  108. // which controls should be enabled/disabled depending on the current
  109. // states of of its "master" control
  110. //
  111. void CHSGeneralPage::OnUpdateControls() 
  112. {
  113.     typedef struct _tagCONTROLS
  114.     {
  115.         int type;
  116.         int idMaster;
  117.         BOOL bState;
  118.         int idSlave;
  119.     } CONTROLS, *PCONTROLS;
  120.  
  121.     CWnd* pWndMaster;
  122.     CWnd* pWnd;
  123.     BOOL bEnable;
  124.      CONTROLS* ctrl;
  125.     CString text;
  126.  
  127.     CONTROLS controls[] =
  128.     {
  129.         0,    CHK_LOCKED,            FALSE,    EB_LATITUDE,
  130.         0,    0,                    FALSE,    EB_LONGITUDE,
  131.         0,    0,                    FALSE,    EB_HEIGHT,
  132.         0,    0,                    FALSE,    EB_WIDTH,
  133.         0,0,0,0
  134.     };
  135.  
  136.     ctrl = controls;
  137.     while( ctrl->idSlave != 0 )
  138.     {
  139.         if( ctrl->idMaster != 0 )
  140.         {
  141.             if( (pWndMaster = GetDlgItem( ctrl->idMaster )) == 0 )
  142.                 return;
  143.  
  144.             if( pWndMaster->IsWindowEnabled() == FALSE )
  145.                 bEnable = FALSE;
  146.             else
  147.             {
  148.                 switch( ctrl->type )
  149.                 {
  150.                     case 0:
  151.                         bEnable = IsDlgButtonChecked( ctrl->idMaster );
  152.                         break;
  153.  
  154.                     case 1:
  155.                         pWndMaster->GetWindowText( text );
  156.                         bEnable = !text.IsEmpty();
  157.                         break;
  158.  
  159.                     default:
  160.                         bEnable = FALSE;
  161.                         break;
  162.                 }
  163.             }
  164.         }
  165.         
  166.         if( (pWnd = GetDlgItem( ctrl->idSlave )) != NULL )
  167.             pWnd->EnableWindow( bEnable == ctrl->bState );
  168.  
  169.         ctrl++;
  170.     }
  171. }
  172.  
  173.  
  174.