2

The code removing all of the three buttons on the title-bar and removing the scroll-bar I use in "Windows 7" so far is listed:

#define WINVER 0x0501 // WinXP and UP
#include <windows.h>

int main ( void ) 
{
     //Get a console handle
     HWND ConsoleWindow = GetConsoleWindow();

     //Change Settings
     SetWindowLong (ConsoleWindow, GWL_STYLE, WS_THICKFRAME);
     SetWindowLong (ConsoleWindow, GWL_STYLE, WS_CAPTION);
     SetWindowPos  (ConsoleWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_SHOWWINDOW);

     //Resize
     system ("mode con cols=75 lines=50");
     system ("pause>nul");
     return 0;
}

Compiling Command:

mingw32-gcc.exe -c "Console_Graphing_10.c" -o "Console_Graphing_10.o"
mingw32-gcc.exe -o "Console_Graphing_10.exe"  "Console_Graphing_10.o"

But this cannot remove all of the three buttons on the title-bar and remove the scroll-bar in "Windows XP"

Is there any better code to achieve this goal? Thanks.

Kevin Dong
  • 5,001
  • 9
  • 29
  • 62

2 Answers2

1

You can try this:

#define WINVER 0x0501 // WinXP and UP
#include <windows.h>

int main ( void ) 
{
  LONG style;
  HWND ConsoleWindow;

  ConsoleWindow = GetConsoleWindow();

  style = GetWindowLong(ConsoleWindow, GWL_STYLE); 
  style &= ~( WS_MINIMIZEBOX | WS_SYSMENU ); 
  SetWindowLongPtr(ConsoleWindow, GWL_STYLE, style);

  SetWindowPos(ConsoleWindow, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED |
  SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);

  system ("pause>nul");
  return 0;
}

all buttons will be removed:

enter image description here

1

I found This after my comment saying I thought it was not possible...

void ClearButtons(void)
{
    int index = WS_BORDER;
    unsigned int a = (unsigned int)((WS_BORDER | WS_CAPTION) & (~WS_ICONIC));

    LONG_PTR lPtr;
    HWND hWnd = GetActiveWindow();
    lPtr = GetWindowLongPtr(hWnd, index); 
    SetWindowLongPtr(hWnd, GWL_STYLE, a);  
}

Note: When compiling for 32-bit Windows, SetWindowLongPtr is defined as a call to the SetWindowLong function. So, should work with either Windows 7, or with XP (did not test)

Test image:
enter image description here

ryyker
  • 22,849
  • 3
  • 43
  • 87
  • THX, BUT MSVC? I tagged **GCC**. – Kevin Dong Nov 21 '13 at 18:10
  • I do not think it would matter. If you are using Windows OS (i.e. creating and modifying panels on Windows 7) all you have to do in include the right #includes, and libs. GCC will compile and build. No? I #included `#include ` and `#include ansi_c.h>` And, no, I am NOT using MSVC. I am using standard Windows API stuff from ***[HERE](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644898%28v=vs.85%29.aspx)*** – ryyker Nov 21 '13 at 18:16
  • Regarding _It didn't work on my GCC Compiler, so sad_. If you include User32.lib, User32.dll and Winuser.h, it will build. (and probably clear the buttons) – ryyker Nov 21 '13 at 18:21
  • THX. Well... I added `#include `, but still got failed in `WinXP`. – Kevin Dong Nov 21 '13 at 18:21
  • Great. But it works perfectly on Win7, but not effective on WinXP. :( – Kevin Dong Nov 21 '13 at 18:30
  • @KVD - Even after adding in the ***User32.lib*** and ***Winuser.h***? – ryyker Nov 21 '13 at 18:33
  • YES... I have added those. – Kevin Dong Nov 21 '13 at 18:35
  • Okay, well, I am very sorry that I do not have an XP box to go any further. Thanks for the good question though! +1 from me. (Good luck) – ryyker Nov 21 '13 at 18:37