source: trunk/ab5.0/ablib/src/api_console.sbp

Last change on this file was 629, checked in by イグトランス (egtra), 16 years ago

Console.Title(取得側)が正しく動かないバグを除去

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