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,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

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read