Click here to Skip to main content
15,885,899 members
Articles / Desktop Programming / MFC

A Logging Listbox Control

Rate me:
Please Sign up or sign in to vote.
4.80/5 (9 votes)
16 May 2000 176.4K   3K   85  
Learn how to use printf-like functionality to debug your GUI applications.
#if !defined(AFX_LOGFRAME_H__319C7EF0_D94C_11D3_9FE9_006067718D04__INCLUDED_)
#define AFX_LOGFRAME_H__319C7EF0_D94C_11D3_9FE9_006067718D04__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// LogFrame.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CLogFrame frame

class TraceEvent;

class CLogFrame : public CMDIChildWnd
{
	DECLARE_DYNCREATE(CLogFrame)
protected:
	CLogFrame();           // protected constructor used by dynamic creation

// Attributes
public:

// Operations
public:
        int AddString(TraceEvent *);
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CLogFrame)
	protected:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CLogFrame();

	// Generated message map functions
	//{{AFX_MSG(CLogFrame)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

class CLogger {
    public:
       // This is the only member that is normally used
       int AddString(TraceEvent * event);
    public: // Constructors
       CLogger() { frame = NULL; }
       virtual ~CLogger() {}

    public:
       // These methods are useful during creation
       BOOL IsValid() { return frame != NULL && ::IsWindow(frame->m_hWnd); }
       void MDIActivate() {if(IsValid()) frame->MDIActivate(); }
       BOOL IsIconic()    {if(IsValid()) return frame->IsIconic(); else return FALSE; }
       void ShowWindow(UINT show) { if(IsValid()) frame->ShowWindow(show); }
       void SetLogger(CLogFrame * f) { frame = f; }
    protected:
       CLogFrame * frame;
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_LOGFRAME_H__319C7EF0_D94C_11D3_9FE9_006067718D04__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Retired
United States United States
PhD, Computer Science, Carnegie Mellon University, 1975
Certificate in Forensic Science and the Law, Duquesne University, 2008

Co-Author, [i]Win32 Programming[/i]

Comments and Discussions