DOS Text Screen in Dialog | CodeGuru

DOS Text Screen in Dialog

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

Written By
CodeGuru Staff
CodeGuru Staff
Jan 30, 2002
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

, 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,0×71);
   m_monitor.Print(5,14," Window 1 ",0xF1);
   m_monitor.Window(6,7,30,8,0×71);
   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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.