Click here to Skip to main content
15,919,132 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: When ControlSize exceeds parent size Pin
PJ Arends24-Nov-05 10:24
professionalPJ Arends24-Nov-05 10:24 
GeneralRe: When ControlSize exceeds parent size Pin
Pazzuzu24-Nov-05 21:10
Pazzuzu24-Nov-05 21:10 
GeneralRe: When ControlSize exceeds parent size Pin
Pazzuzu25-Nov-05 4:34
Pazzuzu25-Nov-05 4:34 
Questionkilling thread Pin
Boder Coder24-Nov-05 3:44
Boder Coder24-Nov-05 3:44 
AnswerRe: killing thread Pin
toxcct24-Nov-05 4:19
toxcct24-Nov-05 4:19 
AnswerRe: killing thread Pin
Owner drawn24-Nov-05 20:28
Owner drawn24-Nov-05 20:28 
AnswerRe: killing thread Pin
ThatsAlok27-Nov-05 18:19
ThatsAlok27-Nov-05 18:19 
QuestionOutput to printer in Managed C++ Console Pin
Simon Cornish24-Nov-05 3:18
Simon Cornish24-Nov-05 3:18 
Hi all

I've been teaching C++ for about 10 years (unmanaged using Borland Compilers), and for the first time this year I am teaching managed C++ using MS Visual Studio .NET. The first part of the course concentrates on procedural programming in a console environment, and one of the topics is writing / reading to text files (which is OK), and printing data to a printer (local LPT1 printer). In unmanaged code, I would write is as follows :

#include <fstream.h>

void main(void)
{
char data[80];
ifstream infile;
ofstream printer;
infile.open("TEST.TXT", ios::in);
printer.open("PRN");

while (infile)
{
infile.getline(data,80);
if (infile)
{
printer << data << "\n";
}
}
};

However, I cant find a simple way to set up a stream to the local printer in a console based environment using managed code. The file handling part is fine, and would look as follows :

// Filein1.cpp

#include "stdafx.h"
#using <mscorlib.dll>

using namespace System;
using namespace System::IO;

int _tmain()
{
String *record;
StreamReader * fileIn = File::OpenText(S"Test.txt");
// Need to set up stream to printer here

while ((record = fileIn->ReadLine()) != 0)
{
Console::WriteLine(S"{0}",record); // need to replace with output to printer stream
}

Console::ReadLine();
fileIn->Close();
return 0;
}

Can anyone help me fill in the gaps ?

Many thanks




Simon Cornish
AnswerRe: Output to printer in Managed C++ Console Pin
toxcct24-Nov-05 4:20
toxcct24-Nov-05 4:20 
QuestionBitmap Image on Status Bar Pin
romuzu24-Nov-05 2:31
romuzu24-Nov-05 2:31 
QuestionCAnimateCtrl (MFC) Pin
Kevin Gutteridge24-Nov-05 2:31
Kevin Gutteridge24-Nov-05 2:31 
AnswerRe: CAnimateCtrl (MFC) Pin
PJ Arends24-Nov-05 10:17
professionalPJ Arends24-Nov-05 10:17 
QuestionAlpha blended tooltips Pin
siphiuel24-Nov-05 2:14
siphiuel24-Nov-05 2:14 
QuestionCustom Shell Dll loaded from USB CDROM not allowing to stop the device from Tray Pin
Rajagovarthanan24-Nov-05 2:02
Rajagovarthanan24-Nov-05 2:02 
Questionhow to develop a chat application using c++ Pin
ieza24-Nov-05 1:46
ieza24-Nov-05 1:46 
QuestionHow can I add Text to an bmp file? Pin
ItziarH24-Nov-05 1:25
ItziarH24-Nov-05 1:25 
AnswerRe: How can I add Text to an bmp file? Pin
Jagadeesh VN24-Nov-05 1:29
Jagadeesh VN24-Nov-05 1:29 
GeneralRe: How can I add Text to an bmp file? Pin
ItziarH24-Nov-05 1:49
ItziarH24-Nov-05 1:49 
GeneralRe: How can I add Text to an bmp file? Pin
Jagadeesh VN24-Nov-05 1:53
Jagadeesh VN24-Nov-05 1:53 
GeneralRe: How can I add Text to an bmp file? Pin
ItziarH29-Nov-05 3:16
ItziarH29-Nov-05 3:16 
QuestionCheck existing folder Pin
Cedric Moonen24-Nov-05 1:22
Cedric Moonen24-Nov-05 1:22 
AnswerRe: Check existing folder Pin
kakan24-Nov-05 1:24
professionalkakan24-Nov-05 1:24 
GeneralRe: Check existing folder Pin
Cedric Moonen24-Nov-05 1:42
Cedric Moonen24-Nov-05 1:42 
AnswerRe: Check existing folder Pin
Jagadeesh VN24-Nov-05 1:26
Jagadeesh VN24-Nov-05 1:26 
AnswerRe: Check existing folder Pin
Cool Ju24-Nov-05 18:27
Cool Ju24-Nov-05 18:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.