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.
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:
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:
来源:https://stackoverflow.com/questions/20126202/is-there-a-better-way-to-remove-all-of-the-three-buttons-on-the-title-bar-and-re