|
Hello, i hope you can help me,
Ik need a program for instance a .exe file that when it runs it holds the image of my entire screen, meanwhile a other program is changing information and it had to fade into the current screen total time +/- 1 sec and then the program closes again. Is this possible? if yes please tell me how i can make this. I am not a verry good programer in c++ or maybee you can help me with it.
Thanks Johan
|
|
|
|
|
If you're using W98 or above, there is an AlphaBlend function that you can use to make your image fade.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi
I made a class that it's header does not include any other files..
however, when i used MAX_PATH (defined in windef.h ) it compiled well.
how that comes ? shouldn't i include windef.h or a file that includes it to use MAX_PATH ?
(others classes include stdafx.h but this one doesn't)
also how can I make such a (global #define ) ?
|
|
|
|
|
A header file isn't actually compiled, it's just #included.
When you #include your header it's effectively added into the source code of whatever file you included it in. So if you #include some other file with a #define it it before you #include your header file then your header will get the benefit of that #define making it look like the #define was some kind of "global".
For example, consider these files:
yourheader.h
#define MAX_PATH 256
myheader.h
typedef struct {
int FileID;
char FileName[MAX_PATH];
}FILE
mycode.cpp
#include "yourheader.h"
#include "myheader.h"
FILE myfile;
In this case yourcode.cpp will effectively look like this:
#define MAX_PATH 256
typedef struct {
int FileID
char FileName[MAX_PATH]
}FILE
FILE myfile;
So the fact that you didn't #define MAX_PATH in yourheader doesn't actually make any difference.
By the way, the order of the #includes effects this so if you changed yourcode.cpp to be
#include "myheader.h"
#include "yourheader.h"
FILE myfile;
you'd get a compile error because you'd use MAX_PATH before it's been #defined.
Hope that helps.
|
|
|
|
|
...I know how #include works .. but the problem here is that (as i mentioned in the post) I did NOT include windef.h
but MAX_PATH still can be used !!
|
|
|
|
|
So you didn't #include windef.h (or any other header file which #includes it such as windows.h) anywhere else in your project?
|
|
|
|
|
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
|
|
|
|