Activate the navigation functions
Return to Main

Resume :
  1. To make the navigation function - First .
    • To add a member function(handler function), using ClassWizard.
    • To use the Recordset Navigation Operation - MoveFirst (member of CDaoRecordset).
    • To display the record corresponding ...
  2. To make the navigation function - Previous.
    • To add a member function(handler function), using ClassWizard.
    • To use the Recordset Navigation Operation - MovePrev (member of CDaoRecordset).
    • To display the record corresponding ...
  3. To make the navigation function - Next .
    • To add a member function(handler function), using ClassWizard.
    • To use the Recordset Navigation Operation - MoveNext (member of CDaoRecordset).
    • To display the record corresponding ....
  4. To make the navigation function - Last .
    • To add a member function(handler function), using ClassWizard.
    • To use the Recordset Navigation Operation - MoveLast (member of CDaoRecordset).
    • To display the record corresponding ...

Details ...

  1. To make the navigation function - First :

    1. ClassWizard, Add the member function - ( object ID: IDC_RECORD_FIRST).
    2. On the View menu, click ClassWizard.
      The MFC ClassWizard dialog box appears, click the Message Maps tab.
    3. In the Class name box, select the class CTestVC0Dlg.
    4. In the Object IDs list, select the IDC_RECORD_FIRST.
    5. In the Messages list, select the BN_CLICKED.
    6. Click Add Function.
    7. The Add Member Function dialog box appears, click OK.
      To accept the default Member function name -
      OnRecordFirst display(or rename it) and then
      click OK.
      The new item message -
      OnRecordFirst ....... ON_IDC_RECORD_FIRST:BN_CLICKED appearing in the Member functions list.
      ClassWizard makes changes to TestVC0Dlg.h and TestVC0Dlg.cpp files after you’ve
      added the member function. Examine these changes ...

      TestVC0Dlg.h file
      - the new Text Code is red.

      // TestVC0Dlg.h : header file
      //
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      // Generated message map functions
      //{{AFX_MSG(CTestVC0Dlg)
      virtual BOOL OnInitDialog();
      afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
      afx_msg void OnPaint();
      afx_msg HCURSOR OnQueryDragIcon();
      afx_msg void OnRecordFirst();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
      ...................................................................................................................................................
      ...................................................................................................................................................

      ...


      TestVC0Dlg.cpp file - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      void CTestVC0Dlg::DoDataExchange(CDataExchange* pDX)
      {
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CTestVC0Dlg)
      DDX_Text(pDX, IDC_BOOK, m_book);
      DDX_Text(pDX, IDC_CHAPTER, m_chapter);
      DDX_Text(pDX, IDC_TITLE, m_title);
      DDX_Text(pDX, IDC_VERSE, m_verse);
      DDX_Text(pDX, IDC_TEXTDATA, m_textdata);
      //}}AFX_DATA_MAP
      }

      BEGIN_MESSAGE_MAP(CTestVC0Dlg, CDialog)
      //{{AFX_MSG_MAP(CTestVC0Dlg)
      ON_WM_SYSCOMMAND()
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      ON_BN_CLICKED
      (IDC_RECORD_FIRST, OnRecordFirst)
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      void CTestVC0Dlg::OnRecordFirst()
      {
      // TODO: Add your control notification handler code here

      }
    8. ClassWizard, Edit the Code - ( function OnRecordFirst).
    9. In the ClassWizard dialog box, select the Message Maps tab and in the Class Name box,
      select the class CTestVC0Dlg.
    10. In the Member Functions list, select the function name - OnRecordFirst:
      Choose Edit Code
      -or-
      Double-click the function name.
      The insertion point moves to the function in theTestVC0Dlg.cpp file. Edit the Text Code,
      examine these changes ...

      TestVC0Dlg.cpp file
      - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................


      void CTestVC0Dlg::OnRecordFirst()
      {

      m_pRS->MoveFirst();
      m_pRS->Move(2);
      CalculValue();
      SetButtons(TRUE);
      // TODO: Add your control notification handler code here

      }
  2. To make the navigation function, Previous :

    1. ClassWizard, Add the member function - ( object ID: IDC_RECORD_PREV).
    2. On the View menu, click ClassWizard.
      The MFC ClassWizard dialog box appears, click the Message Maps tab.
    3. In the Class name box, select the class CTestVC0Dlg.
    4. In the Object IDs list, select the IDC_RECORD_PREV.
    5. In the Messages list, select the BN_CLICKED.
    6. Click Add Function.
    7. The Add Member Function dialog box appears, click OK.
      To accept the default Member function name -
      OnRecordPrev display(or rename it) and then
      click OK.
      The new item message -
      OnRecordPrev ....... ON_IDC_RECORD_PREV:BN_CLICKED appearing in the Member functions list.
      ClassWizard makes changes to TestVC0Dlg.h and TestVC0Dlg.cpp files after you’ve
      added the member function. Examine these changes ...

      TestVC0Dlg.h file
      - the new Text Code is red.

      // TestVC0Dlg.h : header file
      //
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      // Generated message map functions
      //{{AFX_MSG(CTestVC0Dlg)
      virtual BOOL OnInitDialog();
      afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
      afx_msg void OnPaint();
      afx_msg HCURSOR OnQueryDragIcon();
      afx_msg void OnRecordFirst();
      afx_msg void OnRecordPrev();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
      ...................................................................................................................................................
      ...................................................................................................................................................

      ...


      TestVC0Dlg.cpp file - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      void CTestVC0Dlg::DoDataExchange(CDataExchange* pDX)
      {
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CTestVC0Dlg)
      DDX_Text(pDX, IDC_BOOK, m_book);
      DDX_Text(pDX, IDC_CHAPTER, m_chapter);
      DDX_Text(pDX, IDC_TITLE, m_title);
      DDX_Text(pDX, IDC_VERSE, m_verse);
      DDX_Text(pDX, IDC_TEXTDATA, m_textdata);
      //}}AFX_DATA_MAP
      }

      BEGIN_MESSAGE_MAP(CTestVC0Dlg, CDialog)
      //{{AFX_MSG_MAP(CTestVC0Dlg)
      ON_WM_SYSCOMMAND()
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      ON_BN_CLICKED(IDC_RECORD_FIRST, OnRecordFirst)
      ON_BN_CLICKED(IDC_RECORD_PREV, OnRecordPrev)
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      void CTestVC0Dlg::OnRecordPrev()
      {
      // TODO: Add your control notification handler code here

      }
    8. ClassWizard, Edit the Code - ( function OnRecordPrev).
    9. In the ClassWizard dialog box, select the Message Maps tab and in the Class Name box,
      select the class CTestVC0Dlg.
    10. In the Member Functions list, select the function name - OnRecordPrev:
      Choose Edit Code
      -or-
      Double-click the function name.
      The insertion point moves to the function in theTestVC0Dlg.cpp file. Edit the Text Code,
      examine these changes ...

      Note:
      SetButtonsAll procedure uses to enable or disable the navigation controls.

      TestVC0Dlg.cpp file
      - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      //To enable or disable the navigation controls - SetButtonsAll function
      void CTestVC0Dlg::SetButtonsAll(BOOL bVal)
      {
      GetDlgItem(IDC_RECORD_FIRST)->EnableWindow(bVal);
      GetDlgItem(IDC_RECORD_PREV)->EnableWindow(bVal);
      GetDlgItem(IDC_RECORD_NEXT)->EnableWindow(bVal);
      GetDlgItem(IDC_RECORD_LAST)->EnableWindow(bVal);
      }


      void CTestVC0Dlg::OnRecordFirst()
      {

      m_pRS->MoveFirst();
      m_pRS->Move(2);
      CalculValue();
      SetButtons(TRUE);

      // TODO: Add your control notification handler code here

      }

      void CTestVC0Dlg::OnRecordPrev()
      {

      m_pRS->MovePrev();
      CalculValue();

      if (m_pRS->GetRecordCount() > 0 && m_book == "01" && m_chapter == "001" & m_verse == "001")
      {
      SetButtons(TRUE);
      return;
      }
      else
      SetButtonsAll(TRUE);
      // TODO: Add your control notification handler code here

      }


      TestVC0Dlg.h file - the new Text Code is red.

      // TestVC0Dlg.h : header file
      //
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      // Generated message map functions
      //{{AFX_MSG(CTestVC0Dlg)
      virtual BOOL OnInitDialog();
      afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
      afx_msg void OnPaint();
      afx_msg HCURSOR OnQueryDragIcon();
      afx_msg void OnRecordFirst();
      afx_msg void OnRecordPrev();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
      void CalculValue();
      void SetButtons(BOOL bVal);
      void SetButtonsAll(BOOL bVal);
      ...................................................................................................................................................
      ...................................................................................................................................................

      ...
  3. To make the navigation function, Next :

    1. ClassWizard, Add the member function - ( object ID: IDC_RECORD_NEXT).
    2. On the View menu, click ClassWizard.
      The MFC ClassWizard dialog box appears, click the Message Maps tab.
    3. In the Class name box, select the class CTestVC0Dlg.
    4. In the Object IDs list, select the IDC_RECORD_NEXT.
    5. In the Messages list, select the BN_CLICKED.
    6. Click Add Function.
    7. The Add Member Function dialog box appears, click OK.
      To accept the default Member function name -
      OnRecordNext display(or rename it) and then
      click OK.
      The new item message -
      OnRecordNext....... ON_IDC_RECORD_NEXT:BN_CLICKED appearing in the Member functions list.
      ClassWizard makes changes to TestVC0Dlg.h and TestVC0Dlg.cpp files after you’ve
      added the member function. Examine these changes ...

      TestVC0Dlg.h file
      - the new Text Code is red.

      // TestVC0Dlg.h : header file
      //
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      // Generated message map functions
      //{{AFX_MSG(CTestVC0Dlg)
      virtual BOOL OnInitDialog();
      afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
      afx_msg void OnPaint();
      afx_msg HCURSOR OnQueryDragIcon();
      afx_msg void OnRecordFirst();
      afx_msg void OnRecordPrev();
      afx_msg void OnRecordNext();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
      ...................................................................................................................................................
      ...................................................................................................................................................

      ...


      TestVC0Dlg.cpp file - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      void CTestVC0Dlg::DoDataExchange(CDataExchange* pDX)
      {
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CTestVC0Dlg)
      DDX_Text(pDX, IDC_BOOK, m_book);
      DDX_Text(pDX, IDC_CHAPTER, m_chapter);
      DDX_Text(pDX, IDC_TITLE, m_title);
      DDX_Text(pDX, IDC_VERSE, m_verse);
      DDX_Text(pDX, IDC_TEXTDATA, m_textdata);
      //}}AFX_DATA_MAP
      }

      BEGIN_MESSAGE_MAP(CTestVC0Dlg, CDialog)
      //{{AFX_MSG_MAP(CTestVC0Dlg)
      ON_WM_SYSCOMMAND()
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      ON_BN_CLICKED(IDC_RECORD_FIRST, OnRecordFirst)
      ON_BN_CLICKED(IDC_RECORD_PREV, OnRecordPrev)
      ON_BN_CLICKED(IDC_RECORD_NEXT, OnRecordNext)
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      void CTestVC0Dlg::OnRecordNext()
      {
      // TODO: Add your control notification handler code here

      }
    8. ClassWizard, Edit the Code - ( function OnRecordNext).
    9. In the ClassWizard dialog box, select the Message Maps tab and in the Class Name box,
      select the class CTestVC0Dlg.
    10. In the Member Functions list, select the function name - OnRecordNext:
      Choose Edit Code
      -or-
      Double-click the function name.
      The insertion point moves to the function in theTestVC0Dlg.cpp file. Edit the Text Code,
      examine these changes ...

      TestVC0Dlg.cpp file
      - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................


      void CTestVC0Dlg::OnRecordNext()
      {

      m_pRS->MoveNext();
      CalculValue();

      if (m_pRS->GetRecordCount() > 0 && m_book == "66" && m_chapter == "022" & m_verse == "021")
      {
      SetButtons(FALSE);
      return;
      }
      else
      SetButtonsAll(TRUE);


      // TODO: Add your control notification handler code here

      }
  4. To make the navigation function, Last :

    1. ClassWizard, Add the member function - ( object ID: IDC_RECORD_LAST).
    2. On the View menu, click ClassWizard.
      The MFC ClassWizard dialog box appears, click the Message Maps tab.
    3. In the Class name box, select the class CTestVC0Dlg.
    4. In the Object IDs list, select the IDC_RECORD_LAST.
    5. In the Messages list, select the BN_CLICKED.
    6. Click Add Function.
    7. The Add Member Function dialog box appears, click OK.
      To accept the default Member function name -
      OnRecordLast display(or rename it) and then
      click OK.
      The new item message -
      OnRecordLast ....... ON_IDC_RECORD_LAST:BN_CLICKED appearing in the Member functions list.
      ClassWizard makes changes to TestVC0Dlg.h and TestVC0Dlg.cpp files after you’ve
      added the member function. Examine these changes ...

      TestVC0Dlg.h file
      - the new Text Code is red.

      // TestVC0Dlg.h : header file
      //
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      // Generated message map functions
      //{{AFX_MSG(CTestVC0Dlg)
      virtual BOOL OnInitDialog();
      afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
      afx_msg void OnPaint();
      afx_msg HCURSOR OnQueryDragIcon();
      afx_msg void OnRecordFirst();
      afx_msg void OnRecordPrev();
      afx_msg void OnRecordNext();
      afx_msg void OnRecordLast();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
      ...................................................................................................................................................
      ...................................................................................................................................................

      ...


      TestVC0Dlg.cpp file - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      void CTestVC0Dlg::DoDataExchange(CDataExchange* pDX)
      {
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CTestVC0Dlg)
      DDX_Text(pDX, IDC_BOOK, m_book);
      DDX_Text(pDX, IDC_CHAPTER, m_chapter);
      DDX_Text(pDX, IDC_TITLE, m_title);
      DDX_Text(pDX, IDC_VERSE, m_verse);
      DDX_Text(pDX, IDC_TEXTDATA, m_textdata);
      //}}AFX_DATA_MAP
      }

      BEGIN_MESSAGE_MAP(CTestVC0Dlg, CDialog)
      //{{AFX_MSG_MAP(CTestVC0Dlg)
      ON_WM_SYSCOMMAND()
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      ON_BN_CLICKED(IDC_RECORD_FIRST, OnRecordFirst)
      ON_BN_CLICKED(IDC_RECORD_PREV, OnRecordPrev)
      ON_BN_CLICKED(IDC_RECORD_NEXT, OnRecordNext)
      ON_BN_CLICKED(IDC_RECORD_FIRST, OnRecordLast)
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

      ...
      ...................................................................................................................................................
      ...................................................................................................................................................

      void CTestVC0Dlg::OnRecordLast()
      {
      // TODO: Add your control notification handler code here

      }
    8. ClassWizard, Edit the Code - ( function OnRecordLast).
    9. In the ClassWizard dialog box, select the Message Maps tab and in the Class Name box,
      select the class CTestVC0Dlg.
    10. In the Member Functions list, select the function name - OnRecordLast:
      Choose Edit Code
      -or-
      Double-click the function name.
      The insertion point moves to the function in theTestVC0Dlg.cpp file. Edit the Text Code,
      examine these changes ...

      TestVC0Dlg.cpp file
      - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"
      ...
      ...................................................................................................................................................
      ...................................................................................................................................................


      void CTestVC0Dlg::OnRecordLast()
      {

      m_pRS->MoveLast();
      CalculValue();
      SetButtons(FALSE);
      // TODO: Add your control notification handler code here

      }
Return to Main