|
I'm not sure I understand the context of the question either. In a sense, yes a file is a bit stream. It's just data. You don't have to convert a file to a bit stream you simply have to use a tool to get the data out of the file and into a file stream in your program so that you can read the data.
Binary mode; sounds like you might be referring to the CStdioFile which is an MFC class. This class inherits from CFile which is used for binary files. CStdioFile allows you to specify binary or text mode and has some extra functions that make reading lines of text very easy. The MFC documentation is fairly clear on how this works; it's just a matter of reading the class documentation in the MSDN library. Of course, there are the basic C++ file streams that can be used to read files and stream data into your program. These are just STL classes which you can learn about in most basic C++ books.
I guess I don't know if I really answered the original question since it was rather vague. We don't really know what is going to be done with the file so all I can say is that streaming data into the program from a file or vice versa is done with file streams or an MFC framework class such as CFile or CStdioFile. A file is just a stream of bits waiting to be processed. You don't have to convert it to do this; you just do it with an existing programming tool and stream the data into your program.
Best Regards,
Shawn
|
|
|
|
|
All files are just a series a bytes stored on disk. There is no conversion needed. The only differnce is which program or piece of code you try to open them with. You can open a .exe file with note pad if you want, of course it will look very strange, but it is not text is it.
INTP
|
|
|
|
|
Hi guys
There is an easy way to create a PDF instead to print programatically?
Best Regads
DOC
|
|
|
|
|
There is no 'easy' way, but there are a multitude of PDF programming APIs, such as TallPDF. These allow you to easily create PDF output files from C++ programs. Naturally, they are commercial and probably none is freeware.
The cheapest way is to invest to Adobe PDF Writer and then print documents directly into PDF format. This software acts as a print-to-file application that outputs PDF files.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks Antii
I suposed (((
I'll investigate more
Doc
|
|
|
|
|
There are freeware PDF writers, though I don't know all the details. I've never needed one myself. linux has a number of different ones.
http://printing.kde.org/ for instance references one, but I'm not sure what the details are. I think it coverets postscript to PDF. (since PDF is basicly a more complex postscript or something like that, this is really easy) source code exists for your reference.
PDF is an open specification, so in theory you could write your own. Most of us don't wish to spend that much time (years most likley).
|
|
|
|
|
hi,
i got a 2 CFormView classes attached to one CDocument (with member variable myVar).
i open the first CFormView, in onInitialUpdate() do GetDocument() and change myVar to 1;
i open the second CFormView, in onInitialUpdate() do GetDocument() and get myVar,
but then i see that myVar is not 1. like i didnt got the doc i wanted.
is my assumption is wrong, and if so what can i do to fix it?
|
|
|
|
|
You are using GetDocument correctly, but you are misunderstanding the concepts of how object-oriented C++ and MFC work. To fill in this gap, consider this example:
You have a class called CDocument , that represents the layout (design) of a document class. When you use the new operator or declare an object on the stack, an instance of the class is created. All standard data members of this class belong to this very instance. If you declare a new instance of the class, the new instance will have it's own data members.
What is happening in your code is that you have two CFormView classes which use the same CDocument class. But, when the CFormView objects are created, they both create seperate instances of the CDocument class. This means that though you have told both form views to use the same document class, the actual document objects created from these classes are different objects, both with their own variables. Changing one variable does not change the other one. In short, the form views do not share the document object: both views haver their own instance of the document.
However, there is an option to achieve what you desire in C++. It is called the static keyword. Determine the variable myVar as static in the class declaration. Now, each instance of the CDocument class will share the variable. Here is a code example to clarify:
#include <iostream>
using namespace std;<DIV>
class CDoc
{
public:
CDoc() {}
~CDoc() {}<DIV>
public:
static int nIndex;
};<DIV>
int CDoc::nIndex;<DIV>
int main(void)
{
CDoc* ptrDoc1 = new CDoc();
ptrDoc1->nIndex = 2;<DIV>
cout << "The contents of the static variable is " << ptrDoc1->nIndex << endl;<DIV>
CDoc* ptrDoc2 = new CDoc();
ptrDoc2->nIndex = 60;<DIV>
cout << "The static variable was altered and became " << ptrDoc1->nIndex << endl;<DIV>
delete ptrDoc1; ptrDoc1 = NULL;
delete ptrDoc2; ptrDoc2 = NULL;<DIV>
return 0;
}<DIV>
The output is:
The contents of the static variable is 2
The static variable was altered and became 60 I hope this will clarify the idea.
Additionally, The MFC Framework offers it's very own style to implement the idea 'multiple views for a single document'. You should follow the example set forth in this MSDN link to implement similar functionality. Actually, I suggest you follow only the MSDN example, as I am not perfectly sure the static variable approach would work in MFC. But hopefully the huge code paste was useful
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
your reply was very helpfull!!!
thanks very much!
|
|
|
|
|
Hi.
I am trying to create an autofill program.
This is similar to what the google toolbar does. it looks at the name of the controls, and puts some values accordingly.
The difference is that i am not creating a toolbar. I am using a CHTMLView. So the page is showing inside my program.
I don't know how to access the controls in order to fill them.
Could you please help..
Thank you very much in advance
|
|
|
|
|
Internet Explorer is all COM objects so you have to learn the COM interfaces to accomplish that. What you are interested in is the DHTML interface to the Document Object.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Many thanks for the quick reply.
Could you please give me any pointers as to where to start? I already know COM, but i don't know anything about DHTML, or the DHTML interface?
Thank you very much in advance..
|
|
|
|
|
Go to http://msdn.microsoft.com[^] Enter: DHTML Reference in the "Search MSDN for" edit box the click the "Go" button.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hello, I am having trouble making a semi-infinite loop. Here's the problem: I need to send a positional value from a machine to a dialog box on my main dialog screen all the time, but the program must be able to detect when buttons are being pushed and things like that
Right now I have it where I can continuously update the text box while a button is down by using the command: while(GetAsyncKeyState(VK_LBUTTON)<0) , but the mouse button must remain down to do this, which makes all of the other buttons on the dialog useless. I need to do something like this in my main dialog box: always update the text box without clicking the mouse or pressing any buttons and be able to constantly monitor when the keyboard is pressed and when the mouse buttons are pressed
Thanks for your help!
Loren:
|
|
|
|
|
Have you ever seen my article: "Take user's action for loop forever" ?
well, you can see it in programming tips.
ZARZOR13
|
|
|
|
|
I'm pretty sure there is something trivial that you are missing, but I don't do windows event loops enough to tell you what.
As an alternative, that might be better: have you considered using threads? use one thread to read this message, and when it changes post a message to the main thread. (In some systems you can update the window from that thread, I'm not sure about windows) Threads have their own problems, and are difficult to work with on some levels, but it might be better.
|
|
|
|
|
Loren,
Have you thought about using the timer event. In the OnInitDlg section of your code you could create a timer that calls the OnTimer event. Have it run every second. Then you can let the rest of your program do what you want it to do. I have this running a clock in a status bar. Work great.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Have you considered using windows hooks ?
gabby
|
|
|
|
|
Hi all.
I am trying to customize the cookie data in the http headers of my IE. That is to say I must add my own 'Cookie' header to standard IE http headers. But, each time when I use IWebBrowser2::Navigate2() function to add 'Cookie' header(such as 'Cookie: jsessionid=0DE9IIUD03D23'), the 'Cookie' header will be filtered by IE. It seems that the 'Cookie' header is maintained by IE itself and it is not changeable.
Is there any way to modify IE's 'Cookie' http header according to you need?
Any suggestion will be appreciated.Thanks very much.
Leo.
To be better, better and better ...
|
|
|
|
|
Hi All!
Can Anyone tell me how to patch a memory address in an .exe from the same exe?
|
|
|
|
|
Dennis L wrote:
...patch a memory address...
Exactly what does this mean?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
In the U.S., Memory Address Patches are available in most Pharmacies. If you can't find them you can use the Generic "Patch Patch" with the "Universal Patch Adaptor".
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
How to get "." formated IP Adress string from hostent structure, returned after gethostbyname(...)?
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
Like:
CString strIPAddress;
struct sockaddr_in dest;
LPHOSTENT lpHostEnt = gethostbyname(szHost);
if (NULL != lpHostEnt)
{
memcpy(&(dest.sin_addr), lpHostEnt->h_addr_list[0], lpHostEnt->h_length);
strIPAddress = inet_ntoa(dest.sin_addr);
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
thankx, that was useful to me
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|