'GetConsoleWindow' doesn't works ??!

This is a discussion on 'GetConsoleWindow' doesn't works ??! within the Windows Programming forums, part of the Platform Specific Boards category; When I try to compile some code I found I always have the following error: f:\ookbij3\days\day08\a.cpp(31) : error C2065: 'GetConsoleWindow' ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    10

    'GetConsoleWindow' doesn't works ??!

    When I try to compile some code I found I always have the following error:

    f:\ookbij3\days\day08\a.cpp(31) : error C2065: 'GetConsoleWindow' : undeclared identifier

    I have
    #include <iostream>
    included (so normally 'GetConsoleWindow' should work)?!?
    greetz

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You need windows.h for GetConsoleWindow.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    10
    thanks for your reply, but I allready tried that and it still doesn't works.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Can you show us your source code please?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    10
    oh.. sorry: here it is:

    Code:
     #include <iostream>
    #include "stdafx.h"
    //#include <practice.h>
    
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    
    // The one and only application object
    
    CWinApp theApp;
    
    using namespace std;
    
    /*input stream handle */
    HANDLE hIn = NULL;
    
    int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
    {
        int nRetCode = 0;
    
        // initialize MFC and print and error on failure
        if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
        {
             // TODO: change error code to suit your needs
             _tprintf(_T("Fatal Error: MFC initialization failed\n"));
             nRetCode = 1;
        }
        else
        {
    		//::
    ShowWindow(GetConsoleWindow(), SW_SHOW);     
         }
    
        return nRetCode;
    }
    project must support MFC.

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227

    Re: 'GetConsoleWindow' doesn't works ??!

    Originally posted by andre123
    When I try to compile some code I found I always have the following error:

    f:\ookbij3\days\day08\a.cpp(31) : error C2065: 'GetConsoleWindow' : undeclared identifier
    Read the remarks section for GetConsoleWindow .
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #7
    Registered User
    Join Date
    Sep 2003
    Posts
    10
    thanks for your reply, but:
    I've putted
    Code:
    #define _WIN32_WINNT 0x0500 
    #include <windows.h>
    and putted #include "stdafx.h"
    on first line, but it STILL doesn't works

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>but it STILL doesn't works<<

    Ah, but at least you won't be getting C2065: 'GetConsoleWindow' : undeclared identifier error messages anymore.

    If you are creating a console application I don't think you should have to use ShowWindow to get it to appear. However, you can always test the return value of GetConsoleWindow which will be NULL if the function fails (no point in doing anything with it then other than reporting an error, perhaps).

    There is an example on this page on msdn that may be able to help you out. Other than specifying compiler switches it #includes <afx.h> which your example doesn't seem to do.

    Sorry I can't be of more help but I don't really speak mfc.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    Registered User
    Join Date
    Sep 2003
    Posts
    10
    Ah, but at least you won't be getting C2065: 'GetConsoleWindow' : undeclared identifier error messages anymore
    err.. no, I mean I still have the error.
    I checked MSDN, but still sisn't managed into getting it to work.

  10. #10
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Open up wincon.h and do a search for GetConsoleWindow. If you don't have the function declared in that header file (which now seems likely; it's missing in my 'from the box' msvc6 wincon.h) then you'll need to get an updated version - download the latest psdk from microsoft to get that.

    edit: typos
    Last edited by Ken Fitlike; 09-08-2003 at 10:36 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  11. #11
    Registered User
    Join Date
    Sep 2003
    Posts
    10
    Thanks for your reply, I'll check it as soon as I'm home.

  12. #12
    Registered User
    Join Date
    Sep 2003
    Posts
    10
    yes. thanks. It works now.
    greetz

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can anybody show me why this works??
    By tzuch in forum C Programming
    Replies: 2
    Last Post: 03-29-2008, 10:03 AM
  2. explanation of how this works
    By c++.prog.newbie in forum Linux Programming
    Replies: 3
    Last Post: 09-27-2004, 06:59 PM
  3. Works in MSVC++ 6.0 but not in Dev-C++
    By smitsky in forum C++ Programming
    Replies: 1
    Last Post: 05-30-2004, 09:07 PM
  4. fprintf works in one function but not in the other.
    By smegly in forum C Programming
    Replies: 11
    Last Post: 05-25-2004, 04:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21