• 0

[C] Disable console buttons


Question

I'd like to know if is possible to disable some console window buttons, i.e minimize and maximize. Does exists an API which allows me to do that?

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

You would first have to somehow obtain an HWND to your console window(s). You could probably use FindWindow(Ex). Then you have to set window style to exclude the maximized style). I would give specific functions but my computer is down atm :(

Link to comment
Share on other sites

  • 0

I have no problem to obtain an HWND :)

Anyway, I already checked the SetConsoleMode, but I didn't found anything.

I'll try to find out something else.

Thanks :)

Link to comment
Share on other sites

  • 0

What you would use is SetWindowLong (or SetWindowLongPtr), with GWL_STYLE as the nIndex (2nd) parameter.

ex:

SetWindowLong(hWnd, GWL_STYLE, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);

Those are all the styles used in WS_OVERLAPPEDWINDOW, which is mostly commonly used when creating a window, minus the minimize button and maximize button styles.

Link to comment
Share on other sites

  • 0

Doesn't SetWindowLong have effect on normal windows (like when you open a folder)?

I thought it doesn't have effect on console windows

Anyway, I've solved in this way:

sm = GetSystemMenu(hWnd, FALSE);

RemoveMenu(sm, 4, MF_BYPOSITION); //disable Maximize

RemoveMenu(sm, 3, MF_BYPOSITION); //disabile Minimize

Link to comment
Share on other sites

  • 0
Doesn't SetWindowLong have effect on normal windows (like when you open a folder)?

I thought it doesn't have effect on console windows

Anyway, I've solved in this way:

sm = GetSystemMenu(hWnd, FALSE);

RemoveMenu(sm, 4, MF_BYPOSITION); //disable Maximize

RemoveMenu(sm, 3, MF_BYPOSITION); //disabile Minimize

The console is just another window.. I see no reason why it wouldn't work.

And doesn't your code only remove the menu items?

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.