Closed Thread
Results 1 to 8 of 8

Thread: Simple Window application (Unwanted cmd)

  1. #1
    sakishrist's Avatar
    sakishrist is offline Programmer
    Join Date
    Dec 2007
    Location
    Greece - Syros
    Posts
    109
    Rep Power
    0

    Lightbulb Simple Window application (Unwanted cmd)

    Hello all! Merry Xmas!

    I am new to C++ and I tryed to understund how windows work in this language so I found this code and compiled it. What I can see is that exept the window I get a cmd. How can I remove that? I can not find the code that creates it.

    Thanks! Merry Xmas!

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Oct 2008
    Location
    San Diego
    Posts
    629
    Rep Power
    19

    Re: Simple Window application (Unwanted cmd)

    windows.h creates a new window. Its in the first line of code, the include. You can read more here

    windows.h - Wikipedia, the free encyclopedia

  4. #3
    sakishrist's Avatar
    sakishrist is offline Programmer
    Join Date
    Dec 2007
    Location
    Greece - Syros
    Posts
    109
    Rep Power
    0

    Re: Simple Window application (Unwanted cmd)

    Thanks but ... there is the same thing (windows.h) in a default win32 project of Dev-c++ and no cmd is displayed. Anyways I found why that cmd apears and it is because I had started a cmd project ... but I get more comfused here ... shuldn't it be displayed with some kind of code? What does it make the cmd to apear. sorry for making such questions but I've been programing in vb until now and I just faced some of the dificulties of C++ (all these compilers and the diferences betwen them, the more code etc). But I still want to continue learning it.

  5. #4
    Join Date
    Oct 2008
    Location
    San Diego
    Posts
    629
    Rep Power
    19

    Re: Simple Window application (Unwanted cmd)

    I don't program C++, what I posted earlier is all I know about that, sorry

  6. #5
    TkTech's Avatar
    TkTech is offline The Crazy One
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    1,412
    Blog Entries
    1
    Rep Power
    31

    Re: Simple Window application (Unwanted cmd)

    Its just the entry point on the linker script. When you create a GUI project, it links in some object code that actually sets it up, and sets it as the entry point. That function then calls main(). Use objdump to see the symbols in your project and you'll notice it.

  7. #6
    sakishrist's Avatar
    sakishrist is offline Programmer
    Join Date
    Dec 2007
    Location
    Greece - Syros
    Posts
    109
    Rep Power
    0

    Re: Simple Window application (Unwanted cmd)

    Thanks for the information but as I see I know really just a few things about C++ and I have started trying to learn it. So please, could you give me some links. Or could you explain to me some of the theory of C++? One thing I find difficult to understand is the differences between the compilers. In vb.net there were no/minimal difficulties getting some code from the net and running it. Now that I tried C++ ... EVERY sample that I get has some kind of problem working on dev-cpp. I do not know if that code actually runs on other compilers (so dev-cpp is the problem), if it runs on other computers (so my pc has the problem because it's vista H-P or something). How on earth am I going to learn if I do not have the ability to run some ready code to see what it does? I get some errors that look really stupid on first sight. For example: I got this dialog based code, unzipped it, double-clicked 'main.cpp' and on dev-cpp pressed 'Execute' --> 'Compile & Run' an I got a bunch of stupid errors like
    Code:
    156 C:\Users\sakishrist\Desktop\projects\dialogs\Main.cpp `_set_new_handler' undeclared (first use this function)
    Ok ... I found that line and did not know what to do. OK I do not know nearly any C++ at all but aren’t these samples supposed to help me learn. Sorry if the way I have chosen to learn sounds stupid but it was the best one in VB. I read books about C++ but when I try to go a bit further like I did in VB I get stuck because of some compiling error. I even got an error about something that was undeclared (inside an ‘if’ loop) which was actually declared at the beginning of the code. Am I doing something wrong here?
    Thanks!

  8. #7
    whitey6993's Avatar
    whitey6993 is offline Programming Expert
    Join Date
    Dec 2008
    Posts
    435
    Rep Power
    15

    Re: Simple Window application (Unwanted cmd)

    You may be getting errors in dev-cpp because you are using the wrong project type. If the project type is not a windows application then you need to select console application as your project type. If it is a windows application, you need to select win32 application as your file type. You should probably visit a few tutorial sites or the tutorials in the C++ section of codecall if you are attempting to learn C++. Most of these tutorials will probably use programs that run in the console for examples. Programming a windows application in C++ is a more advanced concept and should only be attempted after learning about classes. You should also check to see if the code you are using as an example was written and compiled in Dev-C++ originally or not. Programs written in Microsoft Visual C++ for example will not run the same in Dev-C++. If you continue to run into compiling errors, you may want to consider switching compilers.

  9. #8
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Simple Window application (Unwanted cmd)

    It also depends on what file extensions you're using. For example, if you put C++ code in a file saved with the .c extension (for example, example.c), the compiler will probably choke and spit out a bunch of errors because it's trying to interpret the C++ code as pure C code. I've had that problem, took me forever to figure it out.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Beginner Assembly, Simple Window (Win32, NASM)
    By RhetoricalRuvim in forum Assembly Tutorials
    Replies: 0
    Last Post: 08-14-2011, 05:26 PM
  2. Create Simple Back Up Application
    By R8ter63 in forum Visual Basic Programming
    Replies: 3
    Last Post: 01-22-2011, 05:03 PM
  3. Simple console application.
    By Psynic in forum CSharp Tutorials
    Replies: 5
    Last Post: 06-01-2009, 10:08 AM
  4. Difficulties with a simple application
    By Viper in forum C and C++
    Replies: 21
    Last Post: 08-20-2006, 08:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts