Thread: disabling minimize and mazimize boxes on Microsoft display output

  1. #1
    Registered User Ivory348's Avatar
    Join Date
    Oct 2019
    Posts
    75

    disabling minimize and mazimize boxes on Microsoft display output

    I would like to disable the minimize and maximize boxes on the Microsoft console output, because if you use them running a C console application they cause bugs. It can easily be done running C++ or C#, but there is no information for C on the Internet. You cannot transpose what is shown for C++ and C# because of no information as to the library to be used in C with the code that is shown for C++ and C#.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > because if you use them running a C console application they cause bugs
    So fix the bugs, rather than trying to cover up the evidence and making life hard for your users.

    If they want to press the X in the corner, they should be able to.

    > but there is no information for C on the Internet. You cannot transpose what is shown for C++
    > and C# because of no information as to the library to be used in C with the code that is shown for C++ and C#.
    Which is odd really, because the Win32 API is fundamentally a 'C' API to begin with.

    Don't let the "C++ example" fool you.
    Unless there are specific C++-isms in the example like templates, classes, chances are, it will compile just fine in C (or will be easy to make compile in C).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User Ivory348's Avatar
    Join Date
    Oct 2019
    Posts
    75
    Quote Originally Posted by Salem View Post
    > because if you use them running a C console application they cause bugs
    So fix the bugs, rather than trying to cover up the evidence and making life hard for your users.

    If they want to press the X in the corner, they should be able to.

    > but there is no information for C on the Internet. You cannot transpose what is shown for C++
    > and C# because of no information as to the library to be used in C with the code that is shown for C++ and C#.
    Which is odd really, because the Win32 API is fundamentally a 'C' API to begin with.

    Don't let the "C++ example" fool you.
    Unless there are specific C++-isms in the example like templates, classes, chances are, it will compile just fine in C (or will be easy to make compile in C).
    I didn't say I want to get rid of the x at the top of the output. I want to disable the maximize and minimize buttons of the output frame.

  4. #4
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    Maybe:
    Code:
    void disableMinimizeAndMaximizeButtons(HWND hwnd)
    {
        SetWindowLong(hwnd, GWL_STYLE,
            GetWindowLong(hwnd, GWL_STYLE) & ~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX));
    }
    A little inaccuracy saves tons of explanation. - H.H. Munro

  5. #5
    Registered User Ivory348's Avatar
    Join Date
    Oct 2019
    Posts
    75
    Thank you very much for the code. But I regret to say, it doesn't work. I copy/pasted your code to my application, so there cannot have been any copying errors.

  6. #6
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    Unless you define "doesn't work" there's nothing else I can do.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  7. #7
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    I love the "I copied and pasted it so I can't possibly be at fault" reasoning!
    I assume you found whatever mistake you made.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    So, did you call the function or do you think it will work because programming is magic?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  9. #9
    Registered User Ivory348's Avatar
    Join Date
    Oct 2019
    Posts
    75
    Quote Originally Posted by stahta01 View Post
    So, did you call the function or do you think it will work because programming is magic?

    Tim S.
    If this is your contribution, I am not sure I understand. I tried getting the code to work by making a few changes, however to no avail.

  10. #10
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by Ivory348 View Post
    If this is your contribution, I am not sure I understand. I tried getting the code to work by making a few changes, however to no avail.
    How, specifically, doesn't it work? Simply saying it doesn't work provides no information at all. Many of us probably don't even use Windows so you need to provide specific details regarding how it doesn't work. Did you call the function disableMinimizeAndMaximizeButtons from within your program?

  11. #11
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Do you know what a function is?
    Do you know how to call a function?
    Did you call the disableMinimizeAndMaximizeButtons function?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  12. #12
    Registered User Ivory348's Avatar
    Join Date
    Oct 2019
    Posts
    75
    I don't think I made a mistake trying to implement the function. When the code did not work I tried some changes . Moving the declarations from the parameter list to the body of the function. Changing the function for it to be similar to a function in Basic that I know of, and which does work. Both didn't solve the problem. I was hoping to hear more from you. So to answer your question: no, I did not find any mistake.

  13. #13
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by Ivory348 View Post
    I don't think I made a mistake trying to implement the function. When the code did not work I tried some changes . Moving the declarations from the parameter list to the body of the function. Changing the function for it to be similar to a function in Basic that I know of, and which does work. Both didn't solve the problem. I was hoping to hear more from you. So to answer your question: no, I did not find any mistake.
    I was hoping you'd answer the question. Nobody asked if there was a mistake in the function. The question was, did you call the function?

    Edit: After you answer the question that was asked can you please post your test code (I imagine/hope that it's simply a few includes, the function above, and a small main() with 1 or two lines of code)
    Last edited by Hodor; 12-15-2019 at 05:39 PM.

  14. #14
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Ivory348
    I don't think I made a mistake trying to implement the function.
    Maybe you did. Since you didn't show your code, it is reasonable to suppose that you made a mistake. Show your code.

    Quote Originally Posted by Ivory348
    When the code did not work I tried some changes . Moving the declarations from the parameter list to the body of the function.
    That makes it sound like you didn't actually call the function: surely you cannot just turn the parameter into a local variable because you would need to pass the handle of the current window to the function?

    Quote Originally Posted by Ivory348
    Changing the function for it to be similar to a function in Basic that I know of, and which does work.
    You're being terribly vague. What did you change the C function to? What is the Basic function code?

    So to answer your question: no, I did not find any mistake.
    The question isn't "did you find any mistake?" The question is: "how does it not work"? For example, did you encounter a compile error, and if so, what was the error message? Did you call the function and then find that there was no intended effect, and if so, what is the relevant code?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #15
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    I don't have Windows but looking at the docs the function should, in principle at least, work. How are you getting the value for hwnd?
    We really need to see your test code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 10-25-2019, 05:13 AM
  2. Replies: 0
    Last Post: 10-25-2019, 05:13 AM
  3. Microsoft display
    By zach in forum Windows Programming
    Replies: 1
    Last Post: 09-07-2019, 01:48 PM
  4. LCD 16x2 Display only shows black boxes?
    By ElectronicX in forum C Programming
    Replies: 4
    Last Post: 06-12-2012, 08:17 AM
  5. output file display -- Need Help
    By boostpower in forum C Programming
    Replies: 2
    Last Post: 04-06-2006, 01:50 PM

Tags for this Thread