Click here to Skip to main content
15,896,111 members
Articles / Desktop Programming / MFC
Article

Text-only Blackboard control

Rate me:
Please Sign up or sign in to vote.
3.67/5 (11 votes)
14 Oct 2003 60.9K   1.1K   18   2
Text-only Blackboard control for MFC

Image 1

Introduction

This is a simple control which really helped me when I needed to debug the code with no debug info on the binary (Linked as Release mode). We can actually use List Control or something similar but we have to spend more time on its properties like font. This control (I hope) will simplify our task on debugging or displaying some progress in our code.

How to use

There are few steps to use this control:

  • Include two files, TextDispCtrl.h and TextDispCtrl.cpp in your project
  • Create a Picture box (Frame) in your form/dialog
  • Change its ID to whatever you want
  • Include TextDispCtrl.h in the class declaration of your form/dialog
  • Put this in your dialog/form class:
    CTextDispCtrl    m_wndx;
  • Initialize the control, usually within OnInitDialog() in dialog or OnInitialUpdate() in form:
    CRect rect;
    GetDlgItem(IDC_STATIC_OF_YOUR_PICTURE_BOX)->GetWindowRect(rect);
    ScreenToClient(rect);
    if( !m_wndx.Create(WS_VISIBLE | WS_CHILD | WS_TABSTOP, rect, this, 1000) )
        AfxMessageBox("Hmmm...");
    
    // Set the font
    m_wndx.SetFont("Terminal", 100); // Any "monospace" font would be fine
    
    // Just in case the size of your Picture control smaller than your data
    // or you choose HUGE font ;-)
    m_wndx.SetDumpWidth(14);
  • Call the following method to display strings:
    m_wndx.ShowString("Bla..bla...bla...");
    m_wndx.ShowString(""); // Add blank line
  • Or this function to Hex Dump your buffer:
    m_wndx.DumpData(pszBuffer, iBufLen);

Conclusion

This class will be useful for projects which needs no fancy appearance but developed just for functionality and display the progress as simple as possible. That's all for now! Cheers!

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
Web Developer
Indonesia Indonesia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHey! Where's the scrollbar??? Pin
AndrewSmirnov22-Oct-03 3:15
AndrewSmirnov22-Oct-03 3:15 
GeneralA handy little tool indeed !! Pin
WREY16-Oct-03 12:39
WREY16-Oct-03 12:39 
Thanks for this wonderful little tool. I can see many uses for it not just for debugging and memory dumping purposes, but (with some modifications, can be used) for dynamically changing string, array, integer (etc.) values while the program is running (which in a sense can now be done in VC++ debugging mode). But what makes this sample useful in its own right, is that the user does not have to go into Debugging mode to do these things. It can be interactively accomplished right from the program that's using it, as part of the program's own functionality.

I am also thinking of other uses that WOULD NOT require recompiling the program as a result for using it. (Perhaps, as one becomes more accustomed to working with it, more ideas will surface for other purposes.)

Good job, and thanks for sharing it with us.

Cool | :cool:

William

Fortes in fide et opere!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.