Log Book Control
Posted
by Mike Marquet
on February 1st, 2000

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 KbDownload source - 17 Kb

Comments
Working project.
Posted by Legacy on 04/09/2001 12:00amOriginally 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
Replyhow about "Using the CMMALogListBox Class Num.2 ?"
Posted by Legacy on 01/28/2001 12:00amOriginally posted by: Hoseok Jeon
Hello!
ReplyMy program is MFC Dialog Base.
I want to konw "The where and the why of it".
good bye!
How to change LogFile within same application
Posted by Legacy on 01/15/2001 12:00amOriginally posted by: Neven Gross
Replydoesn't build (missing files), supplied .exe doesn't work
Posted by Legacy on 04/05/2000 12:00amOriginally 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).
ReplySome questions
Posted by Legacy on 02/11/2000 12:00amOriginally 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