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

  • Amazing

    Posted by Amir on 04/27/2014 03:10am

    I was searching for a console solution for port my app written in C++ in Linux to windows. This program is great but it does not work like a real console. for example print("\this is a text\n1\t2\t3") does not print this this is a text 1 2 3

    Reply
  • 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: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds