The way that I do it is AllocConsole(); m_hout = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleMode(m_hout, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT); If you say that it is not true that when the child process get deleted, the parent process also get deleted, then I don't understand why my GUI get closed when the user close the console window.
nachilau
Posts
-
Question about console windows -
Question about console windowsHello all, I have written a program which contains a GUI windows and also a console windows. When the program start, I allocate a console window from Windows. When the user close the console window during the programming is running, my main GUI get closed at the same time too. What I think is that may be the console window process is a child process of the main GUI window, when the child prcoess get closed, its parent process will also be destoryed. However, the destcutor of my main GUI porcess didn't get called when the console get closed which cause a lot of memory leaks. Do anyone know why my main GUI window destructor did get called when one of it child process get closed? :)
-
Question about static variable that define in a functionHello, Yes, I know that the static will created only once. But I want to know how C++ actualy implement this. And I want to know whether doing inline of f() will break the rule? Thanks! Nacho:)
-
Question about static variable that define in a functionHello all, Would anyone tell me that how C++ prevent the static variable been created more than one? Eg, if I have a function that contains a static variable:
void f() { static classA a; a.print(); } void main() { f(); f(); }
How C++ prevents the static variable "a" inside the function to be constructed twice rather than once? If I inline the function f(), will it still works? Thanks!!!:) Nacho -
Way to Prevent memeory leak?Thanks! But do you know how the OS clean is up for me? You mean the OS will keep doing a background search for the memory leak? Am I right? Thanks!
-
Way to Prevent memeory leak?Thanks for your suggestion. I know the way the smart pointer works, but as what you said, since the Assert function never return, smart pointer is no use in this case. Also, if I throw an exception, then, the try and catch block will go around in my code. That is so messy then! But thanks for your comment!!
-
Way to Prevent memeory leak?Hello all, I have a question on about how to prevent to prevent the memory leak? I am writing a window program, and I have an Assert() so that if any fatal erorr occured, the Assert() will call Sleep(INFIITE) to stop the program, and print out the error message to the user. By doing that, the only way to exit the program after Assert() has been called is to close the window. However, it causes a problem which is that even though the desturctor of each classes in the program will be called when the user close the window, there may still some memory leak in the local scoop when I use Assert() like this, eg in funciton f() f() { char* name = new char[10]; Assert(AnyError(), "Fatal Error!"); strcpy(name, "Hello"); delete [] name; } For example, if I get the Assert() if I get any error in f(), then when the user close the window, I will have a memory leak for 10 bytes. What is the best way to solve the problem? I don't want to use the try and catch block since the code will be mess up with all those try and catch block. And I really want to stop the program when the fatal error occurs. Any ideas? Thanks! Nacho
-
Big Endian and small endianHello All, Can someone suggest a fast ways to convert big endian to small endina? Thanks! Nachi
-
Reading .PSD fileHello, Can anyone provide me some ideas or resources in order to read the .PSD file? I am more interest to know how can I read the layer information of in the .PSD file. Thanks! Nachi
-
Some questions about inline functionHello all, I have some questions about inline function, if I have something like this
class myClass { protected: int i; public: inline Set_I(int val) {i = val;}; } int main() { myClass c; c.Set_I(10); }
I want to know what will actually happen. Since Set_I() is an inline function, the compiler will replcae the definition of the function in where the function has been invoked. However, in this case the inline is actually accessing the protected member of the class, so what will happen?? Thanks! Nachi -
Questions about defining a funcitonHello, You are right, I know that it does not make any sense, but I still don't know what is this, int const f(); even thought I never use it in my programming experience. But in some C++ test, people ask something about this, and what I know and what I have used is only something like this, void f(const int); or void f(int) const; and these both make sense to me, but not int const f(); therefore, the's why I would like to know whether this signature make sense to any of you. But anyway, thank you for all your suggestio! Nachi
-
Questions about defining a funcitonSorry, it doesn't really help, I know how to use a constant data in a program, but I have some confussion when using in the definition of functions Thanks! Nachi
-
Questions about defining a funcitonUmmm, You said the second one char* const f(); does not exist, but if I write this in Visual C++, the compiler does not complain. Also, for the first one, I can actualy return something which is not a const, eg, const int f() { int i = 10; return i; } and it also works in Visual C++ too. And would you mind to tell me why's that? Thank you very much! ;) Nachi
-
Questions about defining a funcitonHello All, Can anyone tell me that what is the different when declare function like const char* f(); and char* const f(); I would like to know what does this two function signature means. Thanks! :)Nachi
-
Some questions when declare a functionHello, I have some questions about declare functions, when I declare a function, what is the different between const char* f(); and char* const f(); Thank for your help! Nachi:)
-
How can I get the file size of a fileHello, How can I get the file size of a file using standard C++ library (not MFC)? Thanks!! Nachi
-
How can I check whether the folder is exist or not?Hello all, I would like to know how can I check whether the folder is exist or not? Which function should I use in visual C++? and which library should I included into my program? Thanks! Nachi
-
How to create an empty folder in Visaul C++Hello, I would like to create an empty folder on the disk, which command should I used in Visual C++? Thank you for your help! Nachi
-
How to open a folder using MFCSorry, I am not really know how to use this function, is there any example so that I can study on, thanks! Nachi
-
How to open a folder using MFCHello all, Currently, I need to write a program which allows the users to select a specific folder on the hard drive. However, I only know how to use MFC to allow the users to select specific file on the drive by using "GetOpenFileName()". Is there any way which allows users to select a folder rather than a file in MFC? Thanks!!!! Nachi