Choosing between WinMain and main in MC++
-
Hello If you use main or _tmain then your code will be basically a console app. Even if you use Application::Run to bring up a form, the ugly console will lurk behind. The solution is to use WinMain() instead of _tmain(). This was all very fine till I started using IJW. I need to #include <windows.h> But the moment I #include <windows.h> I get the compile error that says :- d:\Projects\Capture01\Capture01.cpp(22): error C2731: 'WinMain' : function cannot be overloaded :( :(:( :(:( :( Can anyone offer a solution? Nish
Check out last week's Code Project posting stats presentation from :- http://www.busterboy.org/codeproject/ Feel free to make your comments.
-
Hello If you use main or _tmain then your code will be basically a console app. Even if you use Application::Run to bring up a form, the ugly console will lurk behind. The solution is to use WinMain() instead of _tmain(). This was all very fine till I started using IJW. I need to #include <windows.h> But the moment I #include <windows.h> I get the compile error that says :- d:\Projects\Capture01\Capture01.cpp(22): error C2731: 'WinMain' : function cannot be overloaded :( :(:( :(:( :( Can anyone offer a solution? Nish
Check out last week's Code Project posting stats presentation from :- http://www.busterboy.org/codeproject/ Feel free to make your comments.
Blast. I didn't think properly I guess. Problem solved. Used dummy args :-) Nish
Check out last week's Code Project posting stats presentation from :- http://www.busterboy.org/codeproject/ Feel free to make your comments.
-
Hello If you use main or _tmain then your code will be basically a console app. Even if you use Application::Run to bring up a form, the ugly console will lurk behind. The solution is to use WinMain() instead of _tmain(). This was all very fine till I started using IJW. I need to #include <windows.h> But the moment I #include <windows.h> I get the compile error that says :- d:\Projects\Capture01\Capture01.cpp(22): error C2731: 'WinMain' : function cannot be overloaded :( :(:( :(:( :( Can anyone offer a solution? Nish
Check out last week's Code Project posting stats presentation from :- http://www.busterboy.org/codeproject/ Feel free to make your comments.
Well just go to linker options and add the following line to the command line /subsystem:windows, you will have a windows application with _tmain, or you can also try the reverse with /subsystem:console
-
Well just go to linker options and add the following line to the command line /subsystem:windows, you will have a windows application with _tmain, or you can also try the reverse with /subsystem:console
Rama Krishna wrote: Well just go to linker options and add the following line to the command line /subsystem:windows, you will have a windows application with _tmain, or you can also try the reverse with /subsystem:console Thanks Rama, I didn't know that worked on C++ too :-) Thought that was a C# thing :-) Nish
The posting stats are now in PDF:- http://www.busterboy.org/codeproject/ Feel free to make your comments. Updated - May 04th, Saturday
-
Well just go to linker options and add the following line to the command line /subsystem:windows, you will have a windows application with _tmain, or you can also try the reverse with /subsystem:console
Rama Krishna wrote: add the following line to the command line /subsystem:windows, you will have a windows application with _tmain This didnt work on VS .NET academic and VS .NET beta 2. If you use the linker option - /subsystem:windows, it expects to find a WinMain. Nish
The posting stats are now in PDF:- http://www.busterboy.org/codeproject/ Feel free to make your comments. Updated - May 04th, Saturday
-
Rama Krishna wrote: add the following line to the command line /subsystem:windows, you will have a windows application with _tmain This didnt work on VS .NET academic and VS .NET beta 2. If you use the linker option - /subsystem:windows, it expects to find a WinMain. Nish
The posting stats are now in PDF:- http://www.busterboy.org/codeproject/ Feel free to make your comments. Updated - May 04th, Saturday
I have been doing this for quite sometime. Can you mail me the project
-
I have been doing this for quite sometime. Can you mail me the project
There is nothing special needed Rama. Just create a new MC++ project. And #include windows.h The default one would do. Now add /subsystem:windows to the linker command line options. The MC++ program should have only a _tmain() and not a WinMain(). The linker would say that, WinMain is missing. The problem is basically with #including windows.h For normal programs, what you say might work. But for MC++ programs that use IJW, your technique won't work Nish
The posting stats are now in PDF:- http://www.busterboy.org/codeproject/ Feel free to make your comments. Updated - May 04th, Saturday
-
There is nothing special needed Rama. Just create a new MC++ project. And #include windows.h The default one would do. Now add /subsystem:windows to the linker command line options. The MC++ program should have only a _tmain() and not a WinMain(). The linker would say that, WinMain is missing. The problem is basically with #including windows.h For normal programs, what you say might work. But for MC++ programs that use IJW, your technique won't work Nish
The posting stats are now in PDF:- http://www.busterboy.org/codeproject/ Feel free to make your comments. Updated - May 04th, Saturday
I came to office just to check this out:) Just kidding I came here to complete my screen saver. Anyway you are right about /subsystem but the work around for that is to add the following two settings /substem:windows /entry:mainCRTStartup this would fix the problems. I wanted to write an article about compiler and linker settings since the days of CodeGuru but never got a chance.