|
Did you install the registry keys for the controls?
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
Hello,
I have written a C++ program. I have compiled,built and executed the program. It works fine. I want to be able to send the output on the screen to a printer. How can I nclude this option. Can I use MFC? In other words how do I display my program on a page that contains the options for print view, print,save etc.
Thank You
|
|
|
|
|
Have you considered:
FILE *pOutput = fopen("LPT1:", "w");
fprintf(pOutput , ...);
fclose(pOutput);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
First off I have seen you post this at least 4 times. Yet, everyone who responds seems to be thinking like a rocket scientest. For anyone who reads this, all he wants to do is provide printing options for his program. i.e. File ... Print. It's a simple concept.
From what I've read over the last week or so, he has a console application that does a bunch of stuff and displays it on the screen in the console. All that he wants to do is print what's in the console. So anyone that knows a simple way of printing from the console, post it, so we don't have to continue reading the same post.
Brimid, I told you before, go to the printing section of this site and read some of the articles. I'll even point a few out to you in a few mins. I don't know what to tell you about using MFC, because its not something you can just jump right into and understand. It takes time. But I'll go find a few articles for you to look at anyway.
|
|
|
|
|
|
#include <fstream>
int main(int, char*)
{
ofstream Printer ("lpt1:");
Printer << "Test" << endl;
return 0;
}
Works if the printer is connected to your parallel port, not sure about USB printers.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Hi all,
I got a really weird problem when I tried to use RemoveAt() function to remove elements from a CArray.
I have two parallel arrays called carrURL (a CString array) and carrHit (an int array). What I want to do is:
If an element in carrURL has duplicated elements, then add its corresponding values from carrHit together and then remove these duplicated elements from carrURL. If an element is unique in the array, just keep it and go next.
For example: suppose carrURL[0], carrURL[4], carrURL [100] are the same string, add the values of carrHit[4], carrHit[100] to carrURL[0] and remove carrURL[4] and carrURL[100] (also remove carrHit[4] and carrHit[100]).
The code is below:
for (int nIndex = 0; nIndex < carrURL.GetSize(); nIndex++){
for (int ncItem = nIndex + 1; ncItem < carrURL.GetSize(); ncItem++){
if (carrURL[ncItem].Compare(carrURL[nIndex]) == 0){
carrHit[nIndex] += carrHit[ncItem];
carrHit.RemoveAt(ncItem);
carrURL.RemoveAt(ncItem);
}
}
carrHit.FreeExtra(); // free extra memory
carrURL.FreeExtra(); // free extra memory
}
However, the result is not what I supposed. It shows something like that:
carrURL carrHit
a 500 -- good
b 333 -- good
c 450 -- weird!
c 61 -- weird!
d 11 -- good
e 10 -- good
c 1 -- weird!
I can't understand why there are still some duplicated values which can not be found out after running a proper loop.
Any suggestions?
Thanks a lot!
|
|
|
|
|
Each time you call RemoveAt() the size of the array reduces by 1. GetSize() may therefore not give you the result you expect!
A better way would be to replace the elements to be removed with "special" values (like empty strings and -1, for example), then remove those elements in a 2nd loop.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks ravi. I was thinking of trying the similar stuff as your suggested if I don't have any idea to fix my original algorithm. but now I fixed it! :p
|
|
|
|
|
|
try removing items from the end of the array instead of the start.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks anyway
|
|
|
|
|
Only increment nIndex if the compare fails. With your logic, say you have 5 items
A
B
C
D
E
if nIndex is 2, carrURL[nIndex] is 'C'. If you remove this, the array looks lke
A
B
D
E
and then the for loop increments nIndex to 3.
carrURL[nIndex] is now 'E'.
You've missed 'D' completely.
|
|
|
|
|
Thx very much Graham, as you said, I just skipped 1 value each time.
|
|
|
|
|
Hi,
I would like to ask that;
#include "stdafx.h"<br />
#include <iostream><br />
<br />
int _tmain()<br />
{<br />
int myInts[3] = {0,1,2};<br />
char * myName = "sarp";<br />
<br />
std::cout << myName << std::endl;<br />
std::cout << myInts << std::endl;<br />
<br />
return 0;<br />
}
Why it prints out sarp in first output and memory location in second output? I was waiting for memory location of s in the first one.
Also, what is the difference between;
char * myName = "sarp";<br />
char myName[] = "sarp";
Thanks,
Sarp
-
When in doubt, push a pawn!
-
|
|
|
|
|
cout must have an overloaded method to output char*, and nothing to output int* ( except for the adress ).
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
kromozom wrote:
Why it prints out...memory location in second output?
What would you expect it to print out?
kromozom wrote:
I was waiting for memory location of s in the first one.
Then you should use cout << &myName << endl; instead.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
well.....for thiz iz for ur info.....
whenu declare the variable say.....
char a[10];
here the variable "a" is bacially like a pointer,it terminates only when it "sees" the "\O"
thatz why u dont get the same answer.....
if want just one letter to come do like thiz.....
cout<<*(myname);
if u want the second letter.....
cout<<*(myname+1)
and so on.....
hope that helpz.....
happy programmin.....
cheerz.....
|
|
|
|
|
Thanks all, I have cleared some of my confused knowledge...
-
When in doubt, push a pawn!
-
|
|
|
|
|
I am using CScrollView to handle scrolling. The only thing I did so far with ScrollView is setscrollsize and that's it.
Why is that when I have long document open and I drag the scroll bar scrolling my scroll bar would jump right back to the to the top/begining as soon I release my mouse button? Mouse click jump to location, click on scroll arrows up and down, or mouse wheel they all scroll fine.
|
|
|
|
|
I test it out by shrinking the document. It seems to occur when the document goes over 1850 lines.
|
|
|
|
|
I have written a program C++. I want to be able to give the user an option to print or print preview the putput or exe file. Are there any tutorials that explain how to create a page like this in MFC. I have a little idea but do not know how to enter my C++ code into the MFC template in order to create the complete program.
Thank You all for all of your assistance.
|
|
|
|
|
REPOST !
and i'm not sure you want to print "exe files"... do you know what is exe files ?
do you already opened a compiled file into a WYSIWYG editor (like notepad, ultraedit...) ???
TOXCCT >>> GEII power [VisualCalc][toxcct]
|
|
|
|
|
The exe file is what I get after I compile and build my program. I run it and out comes an exe file. The program perfroms exactly how I want it to. Now I want to be able to take my code and enter it into MFC so I will have a more functional program that give the user the option to print out the results. With the exe you can only view it. Of course they could maybe cut and paste but that is not to professional.
Thank You
|
|
|
|
|
so, you have an executable (A) that when run will extract/generate another executable (B) ?
and when you run B, you want it to be able to print what it displays ?
if so, you need to reprogram B to handle the print process.
Am I understanding corretly your situation ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|