|
Tim Smith wrote:
This is the best one.
This? What do you mean by this? The constructor or the operator overloading? The latter is more elegant, but the first one comes more readily to mind.
There's been another reply- somebody used a #define on cout itself (!).Check it out.
Regards,
Vikram.
"Do not give redundant error messages again and again." - A classmate of mine, while giving a class talk on error detection in compiler design.
|
|
|
|
|
How about getting the preprocessor to do it for you?
#define cout cout << "Hello, world"; cout
I also came up withe the operator<< override myself, although I was a bit too unfamiliar to write it.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
WOW!
I never woulda thought of that! Err... maybe I would, given some time. Anyway, full credits to you!
No offense meant, but if you see closely, I don't want anything inside main() to be changed. Your solution and the << overload solution indirectly do that. They change the behavior of what is inside main() from outside. A purist wouldn't like it. The "cleanest" is the global constructor solution, while the dirtiest is the pragma (see my earlier post for code).
Nice work!
Regards,
Vikram.
"Do not give redundant error messages again and again." - A classmate of mine, while giving a class talk on error detection in compiler design.
|
|
|
|
|
How can I handle directories with space when passed into ParseCommandLine. It seems to treat them as paramaters. Any ideas?
ie c:\documents and files\
Thanks
|
|
|
|
|
Surround them with double quotes when passing them in.
e.g. "c:\documents and files\"
Dave
|
|
|
|
|
|
I tried adding a static variable inside a class. ie static CButton m_button and I get a linker error. Any ideas.
Thanks
|
|
|
|
|
If you add a variable as a static it is declared, but not defined. You need this:
class a
{
static int i;
}
int a::i = 0;
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Hello,
I am having trouble with FindResource() when trying to find a resource of custom type.
This code returns null:
<br />
HRSRC hResource = ::FindResource(hInst, "IDR_MYNAME", "MYTYPE");<br />
I also tried FindResourceEx with my language locale, but all the same.
Any ideas as to what I am doing wrong?
|
|
|
|
|
I presume that IDR_MYNAME is your resource ID - in which case you want:
HRSRC hResource = ::FindResource( hInst, MAKEINTRESOURCE(IDR_MYNAME), "MYTYPE" );
Dave
|
|
|
|
|
Yes, I am sorry about that , this is what I've been using.
It doesn't work.
While this works:
<br />
HRSRC hResource = ::FindResource( hInst, MAKEINTRESOURCE(IDB_MYBITMAP), RT_BITMAP); <br />
|
|
|
|
|
Maybe your resource is not in the instance handle passed.
Maybe your resource 'type' did not get stored as "MYTYPE".
Open the DLL or EXE with Visual Studio in 'as resource' mode to see if the resource is really in there.
You might check the value of GetLastError, it usually helps track it down the problem.
C++/MFC/InstallShield since 1993
|
|
|
|
|
hi there, i'm new to this place and Visual C++, so bear with me if i don't ask this clearly....
basically...
i have an SDI based on the form type (so effectively it's a dialog with saving).
I have a tree structure forming, where each node will represent a different version of a file. What i want to do is drag a file, or open a dialog or whatever and add the details to this tree.
I think i know how to store the details, serializing classes and things, it's just getting the information for the file. Preferably i would want to copy the file to it's own subdirectory too...
so to summarise I'd like the following but am unsure on file handling.
NOTE: I'm not talking the file handling as in saving the SDI... i mean dragging a file into the dialog.
The tree would look something like this:
test.txt-
|-Version 1.0
|-Version 1.1
|-Version 1.2
The node would point to an object which needs to contain the file location and other attributes.
For simpleness the file location would be a subdirectory called "version 1.x" from where the SDI document is located...
Hope i'm not asking too much
Just a few pointers on this kind of file handling would be great - i'm not neccaserily asking for a complete solution
Thanks very Much
Colin Davidson
|
|
|
|
|
One solution is CFile. Another solution is CStdioFile.
Kuphryn
|
|
|
|
|
I need to update the resource in an exe file under Windows 98 when my program is running. Under Windows 2000/XP, I can use BeginUpdateResource, UpdateResource and EndUpdateResource. But I am dejected that these functions don't exist under Windows 98. What can I do? Please help.
stanley
|
|
|
|
|
As far as i know, you cannot do this under Win95/98/ME unless you directly edit the PE file format (which is not pretty...).
Dave
|
|
|
|
|
Can you give me a sample including source codes under win95/98/ME?
stanley
|
|
|
|
|
Unfortunately not - i investigated a bit a while ago, but decided it wasn't worth it because most of our users are on NT/2K/XP. So that functionality is just not available under Win95/98/ME.
Dave
|
|
|
|
|
Oh, my god! I am so unlucky! Because of my client's request I have to realize the funtionality. I need help really. Please....
stanley
|
|
|
|
|
Is it possible to post a message to a CDocument derived class? I am curious because I noticed that it has a BEGIN_MESSAGE_MAP()/END_MESSAGE_MAP().
Plus it would be really handy if I could have a thread post a message to the document so that it is updated. I know I can do this if I post a message to a CView, but I would like to do it to the document then have the document update the views using something like UpdateAllViews().
Cheers,
Clint
|
|
|
|
|
A document is not a window, so you cannot post arbitrary messages to it. You can send WM_COMMAND messages to it, but only because MFC handles the message routing itself. CDocument is derived from CCmdTarget , which means "can be the target of a WM_COMMAND message"
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
BUY MY SOFTWARE!! (please?) RightClick-Encrypt | 1ClickPicGrabber
My IntarWeb Homepgae!!!11
|
|
|
|
|
Thank you for the clarification.
Perhaps you could answer another question. I have a thread that is owned by the CDocument derived class. The threads sole purpose is to wait on some incomming data then update a structure in the document. The problem I was running into is that when I called UpdateAllViews I would ASSERT() because of some issues with multithreaded programs and c++ objects.
I thought then that I could just update the data, then post a message to the document which in turn calls UpdateAllViews . That way there wouldn't be a problem.
Any suggestions?
Cheers,
Clint
|
|
|
|
|
Why don't you just post a message to the MainFrame and then use GetActiveDocument()->UpdateAllViews(...)?
Also use (CDocumentClassName *)GetActiveDocument()->SpecialProcessingFunctions(..) in the MainFrame to do any document manipulations which can also be message or timer driven.
Steve
|
|
|
|
|
This way it goes more Frame/Doc/View architecture than the pure Doc/View. I would personally avoid coding logic in the frame window unless it's absolutely needed (which is not the case). The message map in CDocument class can be nicely utilized to handle menu/toolbar/accelerator messages that are related to the document. Try to create message handlers in the classes that own the variables you use in these handlers, so there is nothing like ((CDocumentClassName *)CFrameWnd::GetActiveDocument())->SpecialProcessingFunctions(..) , but rather CDocumentClassName::OnSpecial() .
Regards,
BB
|
|
|
|
|
Someone please tell me what classes and DLLs do. Thanks.
|
|
|
|