How to disable console quick-edit mode

Viewed 298

when I click on a running console it freezes the application till I finish the selection,

I found how to disable it in many languages using "SetConsoleMode" but couldn't find a code for Delphi

1 Answers

This should be straightforward:

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  Windows, System.SysUtils;

const
  ENABLE_QUICK_EDIT_MODE = $40;
  ENABLE_EXTENDED_FLAGS = $80;

var
  h: NativeUInt;
  OldMode: Cardinal;

begin

  h := GetStdHandle(STD_INPUT_HANDLE);
  if not (
    GetConsoleMode(h, OldMode) and
    SetConsoleMode(h, OldMode and not ENABLE_QUICK_EDIT_MODE or ENABLE_EXTENDED_FLAGS)
  )
  then
    RaiseLastOSError;

  // Do stuff

end.
Related