DOS Text Screen in Dialog
Posted
by Eletskikh Yuri
on January 30th, 2002

The CMonitor control is a lightweight class suitable for displaying dos text screen in Dialog
- Include Cmonitor1.h in your dialog class' header file.
- Add member variables of type CMonitor control you want to subclass.
- 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:00amOriginally 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.
ReplyWonderfull - ignore the idiots
Posted by Legacy on 05/02/2002 12:00amOriginally 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:00amOriginally 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:00amOriginally posted by: Spy
i'm sorry.........
Reply
Interesting but...
Posted by Legacy on 01/31/2002 12:00amOriginally posted by: Pedro
Interesting, but what use for this...?
Reply