DOS Text Screen in Dialog

, Russia Lipetsk

The CMonitor control is a lightweight class suitable for displaying dos text screen in Dialog

  1. Include Cmonitor1.h in your dialog class' header file.
  2. Add member variables of type CMonitor control you want to subclass.
  3. Subclass the static controls in your dialog's OnInitDialog() method and use.

Example

   m_monitor.SubclassDlgItem(IDC_STATIC,this);
   m_monitor.Fill(0,0,0xB1,0x20,40*20);
   m_monitor.Window(5,5,30,10,0x71);
   m_monitor.Print(5,14," Window 1 ",0xF1);
   m_monitor.Window(6,7,30,8,0x71);
   m_monitor.Print(6,17," Window 2 ",0xA1);

In my demo Font include Russian symbol. Code page 866.

If you want change font you need change variable short DosCode; this array contains font information. See Source for more.

The following sample shows how you can make a font array:

// Compile with Borland C++ 3.11
#include <graphics.h>
#include <conio.h>
#include <iostream.h>
#include <stdio.h>

unsigned char mass[12];

void GetCharAt()
{
  int i,j,bit,tmp,p;

  for(i=0;i<12;i++)
  {
    bit = 0;
    printf("\n");
    for(j=0;j<8;j++)
    {
      p = getpixel(j,i+1);

      if(p==7)
      {
        tmp = 1;
        tmp=tmp<<j;
        bit+=tmp;
      }

      printf("%d ",p);
    }
    mass[i] = (char)bit;
    printf("%d ",mass[i]);
  }
}


int main()
{
  int driver, mode;
  unsigned i,j,x,y,p,bit,tmp;
  char ch=0;
  FILE *fp;

  driver=DETECT;
  initgraph(&driver,&mode,"");

  fp = fopen("out.h","w");

  if(fp)
  { 
    for(i=0;i<255;i++)
    {
      gotoxy(1,1);
      printf("%c",ch);
      GetCharAt();

      if(i>31)fprintf(fp,"/*'%c'*/ ",ch);
      else fprintf(fp,"/*%X*/ ",ch);

      for(j=0;j<12;j++)
      {
        fprintf(fp,"%d, ",mass[j]);
      }

      fprintf(fp,"\n");

      ch++;
    }

    fclose(fp);
  }

  closegraph();

  return 0;
}

Downloads

Demo project source: Text screen in dialog demo.zip 33 Kb



Comments

  • Great, but...

    Posted by Legacy on 11/22/2002 12:00am

    Originally posted by: Philippe Laugier

    I searching for such program for a long time.
    Your code is really great, but...

    I want to use it as a console, thus I run CMD.EXE
    From this console, running a program that ask for an argument before executing some task is not working:
    Nothing is displayed.
    Being a little bit lazy, before searching myself for a solution, I wonder if you don't already have it.

    Example of problem:
    Imagine a program being an assembler:
    Running it ask for a source file name, then a listing file name and finally assemble the file.

    Knowing what it needs, I can type in two names and it works, but I do not see its requests.

    Reply
  • Wonderfull - ignore the idiots

    Posted by Legacy on 05/02/2002 12:00am

    Originally posted by: trent

    Thanks for the code - it's great!

    Please ignore the ignorant idiots.

    Reply
  • Plenty of uses...

    Posted by Legacy on 02/05/2002 12:00am

    Originally posted by: JamesP


    In my last job I wrote a command interpreter/programming language for an NT based HiDef video server.

    It was console based, but extensible, allowing for curses style console manipulation (with the right module) as well as Windows SDK calls.

    The company wanted an IDE for it (like VC++), but wanted to retain its immediate command interpreter mode (for simple calls and queries) and use of all modules (including the console manipulation ones).

    I hunted around for ages for a DOS style Command Interpreter Window class that I could use in the IDE. There wasn't one, and I didn't have time to write my own.

    Reply
  • @_@What is it for?

    Posted by Legacy on 02/01/2002 12:00am

    Originally posted by: Spy

    i'm sorry.........

    Reply
  • Interesting but...

    Posted by Legacy on 01/31/2002 12:00am

    Originally posted by: Pedro

    Interesting, but what use for this...?

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

Top White Papers and Webcasts

  • When it comes to desktops – physical or virtual – it's all about the applications. Cloud-hosted virtual desktops are growing fast because you get local data center-class security and 24x7 access with the complete personalization and flexibility of your own desktop. Organizations make five common mistakes when it comes to planning and implementing their application management strategy. This eBook tells you what they are and how to avoid them, and offers real-life case studies on customers who didn't …

  • The impact of a data loss event can be significant. Real-time data is essential to remaining competitive. Many companies can no longer afford to rely on a truck arriving each day to take backup tapes offsite. For most companies, a cloud backup and recovery solution will eliminate, or significantly reduce, IT resources related to the mundane task of backup and allow your resources to be redeployed to more strategic projects. The cloud - can now be comfortable for you – with 100% recovery from anywhere all …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds