Log Book Control

The CMMALogListBox class is a class for implementing a logbook in an application. The logbook can be used as a control (CMMALogListBox) or as a dialog which includes the control (CMMALogbookDlg). Using the CMMALogbookDlg class is very simple to use instead of the control himself. The logbook file will be automatically created. Here are some feature of my logbook :

  • Multilines
  • Colors
  • Fonts
  • Printing

Using the CMMALogListBox Class

To use CMMALogListBox class, you must do the following: 1. In the dialog resource, add a listbox (IDLB_LOGBOOK) and set the LVS_OWNERDRAWVARIABLE and LVS_SORT flags. And don't set the LVS_HASSTRING flag. 2. Add in the dialog message handler these lines (the dialog were you use the control) :
if (message == WM_DRAWITEM 
&& (UINT)wParam == IDLB_LOGBOOK)
{
 MMALogListBoxWndProc_DrawItem((LPDRAWITEMSTRUCT)lParam);
 return TRUE;
}

if (message == WM_MEASUREITEM 
&& if (UINT)wParam == IDLB_LOGBOOK)
{
 MMALogListBoxWndProc_MeasureItem((LPMEASUREITEMSTRUCT)lParam);
 return TRUE;
}
3. Add a membre variable to the dialog like this :
CMMALogListBox m_cMMALogListBox;
4. In the WM_INITDIALOG message, call the attach function on the control class :
m_cMMALogListBox.Attach(GetDlgItem(hDlg,IDLB_LOGBOOK), 
 "LOGBOOK.LOG", MAXLINES, TRUE);
You can peer through the source code to see how to implement the CMMALogListBox class.

Using the CMMALogbookDlg class

For using CMMALogbookDlg class, you must do this : 1. Add a variable :
CMMALogbookDlg cMMALogbookDlg;
2. Create the logbook dialog box and show it :
cMMALogbookDlg.CreateLogbookDlg(AfxGetInstanceHandle(), 
 NULL, "LOGBOOK.LOG", MAXLINES)

cMMALogbookDlg.Show(TRUE);
3. After using the logbook dialog, you must destroy it :
cMMALogbookDlg.DestroyLogbookDlg();
You can peer through the source code to see how to implement the CMMALogbookDlg class.

Downloads

Download demo project - 90 Kb
Download source - 17 Kb


Comments

  • Working project.

    Posted by Legacy on 04/09/2001 12:00am

    Originally posted by: Luis E. Cabrera

    Could you send us a working copy of the project for the Log Box control? I have not been able to make the old one run...even after deleting the Debug.h files...

    Are you sure you want windows.h in the Stdafx.h???

    thanks a lot.

    Luis Cabrera

    Reply
  • how about "Using the CMMALogListBox Class Num.2 ?"

    Posted by Legacy on 01/28/2001 12:00am

    Originally posted by: Hoseok Jeon

    Hello!
    My program is MFC Dialog Base.
    I want to konw "The where and the why of it".
    good bye!

    Reply
  • How to change LogFile within same application

    Posted by Legacy on 01/15/2001 12:00am

    Originally posted by: Neven Gross

    Hi
    
    

    I have application which manages logs on daily basis.
    It means, I have separate log for each day. In manage logs
    dialog, calendar control is used for log selection (to be
    able to review logs from previous days.

    Here is program part I use to select file:

    void CLogArchive::OnSelectMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult)
    {
    // TODO: Add your control notification handler code here
    m_cEventLogAr.DestroyLogbookDlg();
    m_cAlarmLogAr.DestroyLogbookDlg();
    m_cEventLogAr.Clear();
    m_cAlarmLogAr.Clear();
    SYSTEMTIME ct;
    m_SelectedDate.GetCurSel(&ct);
    COleDateTime LogDate(ct.wYear, ct.wMonth, ct.wDay, 0, 0, 0);
    CString sLogFileE;
    CString sLogFileA;
    sLogFileE.Format("Logs\\ISO8583E.%04d%02d%02d",LogDate.GetYear(), LogDate.GetMonth(), LogDate.GetDay());
    sLogFileA.Format("Logs\\ISO8583A.%04d%02d%02d",LogDate.GetYear(), LogDate.GetMonth(), LogDate.GetDay());
    CFile fCheck;
    if(fCheck.Open(sLogFileE, CFile::modeRead))
    {
    fCheck.Close();
    m_Title.Format("Selected Log Date : %02d.%02d.%04d",LogDate.GetDay(), LogDate.GetMonth(), LogDate.GetYear());
    UpdateData(FALSE);
    BeginWaitCursor();
    m_cEventLogAr.CreateLogbookDlg(AfxGetInstanceHandle(), NULL, sLogFileE, MAXLEVENT);
    m_cAlarmLogAr.CreateLogbookDlg(AfxGetInstanceHandle(), NULL, sLogFileA, MAXLALARM);
    CString sLogTitle;
    sLogTitle.Format("Event Log Report on : %02d.%02d.%04d",LogDate.GetDay(), LogDate.GetMonth(), LogDate.GetYear());
    m_cEventLogAr.SetTitle(sLogTitle);
    sLogTitle.Format("Alarm Log Report on : %02d.%02d.%04d",LogDate.GetDay(), LogDate.GetMonth(), LogDate.GetYear());
    m_cAlarmLogAr.SetTitle(sLogTitle);
    m_bEventLogView.EnableWindow(TRUE);
    m_bEventLogSetup.EnableWindow(TRUE);
    m_bEventLogPrint.EnableWindow(TRUE);
    m_bAlarmLogView.EnableWindow(TRUE);
    m_bAlarmLogSetup.EnableWindow(TRUE);
    m_bAlarmLogPrint.EnableWindow(TRUE);
    EndWaitCursor();
    }
    else
    {
    MessageBox("Log File does not Exist for Selected Date !","ISO8583 Interface", MB_OK | MB_ICONERROR);
    m_bEventLogView.EnableWindow(FALSE);
    m_bEventLogSetup.EnableWindow(FALSE);
    m_bEventLogPrint.EnableWindow(FALSE);
    m_bAlarmLogView.EnableWindow(FALSE);
    m_bAlarmLogSetup.EnableWindow(FALSE);
    m_bAlarmLogPrint.EnableWindow(FALSE);
    m_Title = "Selected Log Date : N/A";
    UpdateData(FALSE);
    }
    *pResult = 0;
    }

    After date change when m_cEventLogAr.Show() is executed, only first ever log is shown regardless of date selected.
    Am I missing something here?

    Thanks

    Neven Gross

    Reply
  • doesn't build (missing files), supplied .exe doesn't work

    Posted by Legacy on 04/05/2000 12:00am

    Originally posted by: Rick Shide

    Your project does not build. There is no "API\Debug.h" include file, your projext also contains a file "..\CommonSource\API\Debug.cpp", which is also not included. BTW, there is no way to extract "../" from a zip file.

    The supplied release .exe only shows one column (date/time).

    Reply
  • Some questions

    Posted by Legacy on 02/11/2000 12:00am

    Originally posted by: Neven Gross

    Thanks for great LogBook.

    I have included source files in my project.
    Created mem variable from MMALogbookDlg class.
    Called create method.
    At end called destroy method.
    When program is started in debug mode at end in trace win
    memory leak detected. This started to happen after inclusion.
    Am I doing something wrong?

    in TestDlg.h:

    CMMALogbookDlg m_cAlarmLog;
    CMMALogbookDlg m_cEventLog;

    ------------------------------------------------------------

    in TestDlg.cpp:

    OnInitDialog:
    m_cEventLog.CreateLogbookDlg(AfxGetInstanceHandle(), NULL, "ISO8583E.LOG", MAXLEVENT);
    m_cAlarmLog.CreateLogbookDlg(AfxGetInstanceHandle(), NULL, "ISO8583A.LOG", MAXLALARM);
    m_cEventLog.AddLogLine("Program Started", LOGLB_INFO);

    OnbClose:
    m_cEventLog.DestroyLogbookDlg();
    m_cAlarmLog.DestroyLogbookDlg();

    ------------------------------------------------------------

    Trace win:Detected memory leaks!
    Dumping objects ->
    {3082} normal block at 0x00ADF930, 720 bytes long.
    Data: < > 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    {79} normal block at 0x00781260, 720 bytes long.
    Data: < > 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Object dump complete.

    ------------------------------------------------------------
    And some more Q.

    I dont get what is SetFileName method for.
    Can I use existing logbook instead of calling create every time on program init?

    Thansk again.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • On-demand Event Event Date: December 18, 2014 The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this webcast and join industry experts as …

Most Popular Programming Stories

More for Developers

RSS Feeds