Forum > General

How to hide window buttons (Minimize, Maximize and Close) in a Windows app

<< < (2/5) > >>

tr_escape:
@Getmem :

I have to ask to ChatGPT ;)

balazsszekely:
@tr_escape


--- Quote ---I have to as ChatGPT ;)
--- End quote ---
What is ChatGPT? According to google is an Open AI. Where do you ask questions?

tr_escape:
Yes absolutly:

The answer is:

Me:
How can I deny to close console app in the console mode?

GPT:
To prevent a console application from being closed in the console mode in Windows, you can use the SetConsoleCtrlHandler function from the Windows unit. This function allows you to register a callback function that is called when the user attempts to close the console window using the Ctrl+C or Ctrl+Break key combinations.

Here is an example of how to use the SetConsoleCtrlHandler function to prevent a console application from being closed:

Copy code

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses Windows; var  PrevHandler: PHandlerRoutine;  // Pointer to the previous handler routine // Callback function that is called when the user attempts to close the consolefunction ConsoleCtrlHandler(CtrlType: DWORD): BOOL; stdcall;begin  // Do not allow the console to be closed  Result := True;end; begin  // Register the callback function  SetConsoleCtrlHandler(@ConsoleCtrlHandler, True, PrevHandler);   // Run the main program logic here   // Unregister the callback function when the program is finished  SetConsoleCtrlHandler(PrevHandler, False);end;This code will register the ConsoleCtrlHandler function as a callback that is called when the user attempts to close the console window using the Ctrl+C or Ctrl+Break key combinations. The ConsoleCtrlHandler function simply returns True, which prevents the console from being closed. When the program is finished, the callback function is unregistered using the SetConsoleCtrlHandler function.

Note that you must include the Windows unit in your code in order to use the SetConsoleCtrlHandler function. You can do this by adding the following line at the top of your code:

Copy code

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses Windows; This will allow you to use the SetConsoleCtrlHandler function in your code.

Keep in mind that using the SetConsoleCtrlHandler function to prevent a console application from being closed is a low-level operation and should be used with caution. It can have unintended side effects, and it may not be portable to other operating systems. It is generally recommended to use the built-in methods and properties of the Lazarus/Free Pascal language to manipulate the console window, if possible.

tr_escape:

--- Quote from: GetMem on December 07, 2022, 01:00:18 pm ---@tr_escape


--- Quote ---I have to as ChatGPT ;)
--- End quote ---
What is ChatGPT? According to google is an Open AI. Where do you ask questions?

--- End quote ---

https://chat.openai.com/chat

You have to register by email

balazsszekely:

--- Quote ---https://chat.openai.com/chat

You have to register by email
--- End quote ---
Thank you!


--- Quote ---GPT:
To prevent a console application from being closed in the console mode in Windows, you can use the SetConsoleCtrlHandler function from the Windows unit. This function allows you to register a callback function that is called when the user attempts to close the console window using the Ctrl+C or Ctrl+Break key combinations.

--- End quote ---
Interesting.

PS: Before I register, please ask him if he knows the solution to the Riemann hypothesis.  :D

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version