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

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

  • 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