|
Sorry, I would have to check my work computer. Make sure you read the STLPort release notes. There are some things for VS.NET you have to watch out for.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I have a function: CString CMyView::GetNextString( ifstream &File ). Now that has been working for quite a while and all of a sudden I'm getting an error that says syntax error: identifier 'ifstream' and points to the the function declaration. I have the #include "fstream.h". It was working but now its not. Any reason why it just stopped working and how to fix it?
-Raffi
|
|
|
|
|
I haven't used ifstream in a while, but as i recall you want to use
#include <fstream> not
#include "fstream.h".
--------
Sip my mind.
|
|
|
|
|
Did you migrate to .NET ? Maybe it finally removes the deprecated header fstream.h. As has been said already, you should use #include <fstream> and then you need using std::fstream; as well.
What else has changed in your project ? Things don't just stop working by themselves, it must no longer be able to see the header.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
I havent moved to .NET .I tried useing #include < fstream > and I got 16 errors.
When I fisrt added my function I got that same error. Then I deleted the function, rewrote it and it worked for some reason. I added other functions(a change) and then the error reocurred. I tried rewriting the function but it doesnt work now.
Could you explain the std::fstream a little? I've never seen that before and it might be the solution.
Thanks for the help.
-Raffi
|
|
|
|
|
(With the permission of Christian)
Try this. In every .cpp of your project, right after the #include s write
using namespace std; This is usually labelled as a big no-no as C++ coding style goes, but it should get your program working with minimum effort.
If you want to know more about namespaces (that's what std is), have a look at (for instance) this tutorial.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
If you want to know more about namespaces (that's what std is), have a look at (for instance) this tutorial.
Is there no namespaces tutorial in CP ? Hmm... I've been wanting to play with unnamed namespaces for a while, maybe I should write an article.....
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
Is there no namespaces tutorial in CP ?
None that I know of... Unnamed namespaces are rather exotic constructs, and (IMHO) students of C++ will have a hard time learning their uses (so a tutorial of yours might be just very well called for ). To make things worse, the standard guys are considering deprecating static where it means "local to the current compilation unit" in favor of unnamed spaces --a controversial and little advantageous decision in my opinion.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Unnamed namespaces are rather exotic constructs, and (IMHO) students of C++ will have a hard time learning their uses (so a tutorial of yours might be just very well called for ).
To be honest, my manager showed them to me and the purpose of the tutorial would at least partly be to understand their uses fully myself. It looked exciting, but I need to play with it to appreciate it a bit better.
Joaquín M López Muñoz wrote:
To make things worse, the standard guys are considering deprecating static where it means "local to the current compilation unit" in favor of unnamed spaces --a controversial and little advantageous decision in my opinion.
Why do they want to do that ? From what I've seen of the stuff they want to include in the next standard ( threads, GUI stuff) ,I think the standards committe may be running out of useful things to talk about.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
As always, the crowd cheers and roars at your upcoming tutorial If you accept suggestions, there's an interesting subject in connection with namespaces that you might find worth writing about, namely the use of namespaces to support versioning: the library vendor just releases upgrades with different namespaces (say wonderlibrary1_0 , wonderlibrary2_0 , etc.) and the user decides the actual version she wants to use with
namespace wonderlibrary{
using namespace wonderlibrary2_5;
} Cute, isn't it.
Why do they want to do that ?
Don't know. I guess you can find explanations in comp.lang.c++.moderated. To be precise, the declaration has been annonunced from the latest 98 standard.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
there's an interesting subject in connection with namespaces that you might find worth writing about, namely the use of namespaces to support versioning
Hey - that *is* a cool idea. I will definately make mention of it.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
Simply, using the right header ( fstream, not fstream.h ) wraps all of the included stuff in namespace std, so including the right header would break your code in the 16 places you used fstream unless you also did a using std:: statement for each item you use from the header, or using namespace std;, which is evil and pointless, you may as well stick with the deprecated header if you do that.
Also, I forget - did you pass in a stream, or a *reference* to a stream ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
I passed it as a reference to a stream. Is that the problem?
Thanks for all the help.
-Raffi
|
|
|
|
|
Hey all,
I wrote a serial communications protocol stack (transport, network, and datalink layers) for on of our products as a standard library for use in Visual C++. Now of course they want me to convert it for use in Visual Basic . My first thought was to convert it to an active X control, but the RX thread in the stack relies on a windows message. It didn't seem like MFC was going to make it easy to process this windows message and provide a control fire.
So I am thinking I can convert the static library to a dynamic link library and I was wondering if anyone had some quick tips on making this possible. This of course assumes that I can make VB handle windows message which probably won't work either . I need to be able to export the CTransportLayer to VB which I think I know how to do.
I could rewrite everything exporting the right classes, but I want to make sure that I can maintain the code in one central code base. In other words I don't want to have to make changes in the static link library and also in the dynamic link library.
Thanks,
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
well, you can't export any "classes" if you want to be able to use the DLL from VB because VB can only handle plain old C interfaced DLLs. and even then, you've got to be careful in your choice of parameters because VB is a little bitchy about dealing with pointers into structs and such.
for my projects, i write all the classes in C++ then put a plain C wrapper around them - then i export these C functions. if any C++ object needs to exist outside the library (ie. outside the C wrapper), i pass the object address out but i give it a "handle"-type name so that people won't be expecting to be poking around inside it. and, i put lots of validity checking when getting the object back (to make sure VB hasn't passed the wrong thing back).
-c
A computer lets you make more mistakes faster than any other invention, with the possible exceptions of handguns and Tequilla.
Mitch Ratcliffe
|
|
|
|
|
If your code is mainly in classes, then I would create COM objects from them, and expose these objects through a typelibrary in your DLL. It may be a little bit of work to re-organize the code in this fashion, but this is the cleanest way to expose objects and functions for VB users.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Yep my code is mainly in classes. Actually it is all in classes.
I guess though, I have created simple COM objects before, but I cannot find much information on typelibrary and how one creates these. Is there any references you can give me so I can check this out?
Also one of the things I don't want to do is maintain two different libraries. This shows my beginning nature in COM objects, but can I still use this as a static linked library, would I need to convert other projects, or maybe I should just create a COM object with a wrapper class around it that can be exposed?
Thanks for the suggestion, I would love to learn how to do this.
Brian
|
|
|
|
|
Does anybody know what happened to the GetFieldValue() method of the CRecordset class in MFC version 7?
In version 6, the method had 4 overloaded versions, one of which was:
void GetFieldValue( LPCTSTR lpszName, CString& strValue );
In version 7, the method still has 4 overloaded versions, but now the one stated above is missing, and seems to have been replaced with the following two:
void GetFieldValue( short nIndex, CStringA& strValue );
void GetFieldValue( short nIndex, CStringW& strValue );
The problem is that we have a bunch of code that uses the version that was only shipped in version 6, and hence the code does not compile in version 7 (without a bunch of tedious tweaking).
Was this an oversight by MS? Or did they have a reason for removing this particular version of the method?
Thanks in advance to all who have input
--
Loren Brewer
|
|
|
|
|
I compile my old project to VC 7 and I can see dependency from oleacc.dll. This is accessibly controls, but I have not used this in my app. How to remove it?
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
This interesting Usenet thread treats the problem in detail. Esentially, this dependency breaks programs running in Win95 --Win98 and higher have the library by default (though it can be removed, which is another added problem). The simplest option is to statically link and activate delay loading, but a guy in the thread tells how to rebuild the MFC70 DLL so that it does not link oleacc.dll . Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have a static control on my formview, it is linked with a control member m_static. I want to give this control a color background. So in
CMyView::OnDraw(CDC * pDC)
{
CBrush brush.CreateSolidBrush(RGB(255,255,255));
CRect rc;
m_static.GetClientRect(&rc);
ClientToScreen(&rc);
pDC->SelectObject(&brush);
pDC->Rectangle(&rc);
}
but instead of drawing a white rectangle, it is draw somewhere else on the screen. What did I do wrong?
any hint is highly appreciated.
|
|
|
|
|
I'd say the (0,0) of the CDC passed to OnDraw is at the topleft corner of your drawing area, so ClientToScreen can be omitted.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ok, here is what is going on
1. Your DC is relative to the origin of CMyView
2. When you invoke m_static.GetClientRect (), the rect is relative to the origin of the static control.
3. When you invoke ClientToScreen, the adjustments are being made to the CMyView window and not the static. Try m_static .ClientToScreen.
4. You also should add a call to ScreenToClient to move the screen rect for m_static to be coords relative to CMyView.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Finally, I got it. The code is like this:
RECT rc;
m_cStatic.GetClient(&rc);
m_cStatic.ClientToScreen(&rc);
ScreenToClient(&rc);
pDC->SelectStockObject(BLACK_BRUSH);
pDC->Rectangle(&rc);
But the problem is that: the black rectangle will not be displayed, unless I deselect the visible option of the static control. I tried use pDC->SetBkMode(OPAQUE) or TRANSPARENT, but it doesn't help. It seems to me that the static control hides the black rectangle. Why?
Tim Smith wrote:
Do I feel lucky?
Yeah, sure, I do feel lucky to have such a wonderful forum to go.
|
|
|
|
|
Tim Smith already answered your question; i'm just going to suggest that you use OnCtlColor() to change the background of the static control instead of doing it this way. You will more likely get the results you are looking for.
--------
Sip my mind.
|
|
|
|
|