Thread: DOS window behind the actual window

  1. #1
    Registered User
    Join Date
    Jul 2004

    DOS window behind the actual window

    I went through theForger's tutorial for Win32 API and learned alot :]

    The thing that confuses me is why does the dos window always appear behind the window created? Can I make it go away, or at least make it seem like it has?

  2. #2
    Registered User Xzyx987X's Avatar
    Join Date
    Sep 2003
    I'm guessing this is because you're using regular main instead of WinMain. By doing this your program becomes a console application instead of a window based application. To fix this just use WinMain instead of main (you can find documentation for WinMain on MSDN.) Depending on your compiler you may also have to set some additional option to get things working right.

  3. #3
    Registered User
    Join Date
    Jul 2004
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)

    it's already in there... just for quick reference here's the code straight from the tutorial: SimpleWindow

    I appreciate the help though :]

  4. #4
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    You shouldn't have a DOS/console window.

    Which compiler are you using and what project have you created?

  5. #5
    Registered User
    Join Date
    Jul 2004
    I'm using bloodshed's Dev-C++, and project I created?

    I didn't originally create a project for it, but now that I did it works fine, don't know why though :x

    thanks :]

  6. #6
    Join Date
    Jan 2002
    Check your compiler/linker settings - there'll be some extra/omitted switch that you need to remove/set or object to link with. These are different for different compilers. The extra console is handy for outputting debugging information so I wouldn't be in such a great hurry to get rid of it unless your application is ready for 'release'.

    For example, if you compile your example code with MinGW (which devcpp uses) with -mwindows linker option then you'll get no console (it ensures all necessary winapi libs are properly linked). If you compile the same code without that linker switch and instead explicity link with the required windows libs (usually kernel32, advapi32 and gdi32) then you'll get both a console and a winapi gui window.

    Borland compilers are different again; I think there's a gui object (c0w32.obj?) that must be linked to sidestep the extra console issue - but don't quote me on that.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #7
    Registered User Rare177's Avatar
    Join Date
    May 2004
    im not sure with devcpp but with vc++6 and lcc-win32, if you choose your project type to not be win32 application then it has the console, but if you choose win32 application then it should work fine and there shouldnt be a console window

    as i said im not to sure with devcpp and what it uses to create a win32 application.

    good luck
    Good Help Source all round
    Good help for win programmers
    you will probably find something in here
    this thing also helps

    if you have never tried any of the above then maybe you should, they help alot

  8. #8
    Registered User
    Join Date
    Sep 2004
    The linker option for MS Visual C is '/subsystem:console' or '/subsystem:windows' .

    It can be set in Project - Settings - Link - Project Options.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How make platform from DOS to window?
    By Yumin in forum C++ Programming
    Replies: 12
    Last Post: 01-27-2006, 01:16 AM
  2. Window scrollbar
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 10-07-2005, 12:31 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Scrollbar In Dos Window
    By speve in forum A Brief History of
    Replies: 2
    Last Post: 12-17-2001, 08:12 PM
  5. DOS window
    By speve in forum C Programming
    Replies: 1
    Last Post: 12-17-2001, 05:42 AM