|
The resource issue is one reason. The most important objection, though, is of a more profound nature. Adhering to a huge framework for the sake of a tiny utility class like CString can cause more harm than good: if you for instance need to port your app to a non-Win32 platform, you'll be regretting you're locked into MFC for such a minute reason. My advice is one should use MFC for what is worth --doing GUI stuff for Windows.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
that...and the fact that the original poster said "non-MFC".
-c
Cheap oil. It's worth it!
|
|
|
|
|
Instead of adding MFC, use std::string. It has a substr method which does what you're looking for.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
If you don't want to use std::string, use WTL which has a CString that works just like MFC's.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I developed a program as a Win 32 application (non-MFC)
But I find it very difficult to work with string without CString (MFC).
Can I use this MFC class in my program without rewriting my program ?
Can I include this MFC class like a normal class ?
Help me !
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
dlhson wrote:
Can I use this MFC class in my program without rewriting my program ?
no. but there are many classes available on this very site that do just about everything CString can do. or, you could use std::string.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Yes you can, you just need to include MFC support. Look up this topic in MSDN.
Add MFC Support to an ATL Project
Adding MFC support to a Win32 app is similar.
|
|
|
|
|
I created a template and want to use new to instantiate it. What is the correct format?
new CClass<float,double> m_Class;
Is this correct?
How would I use delete to clean up?
Thanks in advance.
|
|
|
|
|
CClass m_Class;
It is a template you said? If for instance:
template<class T>
class CClass {
};
You'll have to create it this way:
CClass<sometype> m_Class;
Where sometype is the template type you want to instantiate.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Yeah, and if u would like to instantiate on the heap, all u have to do is declare a pointer,
CClass <sometype> * m_pClass;
then call new:
m_pClass = new CClass<sometype>;
and whenver u need to free the memory u can call:
delete m_pClass;
and that's it!
Papa
Murex Co.
|
|
|
|
|
I try :
IXMLDOMDocument *p=NULL;
if (FAILED(CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2, (void**)&p)))
AfxMessageBox("failed");
else
p->Release();
It seems that the class is not registered. I've recently reinstalled the system. Is it a way to register all the usual classes in a shot?
rechi
|
|
|
|
|
How can you tell that the class is not registered? You don't fetch the return value from CoCreateInstance .
Did you call CoInitialize(NULL) ? That may be your problem.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I've fetched it in some other code. Anyway, the application is a MFC supporting automation so i don't need to call CoInitialize .
rechi
|
|
|
|
|
I think you have to call it. Anyway, just give it a try, so you will be sure you don't have to call it.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
As expected, it returned S_FALSE, meaning that the library is already initialized on the current thread.
I still think i have to register the class.
rechi
|
|
|
|
|
verify that you have called AfxOleInit() in your InitInstance() code - this is the typical place to put it
|
|
|
|
|
Is called. The application is MFC supporting automation.
rechi
|
|
|
|
|
can anyone tell me how to print on a paper from the user selected tray.
let say.. user enter tray 1, and click on print button, data will be printed on the paper from tray 1 . how can i set that..
i use Devmode for setting paper size. but now i want to use whatever paper size from tray 1.
how can i do that?
what is dmDefaultSource in devmode structure.
thanks
|
|
|
|
|
Is there a trick to using the progress control? When I add it using the resource editor...my dialog simply X|s.
Thanks...
ed
Someday we'll look back on this moment and plow into a parked car.
Evan Davis
|
|
|
|
|
|
|
has anyone written a control that does graph layout like GraphViz does only renders the graph to a control - would be nice if you can click on nodes, collapse them etc.
Needs to be free with source ( Yes I know about Tom Sawyer graph stuff)
Thanks
|
|
|
|
|
I have used the win32 string manipulation routines before, but they still puzzle me somewhat. For example;
char output[255] = "String";
int size = strlen(output);
strlen takes in a pointer to a char. Why then, am I allowed to send it a char array directly? Why does it treat a char array as a pointer to a char?
Simon
I need your clothes, your boots, and your copy of VS.NET.
Sonork ID 100.10024
C++ : The slag of all languages
|
|
|
|
|
Simon Walton wrote:
Why does it treat a char array as a pointer to a char
because, in C, an array is equivalent to a pointer.
char *p = new char[100];
char q[100];
p and q can be usd in the exact same ways.
p[50] = q[50] = 10;
the only differnece is that you need to clean up p when you're done.
-c
Cheap oil. It's worth it!
|
|
|
|
|
I've always suspected this. It's quite strange really. I mean, it's just a block of bytes one after another, why give it special status?
Simon
I need your clothes, your boots, and your copy of VS.NET.
Sonork ID 100.10024
C++ : The slag of all languages
|
|
|
|