Now, this is what happens when I call the in-dll functions from outside the dll:
CString s = Trim(" my string "); // this works fine!
CString s2 = EatString(&s, " "); // this gives a crash inside EatString at the point where I try to set the value of s (like this: *s = "new string");
CMyOwnObject * pNew = new CMyOwnObject("new"); // This gives a crash at the point where the constructor ends... for SOME reason it goes into the desctructor of CString (probably for "new") and there it crashes on FreeData() )
I don't want to completely rewrite all my code to BSTR's and so for the moment. Is there another way to fix this? (Trim works just fine!)
Just checked it, but the _AFXDLL wasn't in there... So I put it there, but that didn't seem to have any effects on the result (even after clean rebuilding a couple of times)...
I just created the project with the classwizard, selecting an extention DLL... And everything works, except this... It crashes on the destructor of the input string!
I found that putting LPCTSTR in the header, instead of CString, resolves the problem, but then I have to rewrite all my headers to use LPCTSTR... And what do I do with CString * then? I can't use LPCTSTR *, right?
Hmm, actually, I don't want to use 'MFC in Shared DLL', because a business policy of ours is to always use MFC in static DLL (to avoid MFC version conflicts)... BTW, it works if I put both projects in MFC as shared DLL.
If I use MFC in a static DLL, then what is the correct way to handle input-ouput string characters? My function does the following:
> If I use MFC in a static DLL, then what is the correct
> way to handle input-ouput string characters?
There's no such thing as static DLL - 'D' in DLL means dynamic.
If you use static lib version of MFC, your .dll and .exe will have two different heaps. Memory allocated in .exe can't be freed in .dll and vice versa. Using CString::operator= may cause heap operations, and this is going to crash when MFC isn't shared. So the declaration for EatString should look more or less like this:
int EatString(char *szOutput, int cbOutput, const char *szInput);
You can return number of characters in szOutput after completing the operation. Or the error code, or whatever.
Here is a description of what I want to do:
Everyday I connect to a news web page that includes a number of news headlines each one of them being a link to the full story of the corresponding headline. I would like to develop an application that shall connect to this web once a day, download all headlines and the corresponding full stories and store them in a TEXT file that I will be able to later print and read. How can I do this using VC++?
I would use the WinInet functions (functions that start with 'Internet*') to get the main page.
When you have the mainpage, you can find all the '<A href=.....>' where the URL to all the other sides is. Then use the same code, as you used to get the mainpage, to get the newspages, and save them to a local file...
I want to connect a file source filter,a avi splitter filter,a avi decompressor filter and a null renderer filter together to get the decode time of the total frames approximately,how can i connect them together??
You mean print to the printer ? If your mapping mode is MM_TEXT, you'll find everything is stupidly small, because an A4 page can have 4000x6000 'pixels' and so you get a postage stamp in the corner from your code created for 800 x 600. I set up a flag to make the code in OnPrepareDC/OnDraw/OnPaint not execute at all, because what I'm working on, I want a different result when I print ( a report ) anyhow. I do all my printing in OnPrint. If you *do* want the printing to be the same, the trick is to draw things relative to the DC size, which you get from GetDeviceCaps(dc, HORZRES) and VERTRES. Either way this is how I do my OnPRint, because I don't know ahead of time the DPI of the printer my users will be using. If you do this and draw with stretch blt, you'll be able to get your bitmaps to print OK. For text, you need to use a function that takes a DC and allows you to specify a font size in points. I think CFont has CreatePtFont, but I'm not sure ( it's something like that, but I learned about it here about a week ago ). In GDI+ you specify fonts in points automatically. When I moved to GDI+ I finally got all my fonts perfectly as I requested them, the same in my preview ( which I draw myself in a seperate function ) and my page. This is essentially because GDI+ IMHO behaves more as I expected it to in terms of the size of the font returned ( although it just may have been because I'd never discovered CreatePtFont ).
Sorry if this rambled a little - if you need more info, just ask. I can post some code to do it tomorrow at work if you're still stuck.
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
How can I add activex component into my program at runtime? All helps talk
only about using Classwizard. But I can not find any help about
creating and using ActiveX component at runtime (like ActiveX tester tool)
I'm using Win2000 and Visual Studio 6 (C++)
I am working with Disconnected Recordsets in a Component Function.I am passing the Recordset pointer from the Server to Client.There is no problem here.However , when I run the client for the First Time the Connection and Recordset objects are opened and I can get the records at the client(The server maintains these Records in MS Access DB).When I run the client for the second time and so on I get the COM error that "The application requested an operation which cannot be performed on an Object which is already open ".The error is due to Recordset opening at the start of the function .But, I am closing the REcordset at the client side.
How should I open and close the REcordset in that case to avoid this error ?