[1] | 1 | 'api_console.sbp
|
---|
| 2 |
|
---|
| 3 | #ifndef _INC_CONSOLE
|
---|
| 4 | #define _INC_CONSOLE
|
---|
| 5 |
|
---|
[119] | 6 | Type COORD
|
---|
| 7 | X As Integer
|
---|
| 8 | Y As Integer
|
---|
| 9 | End Type
|
---|
[122] | 10 | TypeDef PCOORD = *COORD
|
---|
[1] | 11 |
|
---|
[122] | 12 | Type SMALL_RECT
|
---|
| 13 | Left As Integer
|
---|
| 14 | Top As Integer
|
---|
| 15 | Right As Integer
|
---|
| 16 | Bottom As Integer
|
---|
| 17 | End Type
|
---|
| 18 | TypeDef PSMALL_RECT = *SMALL_RECT
|
---|
[1] | 19 |
|
---|
[122] | 20 | Type KEY_EVENT_RECORD
|
---|
| 21 | bKeyDown As BOOL
|
---|
| 22 | wRepeatCount As Word
|
---|
| 23 | wVirtualKeyCode As Word
|
---|
| 24 | wVirtualScanCode As Word
|
---|
| 25 | uChar As WCHAR
|
---|
| 26 | dwControlKeyState As DWord
|
---|
| 27 | End Type
|
---|
| 28 | TypeDef PKEY_EVENT_RECORD = *KEY_EVENT_RECORD
|
---|
| 29 |
|
---|
| 30 | Const RIGHT_ALT_PRESSED = &H0001
|
---|
| 31 | Const LEFT_ALT_PRESSED = &H0002
|
---|
| 32 | Const RIGHT_CTRL_PRESSED = &H0004
|
---|
| 33 | Const LEFT_CTRL_PRESSED = &H0008
|
---|
| 34 | Const SHIFT_PRESSED = &H0010
|
---|
| 35 | Const NUMLOCK_ON = &H0020
|
---|
| 36 | Const SCROLLLOCK_ON = &H0040
|
---|
| 37 | Const CAPSLOCK_ON = &H0080
|
---|
| 38 | Const ENHANCED_KEY = &H0100
|
---|
| 39 | Const NLS_DBCSCHAR = &H00010000
|
---|
| 40 | Const NLS_ALPHANUMERIC = &H00000000
|
---|
| 41 | Const NLS_KATAKANA = &H00020000
|
---|
| 42 | Const NLS_HIRAGANA = &H00040000
|
---|
| 43 | Const NLS_ROMAN = &H00400000
|
---|
| 44 | Const NLS_IME_CONVERSION = &H00800000
|
---|
| 45 | Const NLS_IME_DISABLE = &H20000000
|
---|
| 46 |
|
---|
| 47 | Type MOUSE_EVENT_RECORD
|
---|
| 48 | dwMousePosition As COORD
|
---|
| 49 | dwButtonState As DWord
|
---|
| 50 | dwControlKeyState As DWord
|
---|
| 51 | dwEventFlags As DWord
|
---|
| 52 | End Type
|
---|
| 53 | TypeDef PMOUSE_EVENT_RECORD = *MOUSE_EVENT_RECORD
|
---|
| 54 |
|
---|
| 55 | Const FROM_LEFT_1ST_BUTTON_PRESSED = &H0001
|
---|
| 56 | Const RIGHTMOST_BUTTON_PRESSED = &H0002
|
---|
| 57 | Const FROM_LEFT_2ND_BUTTON_PRESSED = &H0004
|
---|
| 58 | Const FROM_LEFT_3RD_BUTTON_PRESSED = &H0008
|
---|
| 59 | Const FROM_LEFT_4TH_BUTTON_PRESSED = &H0010
|
---|
| 60 |
|
---|
| 61 | Const MOUSE_MOVED = &H0001
|
---|
| 62 | Const DOUBLE_CLICK = &H0002
|
---|
| 63 | Const MOUSE_WHEELED = &H0004
|
---|
| 64 |
|
---|
| 65 | Type WINDOW_BUFFER_SIZE_RECORD
|
---|
| 66 | dwSize As COORD
|
---|
| 67 | End Type
|
---|
| 68 | TypeDef PWINDOW_BUFFER_SIZE_RECORD = *WINDOW_BUFFER_SIZE_RECORD
|
---|
| 69 |
|
---|
| 70 | Type MENU_EVENT_RECORD
|
---|
| 71 | dwCommandId As DWord
|
---|
| 72 | End Type
|
---|
| 73 | TypeDef PMENU_EVENT_RECORD = *MENU_EVENT_RECORD
|
---|
| 74 |
|
---|
| 75 | Type FOCUS_EVENT_RECORD
|
---|
| 76 | bSetFocus As BOOL
|
---|
| 77 | End Type
|
---|
| 78 | TypeDef PFOCUS_EVENT_RECORD = *FOCUS_EVENT_RECORD
|
---|
| 79 |
|
---|
| 80 | Type INPUT_RECORD
|
---|
| 81 | EventType As Word
|
---|
| 82 | ' Union Event
|
---|
| 83 | KeyEvent As KEY_EVENT_RECORD
|
---|
| 84 | ' MouseEvent As MOUSE_EVENT_RECORD
|
---|
| 85 | ' WindowBufferSizeEvent As WINDOW_BUFFER_SIZE_RECORD
|
---|
| 86 | ' MenuEvent As MENU_EVENT_RECORD
|
---|
| 87 | ' FocusEvent As FOCUS_EVENT_RECORD
|
---|
| 88 | ' End Union
|
---|
| 89 | End Type
|
---|
| 90 | TypeDef PINPUT_RECORD = *INPUT_RECORD
|
---|
| 91 |
|
---|
| 92 | Const KEY_EVENT = &H0001
|
---|
| 93 | Const MOUSE_EVENT = &H0002
|
---|
| 94 | Const WINDOW_BUFFER_SIZE_EVENT = &H0004
|
---|
| 95 | Const MENU_EVENT = &H0008
|
---|
| 96 | Const FOCUS_EVENT = &H0010
|
---|
| 97 |
|
---|
| 98 | Type CHAR_INFO
|
---|
| 99 | ' Union Char
|
---|
[141] | 100 | ' UnicodeChar As WCHAR
|
---|
[122] | 101 | AsciiChar[1] As SByte
|
---|
| 102 | ' End Union
|
---|
| 103 | Attributes As Word
|
---|
| 104 | End Type
|
---|
| 105 | TypeDef PCHAR_INFO = *CHAR_INFO
|
---|
| 106 |
|
---|
| 107 | Const FOREGROUND_BLUE = &H0001
|
---|
| 108 | Const FOREGROUND_GREEN = &H0002
|
---|
| 109 | Const FOREGROUND_RED = &H0004
|
---|
| 110 | Const FOREGROUND_INTENSITY = &H0008
|
---|
| 111 | Const BACKGROUND_BLUE = &H0010
|
---|
| 112 | Const BACKGROUND_GREEN = &H0020
|
---|
| 113 | Const BACKGROUND_RED = &H0040
|
---|
| 114 | Const BACKGROUND_INTENSITY = &H0080
|
---|
| 115 | Const COMMON_LVB_LEADING_BYTE = &H0100
|
---|
| 116 | Const COMMON_LVB_TRAILING_BYTE = &H0200
|
---|
| 117 | Const COMMON_LVB_GRID_HORIZONTAL = &H0400
|
---|
| 118 | Const COMMON_LVB_GRID_LVERTICAL = &H0800
|
---|
| 119 | Const COMMON_LVB_GRID_RVERTICAL = &H1000
|
---|
| 120 | Const COMMON_LVB_REVERSE_VIDEO = &H4000
|
---|
| 121 | Const COMMON_LVB_UNDERSCORE = &H8000
|
---|
| 122 | Const COMMON_LVB_SBCSDBCS = &H0300
|
---|
| 123 |
|
---|
| 124 | Type CONSOLE_SCREEN_BUFFER_INFO
|
---|
| 125 | dwSize As COORD
|
---|
| 126 | dwCursorPosition As COORD
|
---|
| 127 | wAttributes As Word
|
---|
| 128 | srWindow As SMALL_RECT
|
---|
| 129 | dwMaximumWindowSize As COORD
|
---|
| 130 | End Type
|
---|
| 131 | TypeDef PCONSOLE_SCREEN_BUFFER_INFO = *CONSOLE_SCREEN_BUFFER_INFO
|
---|
| 132 |
|
---|
| 133 | Type CONSOLE_CURSOR_INFO
|
---|
| 134 | dwSize As DWord
|
---|
| 135 | bVisible As BOOL
|
---|
| 136 | End Type
|
---|
| 137 | TypeDef PCONSOLE_CURSOR_INFO = *CONSOLE_CURSOR_INFO
|
---|
| 138 |
|
---|
| 139 | TypeDef PHANDLER_ROUTINE = *Function(CtrlType As DWord) As BOOL
|
---|
| 140 |
|
---|
| 141 | Const CTRL_C_EVENT = 0
|
---|
| 142 | Const CTRL_BREAK_EVENT = 1
|
---|
| 143 | Const CTRL_CLOSE_EVENT = 2
|
---|
| 144 | Const CTRL_LOGOFF_EVENT = 5
|
---|
| 145 | Const CTRL_SHUTDOWN_EVENT = 6
|
---|
| 146 |
|
---|
| 147 | Const ENABLE_PROCESSED_INPUT = &H0001
|
---|
| 148 | Const ENABLE_LINE_INPUT = &H0002
|
---|
| 149 | Const ENABLE_ECHO_INPUT = &H0004
|
---|
| 150 | Const ENABLE_WINDOW_INPUT = &H0008
|
---|
| 151 | Const ENABLE_MOUSE_INPUT = &H0010
|
---|
| 152 | Const ENABLE_PROCESSED_OUTPUT = &H0001
|
---|
| 153 | Const ENABLE_WRAP_AT_EOL_OUTPUT = &H0002
|
---|
| 154 |
|
---|
| 155 | Declare Function PeekConsoleInput Lib "kernel32" Alias "PeekConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
|
---|
| 156 | Declare Function ReadConsoleInput Lib "kernel32" Alias "ReadConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
|
---|
| 157 | Declare Function WriteConsoleInput Lib "kernel32" Alias "WriteConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsWritten As DWord) As BOOL
|
---|
| 158 | Declare Function ReadConsoleOutput Lib "kernel32" Alias "ReadConsoleOutputA" (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpReadRegion As SMALL_RECT) As BOOL
|
---|
| 159 | Declare Function WriteConsoleOutput Lib "kernel32" Alias "WriteConsoleOutputA" (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpWriteRegion As SMALL_RECT) As BOOL
|
---|
| 160 | Declare Function ReadConsoleOutputCharacter Lib "kernel32" Alias "ReadConsoleOutputCharacterA" (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfCharsRead As DWord) As BOOL
|
---|
| 161 | Declare Function ReadConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfAttrsRead As DWord) As BOOL
|
---|
| 162 | Declare Function WriteConsoleOutputCharacter Lib "kernel32" Alias "WriteConsoleOutputCharacterA" (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
|
---|
| 163 | Declare Function WriteConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
|
---|
| 164 | Declare Function FillConsoleOutputCharacter Lib "kernel32" Alias "FillConsoleOutputCharacterA" (hConsoleOutput As HANDLE, cCharacter As Char, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
|
---|
| 165 | Declare Function FillConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttribute As Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
|
---|
| 166 | Declare Function GetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, ByRef lpMode As DWord) As BOOL
|
---|
| 167 | Declare Function GetNumberOfConsoleInputEvents Lib "kernel32" (hConsoleInput As HANDLE, ByRef lpNumberOfEvents As DWord) As BOOL
|
---|
| 168 | Declare Function GetConsoleScreenBufferInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleScreenBufferInfo As CONSOLE_SCREEN_BUFFER_INFO) As BOOL
|
---|
| 169 | Declare Function GetLargestConsoleWindowSize Lib "kernel32" (hConsoleOutput As HANDLE) As DWord
|
---|
| 170 | Declare Function GetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
|
---|
| 171 | Declare Function GetNumberOfConsoleMouseButtons Lib "kernel32" (ByRef lpNumberOfMouseButtons As DWord) As BOOL
|
---|
| 172 | Declare Function SetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, dwMode As DWord) As BOOL
|
---|
| 173 | Declare Function SetConsoleActiveScreenBuffer Lib "kernel32" (hConsoleOutput As HANDLE) As BOOL
|
---|
| 174 | Declare Function FlushConsoleInputBuffer Lib "kernel32" (hConsoleInput As HANDLE) As BOOL
|
---|
| 175 | Declare Function SetConsoleScreenBufferSize Lib "kernel32" (hConsoleOutput As HANDLE, dwSize As DWord) As BOOL
|
---|
| 176 | Declare Function SetConsoleCursorPosition Lib "kernel32" (hConsoleOutput As HANDLE, dwCursorPosition As DWord) As BOOL
|
---|
| 177 | Declare Function SetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
|
---|
| 178 | Declare Function ScrollConsoleScreenBuffer Lib "kernel32" Alias "ScrollConsoleScreenBufferA" (hConsoleOutput As HANDLE, ByRef lpScrollRectangle As SMALL_RECT, lpClipRectangle As *SMALL_RECT, ByRef dwDestinationOrigin As COORD, lpFill As *CHAR_INFO) As BOOL
|
---|
| 179 | Declare Function SetConsoleWindowInfo Lib "kernel32" (hConsoleOutput As HANDLE, bAbsolute As BOOL, ByRef lpConsoleWindow As SMALL_RECT) As BOOL
|
---|
| 180 | Declare Function SetConsoleTextAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttributes As Word) As BOOL
|
---|
| 181 | Declare Function SetConsoleCtrlHandler Lib "kernel32" (HandlerRoutine As PHANDLER_ROUTINE, Add As BOOL) As BOOL
|
---|
| 182 | Declare Function GenerateConsoleCtrlEvent Lib "kernel32" (dwCtrlEvent As DWord, dwProcessGroupId As DWord) As BOOL
|
---|
[119] | 183 | Declare Function AllocConsole Lib "kernel32" () As BOOL
|
---|
| 184 | Declare Function FreeConsole Lib "kernel32" () As BOOL
|
---|
[122] | 185 | Declare Function GetConsoleTitle Lib "kernel32" Alias "GetConsoleTitleA" (lpConsoleTitle As LPSTR, nSize As DWord) As DWord
|
---|
| 186 | Declare Function SetConsoleTitle Lib "kernel32" Alias "SetConsoleTitleA" (lpConsoleTitle As LPSTR) As BOOL
|
---|
| 187 | Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (hConsoleInput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToRead As DWord, ByRef lpNumberOfCharsRead As DWord, lpReserved As VoidPtr) As BOOL
|
---|
| 188 | Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (hConsoleOutput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToWrite As DWord, ByRef lpNumberOfCharsWritten As DWord, lpReserved As VoidPtr) As BOOL
|
---|
[1] | 189 |
|
---|
[122] | 190 | Const CONSOLE_TEXTMODE_BUFFER = 1
|
---|
[119] | 191 |
|
---|
[122] | 192 | Declare Function CreateConsoleScreenBuffer Lib "kernel32" (dwDesiredAccess As DWord, dwShareMode As DWord, lpSecurityAttributes As *SECURITY_ATTRIBUTES, dwFlags As DWord, lpScreenBufferData As VoidPtr) As HANDLE
|
---|
| 193 | Declare Function GetConsoleCP Lib "kernel32" () As DWord
|
---|
| 194 | Declare Function SetConsoleCP Lib "kernel32" (wCodePageID As DWord) As BOOL
|
---|
| 195 | Declare Function GetConsoleOutputCP Lib "kernel32" () As DWord
|
---|
| 196 | Declare Function SetConsoleOutputCP Lib "kernel32" (wCodePageID As DWord) As BOOL
|
---|
[1] | 197 |
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | #endif '_INC_CONSOLE
|
---|