home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 1 / WINDOWS95_1.bin / internet / vogon / links.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-29  |  2.6 KB  |  92 lines

  1. // links.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vogon.h"
  6.  
  7. #include "CntrInfo.h"
  8. #include "CntrItem.h"
  9. #include "links.h"
  10.  
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char BASED_CODE THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CHyperlinkDlg dialog
  18.  
  19.  
  20. CHyperlinkDlg::CHyperlinkDlg(_DWebster* pWebsterDispatch, CWnd* pParent /*=NULL*/)
  21.     : CDialog(CHyperlinkDlg::IDD, pParent)
  22. {
  23.     //{{AFX_DATA_INIT(CHyperlinkDlg)
  24.     m_stringLink = _T("");
  25.     //}}AFX_DATA_INIT
  26.  
  27.    // Stash the Webster OCX dispatch pointer
  28.    m_pWebsterDispatch = pWebsterDispatch;
  29. }
  30.  
  31.  
  32. void CHyperlinkDlg::DoDataExchange(CDataExchange* pDX)
  33. {
  34.     CDialog::DoDataExchange(pDX);
  35.     //{{AFX_DATA_MAP(CHyperlinkDlg)
  36.     DDX_Control(pDX, IDC_STATIC_HYPERLINKCOUNT, m_staticLinkCount);
  37.     DDX_Control(pDX, IDC_LIST_LINKS, m_listboxLinks);
  38.     DDX_Control(pDX, IDC_EDIT_LINK, m_editLink);
  39.     DDX_Text(pDX, IDC_EDIT_LINK, m_stringLink);
  40.     //}}AFX_DATA_MAP
  41. }
  42.  
  43.  
  44. BEGIN_MESSAGE_MAP(CHyperlinkDlg, CDialog)
  45.     //{{AFX_MSG_MAP(CHyperlinkDlg)
  46.     ON_LBN_SELCHANGE(IDC_LIST_LINKS, OnSelchangeListLinks)
  47.     //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49.  
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CHyperlinkDlg message handlers
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. //
  56. BOOL CHyperlinkDlg::OnInitDialog() 
  57. {
  58.    CDialog::OnInitDialog();
  59.  
  60.    // Get the current page URL
  61.    CString stringURL(m_pWebsterDispatch->GetPageURL());
  62.  
  63.    // Get the hyperlink count for the current visible page:
  64.    int linkCount = m_pWebsterDispatch->GetLinkCount(stringURL);
  65.  
  66.    // Show hyperlink count in the static
  67.    TCHAR fmtBuf[64];
  68.    m_staticLinkCount.SetWindowText(CString(itoa(linkCount, fmtBuf, 10)));
  69.  
  70.    // Fill the list box with hyperinks:
  71.    for (int index = 0; index < linkCount; index++)
  72.    {  // Add each string to the listbox, which is unsorted
  73.       m_listboxLinks.AddString(m_pWebsterDispatch->GetLinkURL(stringURL, index));
  74.    }
  75.  
  76.    // TODO: Add extra initialization here
  77.    return TRUE;  // return TRUE unless you set the focus to a control
  78.                  // EXCEPTION: OCX Property Pages should return FALSE
  79. }
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. //
  83. void CHyperlinkDlg::OnSelchangeListLinks() 
  84. {
  85.    if (m_listboxLinks.GetCurSel() != LB_ERR)
  86.    {  // Get the selected item
  87.       m_listboxLinks.GetText(m_listboxLinks.GetCurSel(), m_stringLink);
  88.       // Copy to the edit control
  89.       m_editLink.SetWindowText(m_stringLink);
  90.    }
  91. }
  92.