Win32 Console Application Problem.

This is a discussion on Win32 Console Application Problem. within the C++ Programming forums, part of the General Programming Boards category; Hello, i'm working on a game. i disabled right clicking to actually not be able to modify the buffer size ...

  1. #1
    kevinawad
    Guest

    Win32 Console Application Problem.

    Hello, i'm working on a game. i disabled right clicking to actually not be able to modify the buffer size of the console and more options.

    Now, i got a big problem, people can still click the top left icon to modify some of the cmd options. How is it possible to disable the edit option for cmd?

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,548
    Why do you need to?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    kevinawad
    Guest
    Because i'm making an "Mmorpg".

    Roleplaying online game.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,548
    Quote Originally Posted by kevinawad View Post
    Because i'm making an "Mmorpg".

    Roleplaying online game.
    I don't use those, so I still don't understand why it's that important, but just tell the users not to do it. If they do it anyways, that's their own fault.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #5
    kevinawad
    Guest
    But there is a way to do it... i just need to know how.

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    60
    Try this on for size:
    Code:
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
      char title[500];
      HWND hwnd;
      HMENU hmenu;
    
      // Get the system menu
      GetConsoleTitle( title, 500);
      hwnd = FindWindow( NULL, title);
      hmenu = GetSystemMenu( hwnd, FALSE);
    
      // Remove all its items
      while (DeleteMenu( hmenu, 0, MF_BYPOSITION))
          ;
    
      // Add "Close" back
      AppendMenu( hmenu, MF_STRING, SC_CLOSE, "Close");
    
      printf( "Hello world\n");
      system( "pause");
    }

  7. #7
    kevinawad
    Guest
    Works, thank you so much.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    21,163
    Quote Originally Posted by nucleon View Post
    Code:
      // Get the system menu
      GetConsoleTitle( title, 500);
      hwnd = FindWindow( NULL, title);
    Can be simplified to
    Code:
    hwnd = GetConsoleWindow();
    Code:
      printf( "Hello world\n");
    Avoid using C stuff on the C++ board.

    Code:
      system( "pause");
    Bad bad. Unportable.
    Best option is to let the IDE do the pausing. Otherwise, use cin.get().
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    60
    I thought there was a better way to get the hwnd, but couldn't remember what it was! As for the C, I forgot which board we were on. As for system("pause"), I usually remove that before posting. It works well for me in testing.

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    21,163
    I can imagine the system pause works for you, but since this is a board about portability and such, it is best if you avoid posting non-portable solutions when there is a portable one.
    One day you might even become a great member of this board who teaches newbies good style and portable solutions!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  11. #11
    Registered User
    Join Date
    Oct 2008
    Posts
    60
    I'll try to keep portability and style in mind.
    I doubt I have the patience to be a "great" member.
    I'll just help out!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making a stealthy win32 console application?
    By killdragon in forum C++ Programming
    Replies: 3
    Last Post: 09-08-2004, 02:50 PM
  2. Painting with Tex on a Win32 Application
    By webzest in forum C++ Programming
    Replies: 5
    Last Post: 08-16-2004, 03:04 PM
  3. icon in win32 console application
    By osal in forum Windows Programming
    Replies: 3
    Last Post: 06-30-2004, 02:13 PM
  4. splitting the screen in a Win32 console application
    By watcher_b in forum C Programming
    Replies: 1
    Last Post: 10-19-2002, 05:22 PM
  5. Win32 Console Application...Full Screen?
    By MrWizard in forum C++ Programming
    Replies: 4
    Last Post: 04-01-2002, 01:56 PM

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