|
Er well it works because of the way DoModal works. Each (UI) thread has a message pump as im sure u know, and in MFC, that pump is usually started by returing true from InitInstance. When you call DoModal on a dialog - you want that call to block until the dialog is closed - and you also want to continue to pump messages while waiting. MFC does that by running another message pump within DoModal, that runs until EndDialog is called and then passes control back out to the "outer" pump. That all apples if your not using a dialog for you "main" window.
When the message pump in DoModal comes across a WM_QUIT message, it handles it differently. Its the outer pump that must process this quit message, so it reposts another WM_QUIT message and then exits it's loop. If you have m_pMainWnd set to anything other than NULL, then the WM_QUIT message is reposted.
Once a thread has received WM_QUIT, calling GetMessage/PeekMessage will do nothing. Internally, a MessageBox also pumps and process messages - so if you have a non-null m_pMainWnd, your message box will start it's own message pump, and will get the WM_QUIT message which was reposted - and exit.
If you set m_pMainWnd to NULL, the WM_QUIT message is esentially swollowd by the message pump in DoModal - even though the DoModal loop exits, the WM_QUIT doesn't get reposted, and hence the message box doesn't pick it up. The app is then exited via returing false at the end of InitInstance.
|
|
|
|
|
Hi-
I have some source code (samples) that will be distributed with an API. I'd like the samples to be in source control of course, but I'm not sure the proper way to remove source control for distribution. (So customers don't get a message like: "This project appears to be under source control, but ...")
Can this process be easily automated with an installer such as Nullsoft's NSIS? It should be clear, but I don't want to remove source control entirely, just for the distributed code.
|
|
|
|
|
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 ...
|
|
|
|