|
And where are you stuck exactly ? If you don't know how to get the files from your folder, take a look at CFileFind[^]
|
|
|
|
|
Well I am able to get folder dialog box and select the folder but now i want that i should be able to display the selected folder files into the right pane of my sdi splitter window I am unable to do that
|
|
|
|
|
This is very vague. Does my answer help you ?
|
|
|
|
|
Can you be more specific
Do you want to get many files instead one file?
|
|
|
|
|
Yes I want to list all the file names in the selected folder
If anyone could help me out please
I am just a beginner
|
|
|
|
|
if you need to all files you can use FindFirstFile and FineNext
but if you want to multiselect use OFN_ALLOWMULTISELECT
OPENFILENAME ofn.m_ofn.Flags in function GetOpenFileName
Hope I understood your question
|
|
|
|
|
Thanx for the help !!!!!!!!
|
|
|
|
|
Thanx for the help !!!!!!!!
|
|
|
|
|
Hello everyone,
I find that _stprintf is defined to swprintf. And in the prototype of swprintf, the 1st and the 2nd parameters are both wchar_t. I think the other parameters should also be w_chart type, but in some situations, I always find others use char* type (which seems not unicode character type) as the parameter, like,
--------------------
// buffer is wchar_t* type.
_stprintf (buffer, L"%s", (char*)pointer);
--------------------
Definitions from Microsoft,
--------------------
#define _stprintf swprintf
_CRTIMP int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
--------------------
Can we use char* as the 3rd parameter? If we can, why can it (non-unicode type) be compatible with wchar_t type (unicode type)?
thanks in advance,
George
|
|
|
|
|
actually, _stprinf() is defined to swprintf() only if UNICODE is defined in your project. if not, then it is defined to sprintf() .
so, instead of using L"" literals, prefer using _T("")
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Thank you toxcct,
Why _T is better than L?
My question is whether it is correct to use char* type as the 3rd parameter in my sample. If it is not correct, what potential issues will be?
regards,
George
|
|
|
|
|
L defines unicode literal strings always, when _T defines unicode strings only if the project is compiling in unicode (wchar_t), otherwise, simple char strings.
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Thanks toxcct!
What header files need to be included if I want to use _L?
By the way, could you come back to the sample I wrote above to comment whether it is correct to use char* (non-unicode type) as the 3rd parameter of _stprintf? Thank a lot!
regards,
George
|
|
|
|
|
I would suggest you don't use the sprintf family of functions. It has just so many problems it's not funny. Here's some of them:
- It's not type safe.
- It's not extensible.
- It's plain not safe. How big do you make the buffer? Make it too small and you're in for a buffer overrun, which is no fun.
I'd use code like the following:
ostringstream ss;
ss << "The number is " << 42;
cout << ss.str() << endl;
This code assumes the following includes:
<iostream>
<string>
<sstream>
And this:
using namespace std;
With this code none of the listed problems occur.
Steve
|
|
|
|
|
Stephen Hewitt wrote: ss << "The number is " << 42;
Now you'll have to find the universal question
|
|
|
|
|
Hi Cedric,
What do you mean univeral question?
regards,
George
|
|
|
|
|
No one knows. I have it on good authority that the answer is 42 however.
Steve
|
|
|
|
|
What do you mean 42?
regards,
George
|
|
|
|
|
No, it is just a popular joke. Did you see the movie "The Hitchhiker's Guide to the Galaxy" ?
42 is the answer to the universal question. But it isn't funny at all if you didn't see the movie
|
|
|
|
|
I see. I have not seen the movie before. I have a lot of souce codes to read. Could you come back to this question and show me an example of mixed unicode type (wchar_t* and _T) and non-unicode type (char*), just as I mentioned at the beginning of this thread, like,
_stprintf (wchar_t*, _T("%S"), char*);
I just can not imagine that we can mix unicode type and non-unicode type in one statement.
regards,
George
|
|
|
|
|
Thank you Steve!
What means "plain not safe"?
Actually, I like your style. But I am reading and learning programs written by others. So, could you come back to the sample I wrote above to comment whether it is correct to use char* (non-unicode type) as the 3rd parameter of _stprintf? Thank a lot!
regards,
George
|
|
|
|
|
George_George wrote: What means "plain not safe"?
This is what I had in mind:
char buffer[1];
sprintf(buffer, "The number is %d", 42);
This code will result in a buffer overrun which at best will crash the program and at worst will open up a security flaw will can be exploited.
Steve
|
|
|
|
|
Thank you Steve!
Maybe I have not made myself understood. My question is not whether the buffer (as the 1st parameter) is large enough (suppose it is large enough in this case, I agree with you about the setbacks of this method), my question is that whether I can input char* (non-unicode type) as the 3rd parameter, while the 1st parameter is wchar_t* type and the 2nd parameter is L (constant string) type.
regards,
George
|
|
|
|
|
Yes. Use %S instead of %s .
Steve
|
|
|
|
|
Thanks Stephen,
I have found that %S is used to specify a wide-character string. Could you show me an example of mixed using of unicode type and non-unicode type, in the following format -- without any errors to print out anything?
I just can not imagine why we can mix the use of unicode type (w_char* and _T) and non-unicode type (char*).
_stprintf (wchar_t*, _T"%s", char*)
regards,
George
|
|
|
|