|
it's included in other classes..
but not in this specific class or in any headers included in this class
|
|
|
|
|
There is no such thing. You've included this file without knowing it, probably it's listed as an include in the project settings. If you don't include it, it's not included. Simple as that.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
We can create functions that return values like :
<br />
CString my_function()<br />
{<br />
CString my_string="whatever";<br />
return my_string;<br />
}<br />
BUT I NEED A FUNCTION THAT MAY BE ABLE TO RETURN A CStringArray OBJECT OR SOMETHING SIMILAR WITH SOME DATA !! I mean, something like this:
<br />
CStringArray my_function()<br />
{<br />
CStringArray my_array;<br />
my_array.Add("VALUE1");<br />
my_array.Add("VALUE2");<br />
return my_array;<br />
}<br />
THANKX !!!!
|
|
|
|
|
If an object has a copy constructor you can do it. It might even be optimized to not be a performance nightmare.
For anything but a trivial return value, I prefer passing a reference to the object to be "returned."
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Could you show me an example please ??
I'm really thanked...
|
|
|
|
|
void my_function(CStringArray& my_array)
{
my_array.Add("VALUE1");
my_array.Add("VALUE2");
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
well, and declare my_array as public ?
|
|
|
|
|
What do you mean ? You pass the array into the function, but you pass it as a reference ( which means you put a & between the type and the variable name ). That means that any changes to the variable within the function also occur to the object outside the function, it's a bit like a pointer, except you have the object, not it's address.
Another point - you should use std::vector over CStringArray unless you have pressing reason to use crappy MFC containers.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
What Christian said except about std::vector. I like CStringArray. Works just fine and has less weirdness than vector.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Yes it was said to pass a reference. I mean, to modify a public CStringArray object from a function.
That's a good idea !!
Thanx for everything !!
|
|
|
|
|
I am using MFC and have a class named
class CProfiles :: CPropertyPage
I currently have the default constructor , using which I create an Object of this class at Runtime such as :
<br />
CProfiles *ptr = new CProfiles();
Now i needed to modify this to pass a value that I need
CProfiles *ptr = new CProfiles(12);
I tried to make changes to my class
In the .h file
CProfiles(); and in the .cpp file
CProfiles::CProfiles(int type=0) : CPropertyPage(CProfiles::IDD)<br />
{<br />
dataBuffer=0;<br />
bufferSize=0;<br />
loaded = false; <br />
Initialize();<br />
}
This isnt compiling . What am I doing wrong here ?
|
|
|
|
|
what error does the compiler return ?
another thing a see. you parameter type , you don't use it in you constructor ; i don't think it is what you wanted to do...
TOXCCT >>> GEII power
|
|
|
|
|
I get the following errors
error C2511: 'CProfiles::CProfiles' : overloaded member function 'void (int)' not found in 'CProfiles'
: see declaration of 'CProfiles'
fatal error C1004: unexpected end of file found
Secondly , the error isnt caused by me not using the variable type ! I am not using it as I am trying to get the Constructor to compile !
Engineering is the effort !
|
|
|
|
|
Needed to do this in the .h file
CProfiles(int type=0);
and in the .cpp file
CProfiles::CProfiles(int type) : CPropertyPage(CProfiles::IDD)
{
//{{AFX_DATA_INIT(CProfiles)
//}}AFX_DATA_INIT
dataBuffer=0;
bufferSize=0;
loaded = false;
profileType = type ;
// Initialize
Initialize();
}
This time I am using the variable "type" !!!!
|
|
|
|
|
isn't there a void trailing few lines before you start the implementation of CProfiles::CProfiles(int); ?
do you also correctly include your header in the cpp ?
are you then sure that you inserted in the .h the synopis CProfiles(int); into the classe definition ?
to finish, i know that the type parameter is not at the origin of the error, i was just astonished to see you don't use it while you just said you overload the construct for that. but nevermind.
TOXCCT >>> GEII power
|
|
|
|
|
does anybody have any code that helps in sound recording from microphone without using directshow/directsound and all those complex things?
also not write to a file but to keep the recorded sound data in memory.
|
|
|
|
|
from microphone without using directshow/directsound and all those complex things
DirectX is a layer provided by Microsoft to access hardware using a standard uniform API, without it, you will have to write each API for each of the hardware installed. Like, when you need to use Creative Sound Card, you will need separate API and so is other sound card. You will need a lot of version of your program to get it compatible.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Anthony - That's not entirely correct. Another option is to use the Windows MME API - for example the WaveIn* functions will do the trick too, and you won't really care about the hardware.
Shoonya - start with the WaveInOpen function and go from there. I don't really know what you are looking for, but this is a viable alternative to DirectX. You might find, though, that this is has different 'complex things', and DirectX might still be the way to go. The choice is yours.
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
Sorry, but decided to delete my previous posting. I don't want to deal with any questions. If you use email notification, you'll have a copy.
Here's an article that covers some of the same things (except, he apparently uses callbacks, which I don't normally recommend, but if it works....) http://www.codeproject.com/audio/wave_class_for_playing_and_recording.asp#xx648264xx[^]
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi and thanks in advance:
I am trying to create an application that first offers the user to open a file. I am using the function GETOPENFILE, then I my purpose is to check in the same folder, if there is another file (no user interaction there). For that, I was using the variable ofn (OPENFILENAME type) from the previous task, so it should have the information of the path and file name.
I tried, but had troubles to do that.
Here is a part of the code:
<br />
<br />
void CMainFrame::OnButton32794() <br />
{<br />
<br />
OPENFILENAME ofn;<br />
memset(&ofn, 0, sizeof(ofn));<br />
ofn.lStructSize = sizeof(ofn);<br />
ofn.lpstrFilter = "Tec Files (*.tec)\0*.tec\0All Files (*.*)\0*.*\0\0";<br />
int nResult = ::GetOpenFileName(&ofn);<br />
<br />
CString str;<br />
LPCTSTR azcv;<br />
TCHAR szPath[MAX_PATH];<br />
LPCTSTR lpszFileName;<br />
LPTSTR lpszFilePart; <br />
WCHAR wszTemp[MAX_PATH];<br />
<br />
lpszFileName = ofn.lpstrFile;<br />
<br />
str = GetFullPathName(lpszFileName, <br />
sizeof(szPath) / sizeof(TCHAR), <br />
szPath, &lpszFilePart);<br />
<br />
MessageBox(str);<br />
}<br />
<br />
|
|
|
|
|
Why call GetFullPathName() at all? If you are interested in the filename that was selected, just reference ofn.lpstrFile .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
ok, I just want to check if in the same folder, the one that the user select by selecting the file there is another specific file... without the interaction of the user. that's all.
Thaks, Ruben.
|
|
|
|
|
Use _splitpath() to split ofn.lpstrFile into its individual components. Then merge the components back together using " another specific file" instead of the file that was selected via GetOpenFileName() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks, could give and example on how to use this function?
Thanks, Ruben.
|
|
|
|
|
I presume you are referring to _splitpath() . If so, the MSDN docs have a good example.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|