1 | 'prompt.sbp
|
---|
2 |
|
---|
3 |
|
---|
4 | #ifndef _INC_PROMPT
|
---|
5 | #define _INC_PROMPT
|
---|
6 |
|
---|
7 |
|
---|
8 | #include <api_imm.sbp>
|
---|
9 |
|
---|
10 | Dim _PromptSys_hWnd As HWND
|
---|
11 | Dim _PromptSys_dwThreadID As DWord
|
---|
12 | Dim _PromptSys_bInitFinish As BOOL
|
---|
13 |
|
---|
14 | 'text
|
---|
15 | Dim _PromptSys_LogFont As LOGFONTA 'LOGFONT
|
---|
16 | Dim _PromptSys_hFont As HFONT
|
---|
17 | Dim _PromptSys_FontSize As SIZE
|
---|
18 | Dim _PromptSys_InputStr[255] As Char
|
---|
19 | Dim _PromptSys_InputLen As Long
|
---|
20 | Dim _PromptSys_KeyChar As Byte
|
---|
21 | Dim _PromptSys_CurPos As POINTAPI
|
---|
22 | Dim _PromptSys_Buffer[100] As *Char
|
---|
23 | Dim _PromptSys_TextColor[100] As *COLORREF
|
---|
24 | Dim _PromptSys_BackColor[100] As *COLORREF
|
---|
25 | Dim _PromptSys_NowTextColor As COLORREF
|
---|
26 | Dim _PromptSys_NowBackColor As COLORREF
|
---|
27 | Dim _PromptSys_SectionOfBufferAccess As CRITICAL_SECTION
|
---|
28 |
|
---|
29 |
|
---|
30 | _PromptSys_InputLen=-1
|
---|
31 |
|
---|
32 | 'graphic
|
---|
33 | Dim _PromptSys_hBitmap As HBITMAP
|
---|
34 | Dim _PromptSys_hMemDC As HDC
|
---|
35 | Dim _PromptSys_ScreenSize As SIZE
|
---|
36 | Dim _PromptSys_GlobalPos As POINTAPI
|
---|
37 |
|
---|
38 |
|
---|
39 | _PromptSys_bInitFinish=0
|
---|
40 | CreateThread(0, 0, AddressOf(PromptMain) As LPTHREAD_START_ROUTINE, 0, 0, _PromptSys_dwThreadID)
|
---|
41 | Do
|
---|
42 | Sleep(20)
|
---|
43 | Loop Until _PromptSys_bInitFinish
|
---|
44 |
|
---|
45 | Sub DrawPromptBuffer(hDC As HDC, StartLine As Long, EndLine As Long)
|
---|
46 | Dim i As Long, i2 As Long, i3 As Long
|
---|
47 | Dim sz As SIZE
|
---|
48 | Dim temporary[2] As Char
|
---|
49 |
|
---|
50 | Dim hOldFont = SelectObject(hDC, _PromptSys_hFont) As HFONT
|
---|
51 |
|
---|
52 | 'Scroll
|
---|
53 | Dim rc As RECT
|
---|
54 | GetClientRect(_PromptSys_hWnd, rc)
|
---|
55 | While (_PromptSys_CurPos.y+1)*_PromptSys_FontSize.cy>rc.bottom and _PromptSys_CurPos.y>0
|
---|
56 | _System_free(_PromptSys_Buffer[0])
|
---|
57 | _System_free(_PromptSys_TextColor[0])
|
---|
58 | _System_free(_PromptSys_BackColor[0])
|
---|
59 | For i=0 To 100-1
|
---|
60 | _PromptSys_Buffer[i] = _PromptSys_Buffer[i+1]
|
---|
61 | _PromptSys_TextColor[i] = _PromptSys_TextColor[i+1]
|
---|
62 | _PromptSys_BackColor[i] = _PromptSys_BackColor[i+1]
|
---|
63 | Next
|
---|
64 | _PromptSys_Buffer[100] = _System_calloc(SizeOf (Char) * 255)
|
---|
65 | _PromptSys_TextColor[100] = _System_calloc(SizeOf(COLORREF) * 255)
|
---|
66 | _PromptSys_BackColor[100] = _System_calloc(SizeOf(COLORREF) * 255)
|
---|
67 |
|
---|
68 | _PromptSys_CurPos.y--
|
---|
69 |
|
---|
70 | 'Redraw
|
---|
71 | StartLine=-1
|
---|
72 | Wend
|
---|
73 |
|
---|
74 | i=0
|
---|
75 | While i*_PromptSys_FontSize.cy<rc.bottom and i<=100
|
---|
76 | If StartLine=-1 or (StartLine<=i and i<=EndLine) Then
|
---|
77 | i3 = lstrlen(_PromptSys_Buffer[i])
|
---|
78 | GetTextExtentPoint32(hDC, _PromptSys_Buffer[i], i3, sz)
|
---|
79 |
|
---|
80 | BitBlt(hDC,_
|
---|
81 | sz.cx, i*_PromptSys_FontSize.cy, _
|
---|
82 | rc.right, _PromptSys_FontSize.cy, _
|
---|
83 | _PromptSys_hMemDC,sz.cx,i*_PromptSys_FontSize.cy,SRCCOPY)
|
---|
84 |
|
---|
85 | For i2 = 0 To i3-1
|
---|
86 | SetTextColor(hDC, _PromptSys_TextColor[i][i2])
|
---|
87 | If _PromptSys_BackColor[i][i2] = -1 Then
|
---|
88 | SetBkMode(hDC, TRANSPARENT)
|
---|
89 | Else
|
---|
90 | SetBkMode(hDC, OPAQUE)
|
---|
91 | SetBkColor(hDC, _PromptSys_BackColor[i][i2])
|
---|
92 | End If
|
---|
93 |
|
---|
94 | Dim tempLen As Long
|
---|
95 | temporary[0]=_PromptSys_Buffer[i][i2]
|
---|
96 | #ifdef UNICODE
|
---|
97 | If _System_IsSurrogatePair(_PromptSys_Buffer[i][i2], _PromptSys_Buffer[i][i2+1]) Then
|
---|
98 | #else
|
---|
99 | If IsDBCSLeadByte(temporary[0]) Then
|
---|
100 | #endif
|
---|
101 | temporary[1] = _PromptSys_Buffer[i][i2+1]
|
---|
102 | temporary[2] = 0
|
---|
103 | i2++
|
---|
104 | tempLen = 2
|
---|
105 | Else
|
---|
106 | temporary[1] = 0
|
---|
107 | tempLen = 1
|
---|
108 | End If
|
---|
109 | With _PromptSys_FontSize
|
---|
110 | TextOut(hDC, i2 * .cx, i * .cy, temporary, tempLen)
|
---|
111 | End With
|
---|
112 | Next
|
---|
113 | End If
|
---|
114 |
|
---|
115 | i++
|
---|
116 | Wend
|
---|
117 |
|
---|
118 | SelectObject(hDC, hOldFont)
|
---|
119 | End Sub
|
---|
120 |
|
---|
121 | Sub PRINT_ToPrompt(buf As String)
|
---|
122 | EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
123 | With _PromptSys_CurPos
|
---|
124 | Dim StartLine As Long
|
---|
125 | StartLine = .y
|
---|
126 | 'Addition
|
---|
127 | Dim i2 = 0 As Long, i3 As Long
|
---|
128 | Do
|
---|
129 | If buf[i2] = 9 Then 'tab
|
---|
130 | i3 = 8 - (.x And 7) '(.x mod 8)
|
---|
131 | _System_FillChar(VarPtr(_PromptSys_Buffer[.y][.x]), i3, &h20) 'Asc(" ")
|
---|
132 | i2++
|
---|
133 | .x += i3
|
---|
134 | Continue
|
---|
135 | End If
|
---|
136 |
|
---|
137 | If buf[i2] = 13 and buf[i2+1] = 10 Then '\r\n
|
---|
138 | i2 += 2
|
---|
139 | .y++
|
---|
140 | .x = 0
|
---|
141 | Continue
|
---|
142 | End If
|
---|
143 |
|
---|
144 | If buf[i2] = 0 Then Exit Do
|
---|
145 | _PromptSys_Buffer[.y][.x] = buf[i2]
|
---|
146 | _PromptSys_TextColor[.y][.x] = _PromptSys_NowTextColor
|
---|
147 | _PromptSys_BackColor[.y][.x] = _PromptSys_NowBackColor
|
---|
148 |
|
---|
149 | i2++
|
---|
150 | .x++
|
---|
151 | Loop
|
---|
152 | 'Draw the text buffer added
|
---|
153 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
154 | DrawPromptBuffer(hDC, StartLine, .y)
|
---|
155 | ReleaseDC(_PromptSys_hWnd, hDC)
|
---|
156 | End With
|
---|
157 | LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
158 | End Sub
|
---|
159 |
|
---|
160 | Function PromptProc(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT
|
---|
161 | Dim hIMC As HIMC
|
---|
162 | Dim hDC As HDC
|
---|
163 | Dim ps As PAINTSTRUCT
|
---|
164 | Dim TempStr As String
|
---|
165 | Dim CompForm As COMPOSITIONFORM
|
---|
166 |
|
---|
167 | Select Case message
|
---|
168 | Case WM_CREATE
|
---|
169 | hDC = GetDC(hWnd)
|
---|
170 | With _PromptSys_ScreenSize
|
---|
171 | _PromptSys_hBitmap = CreateCompatibleBitmap(hDC, .cx, .cy)
|
---|
172 | End With
|
---|
173 | _PromptSys_hMemDC = CreateCompatibleDC(hDC)
|
---|
174 | SelectObject(_PromptSys_hMemDC, _PromptSys_hBitmap)
|
---|
175 |
|
---|
176 | 'Initialize for Win9x
|
---|
177 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, GetStockObject(BLACK_BRUSH)) As HBRUSH
|
---|
178 | With _PromptSys_ScreenSize
|
---|
179 | PatBlt(_PromptSys_hMemDC, 0, 0, .cx, .cy, PATCOPY)
|
---|
180 | End With
|
---|
181 | SelectObject(_PromptSys_hMemDC, hOldBrush)
|
---|
182 |
|
---|
183 | Dim tm As TEXTMETRIC
|
---|
184 | Dim hOldFont=SelectObject(_PromptSys_hMemDC, _PromptSys_hFont) As HFONT
|
---|
185 | GetTextExtentPoint32(_PromptSys_hMemDC, " " As PCTSTR, 1, _PromptSys_FontSize)
|
---|
186 | GetTextMetrics(_PromptSys_hMemDC, tm)
|
---|
187 | SelectObject(_PromptSys_hMemDC, hOldFont)
|
---|
188 | _PromptSys_FontSize.cy = tm.tmHeight
|
---|
189 |
|
---|
190 | ReleaseDC(hWnd,hDC)
|
---|
191 | Case WM_PAINT
|
---|
192 | hDC = BeginPaint(hWnd,ps)
|
---|
193 | With _PromptSys_ScreenSize
|
---|
194 | BitBlt(hDC, 0, 0, .cx, .cy, _PromptSys_hMemDC, 0, 0, SRCCOPY)
|
---|
195 | End With
|
---|
196 | DrawPromptBuffer(hDC, -1, 0)
|
---|
197 | EndPaint(hWnd, ps)
|
---|
198 |
|
---|
199 | _PromptSys_bInitFinish = TRUE
|
---|
200 | Case WM_SETFOCUS
|
---|
201 | If _PromptSys_InputLen<>-1 Then
|
---|
202 | hIMC = ImmGetContext(hWnd)
|
---|
203 | If hIMC Then
|
---|
204 | With CompForm
|
---|
205 | .dwStyle = CFS_POINT
|
---|
206 | .ptCurrentPos.x = _PromptSys_CurPos.x * _PromptSys_FontSize.cx
|
---|
207 | .ptCurrentPos.y = _PromptSys_CurPos.y * _PromptSys_FontSize.cy
|
---|
208 | End With
|
---|
209 | ImmSetCompositionWindow(hIMC, CompForm)
|
---|
210 | ImmSetCompositionFontA(hIMC, _PromptSys_LogFont)
|
---|
211 | End If
|
---|
212 | ImmReleaseContext(hWnd, hIMC)
|
---|
213 |
|
---|
214 | CreateCaret(hWnd, NULL, 9, 6)
|
---|
215 | SetCaretPos(_PromptSys_CurPos.x*_PromptSys_FontSize.cx, _
|
---|
216 | (_PromptSys_CurPos.y+1)*_PromptSys_FontSize.cy-7)
|
---|
217 | ShowCaret(hWnd)
|
---|
218 | End If
|
---|
219 | Case WM_KILLFOCUS
|
---|
220 | HideCaret(hWnd)
|
---|
221 | DestroyCaret()
|
---|
222 | Case WM_KEYDOWN
|
---|
223 | If _PromptSys_InputLen=-1 Then
|
---|
224 | _PromptSys_KeyChar=wParam As Byte
|
---|
225 | End If
|
---|
226 | Case WM_CHAR
|
---|
227 | If _PromptSys_InputLen <> -1 Then
|
---|
228 | If wParam = VK_BACK Then
|
---|
229 | If _PromptSys_InputLen Then
|
---|
230 | _PromptSys_InputLen--
|
---|
231 | _PromptSys_InputStr[_PromptSys_InputLen] = 0
|
---|
232 |
|
---|
233 | _PromptSys_CurPos.x--
|
---|
234 | _PromptSys_Buffer[_PromptSys_CurPos.y][_PromptSys_CurPos.x] = 0
|
---|
235 | End If
|
---|
236 | ElseIf wParam = VK_RETURN Then
|
---|
237 | _PromptSys_InputStr[_PromptSys_InputLen] = 0
|
---|
238 | _PromptSys_InputLen = -1
|
---|
239 | TempStr = Ex"\r\n"
|
---|
240 | ElseIf wParam = &H16 Then
|
---|
241 | 'Paste Command(Use Clippboard)
|
---|
242 | OpenClipboard(hWnd)
|
---|
243 | Dim hGlobal = GetClipboardData(CF_TEXT) As HGLOBAL
|
---|
244 | If hGlobal = 0 Then Return 0
|
---|
245 | Dim pTemp = GlobalLock(hGlobal) As PCSTR
|
---|
246 | #ifdef UNICODE 'A版ウィンドウプロシージャ用
|
---|
247 | Dim tempSizeA = lstrlenA(pTemp)
|
---|
248 | Dim tempSizeW = MultiByteToWideChar(CP_ACP, 0, pTemp, tempSizeA, 0, 0) + 1
|
---|
249 | TempStr = ZeroString(tempSizeW)
|
---|
250 | MultiByteToWideChar(CP_ACP, 0, pTemp, tempSizeA, StrPtr(TempStr), tempSizeW)
|
---|
251 | #else
|
---|
252 | TempStr = ZeroString(lstrlen(pTemp) + 1)
|
---|
253 | lstrcpy(StrPtr(TempStr), pTemp)
|
---|
254 | #endif
|
---|
255 | memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), TempStr.Chars, SizeOf (Char) * TempStr.Length)
|
---|
256 | _PromptSys_InputLen += TempStr.Length
|
---|
257 |
|
---|
258 | GlobalUnlock(hGlobal)
|
---|
259 | CloseClipboard()
|
---|
260 | Else
|
---|
261 | _PromptSys_InputStr[_PromptSys_InputLen] = wParam As Byte
|
---|
262 | _PromptSys_InputLen++
|
---|
263 |
|
---|
264 | TempStr.ReSize(1)
|
---|
265 | TempStr[0] = wParam As Char
|
---|
266 | End If
|
---|
267 |
|
---|
268 | SendMessage(hWnd, WM_KILLFOCUS, 0, 0)
|
---|
269 | PRINT_ToPrompt(TempStr)
|
---|
270 | SendMessage(hWnd, WM_SETFOCUS, 0, 0)
|
---|
271 | End If
|
---|
272 | Case WM_DESTROY
|
---|
273 | DeleteDC(_PromptSys_hMemDC)
|
---|
274 | DeleteObject(_PromptSys_hBitmap)
|
---|
275 |
|
---|
276 | PostQuitMessage(0)
|
---|
277 | Case Else
|
---|
278 | PromptProc=DefWindowProc(hWnd,message,wParam,lParam)
|
---|
279 | Exit Function
|
---|
280 | End Select
|
---|
281 | PromptProc=0
|
---|
282 | End Function
|
---|
283 |
|
---|
284 | Function PromptMain(dwData As Long) As Long
|
---|
285 | Dim i As Long
|
---|
286 |
|
---|
287 | 'Allocate
|
---|
288 | For i=0 To 100
|
---|
289 | _PromptSys_Buffer[i] = _System_calloc(SizeOf (Char) * 255)
|
---|
290 | _PromptSys_TextColor[i] = _System_calloc(SizeOf(COLORREF) * 255)
|
---|
291 | _PromptSys_BackColor[i] = _System_calloc(SizeOf(COLORREF) * 255)
|
---|
292 | Next
|
---|
293 |
|
---|
294 | 'Current Colors initialize
|
---|
295 | _PromptSys_NowTextColor=RGB(255,255,255)
|
---|
296 | _PromptSys_NowBackColor=RGB(0,0,0)
|
---|
297 |
|
---|
298 | 'Setup
|
---|
299 | _PromptSys_ScreenSize.cx=GetSystemMetrics(SM_CXSCREEN)
|
---|
300 | _PromptSys_ScreenSize.cy=GetSystemMetrics(SM_CYSCREEN)
|
---|
301 |
|
---|
302 | 'LogFont initialize
|
---|
303 | With _PromptSys_LogFont
|
---|
304 | .lfHeight = -16
|
---|
305 | .lfWidth = 0
|
---|
306 | .lfEscapement = 0
|
---|
307 | .lfOrientation = 0
|
---|
308 | .lfWeight = 0
|
---|
309 | .lfItalic = 0
|
---|
310 | .lfUnderline = 0
|
---|
311 | .lfStrikeOut = 0
|
---|
312 | .lfCharSet = SHIFTJIS_CHARSET
|
---|
313 | .lfOutPrecision = OUT_DEFAULT_PRECIS
|
---|
314 | .lfClipPrecision = CLIP_DEFAULT_PRECIS
|
---|
315 | .lfQuality = DEFAULT_QUALITY
|
---|
316 | .lfPitchAndFamily = FIXED_PITCH
|
---|
317 | lstrcpy(.lfFaceName, "MS 明朝")
|
---|
318 | End With
|
---|
319 |
|
---|
320 | _PromptSys_hFont = CreateFontIndirect(ByVal VarPtr(_PromptSys_LogFont))
|
---|
321 |
|
---|
322 | 'Critical Section
|
---|
323 | InitializeCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
324 |
|
---|
325 | 'Regist Prompt Class
|
---|
326 | Dim wcl As WNDCLASSEX
|
---|
327 | ZeroMemory(VarPtr(wcl), Len(wcl))
|
---|
328 | With wcl
|
---|
329 | .cbSize = Len(wcl)
|
---|
330 | .hInstance = GetModuleHandle(0)
|
---|
331 | .style = CS_HREDRAW or CS_VREDRAW' or CS_DBLCLKS
|
---|
332 | .hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION))
|
---|
333 | .hIconSm = LoadIcon(NULL, MAKEINTRESOURCE(IDI_WINLOGO))
|
---|
334 | .hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW))
|
---|
335 | .lpszClassName = "PROMPT"
|
---|
336 | .lpfnWndProc = AddressOf(PromptProc)
|
---|
337 | .hbrBackground = GetStockObject(BLACK_BRUSH)
|
---|
338 | End With
|
---|
339 | Dim atom = RegisterClassEx(wcl)
|
---|
340 |
|
---|
341 | 'Create Prompt Window
|
---|
342 | _PromptSys_hWnd=CreateWindowEx(WS_EX_CLIENTEDGE,atom As ULONG_PTR As PCSTR,"BASIC PROMPT",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,GetModuleHandle(0),0)
|
---|
343 | ShowWindow(_PromptSys_hWnd, SW_SHOW)
|
---|
344 | UpdateWindow(_PromptSys_hWnd)
|
---|
345 |
|
---|
346 | Dim msg As MSG
|
---|
347 | Do
|
---|
348 | Dim iResult = GetMessage(msg, 0, 0, 0)
|
---|
349 | If iResult = 0 or iResult = -1 Then Exit Do
|
---|
350 | TranslateMessage(msg)
|
---|
351 | DispatchMessage(msg)
|
---|
352 | Loop
|
---|
353 |
|
---|
354 | '強制的に終了する
|
---|
355 | ExitProcess(0)
|
---|
356 |
|
---|
357 | EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
358 |
|
---|
359 | For i=0 to 100
|
---|
360 | _System_free(_PromptSys_Buffer[i])
|
---|
361 | _System_free(_PromptSys_TextColor[i])
|
---|
362 | _System_free(_PromptSys_BackColor[i])
|
---|
363 | Next
|
---|
364 |
|
---|
365 | LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
366 |
|
---|
367 | DeleteCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
368 |
|
---|
369 | ExitProcess(0)
|
---|
370 | End Function
|
---|
371 |
|
---|
372 |
|
---|
373 | '----------------------
|
---|
374 | ' Prompt text Commands
|
---|
375 | '----------------------
|
---|
376 |
|
---|
377 | Macro CLS()(num As Long)
|
---|
378 | Dim i As Long
|
---|
379 | Dim hOldBrush As HBRUSH
|
---|
380 |
|
---|
381 | 'When parameter was omitted, num is set to 1
|
---|
382 | If num=0 Then num=1
|
---|
383 |
|
---|
384 | If num=1 or num=3 Then
|
---|
385 | 'Clear the text screen
|
---|
386 | For i = 0 To 100
|
---|
387 | _System_FillChar(_PromptSys_Buffer[i],255,0)
|
---|
388 | Next
|
---|
389 | With _PromptSys_CurPos
|
---|
390 | .x = 0
|
---|
391 | .y = 0
|
---|
392 | End With
|
---|
393 | End If
|
---|
394 |
|
---|
395 | If num=2 or num=3 Then
|
---|
396 | 'Clear the graphics screen
|
---|
397 | hOldBrush=SelectObject(_PromptSys_hMemDC,GetStockObject(BLACK_BRUSH))
|
---|
398 | PatBlt(_PromptSys_hMemDC,0,0,_PromptSys_ScreenSize.cx,_PromptSys_ScreenSize.cy,PATCOPY)
|
---|
399 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
400 | End If
|
---|
401 |
|
---|
402 | 'Redraw
|
---|
403 | InvalidateRect(_PromptSys_hWnd,ByVal 0,0)
|
---|
404 | End Macro
|
---|
405 |
|
---|
406 | Macro COLOR(TextColorCode As Long)(BackColorCode As Long)
|
---|
407 | _PromptSys_NowTextColor=GetBasicColor(TextColorCode)
|
---|
408 | If BackColorCode=-1 Then
|
---|
409 | _PromptSys_NowBackColor=-1
|
---|
410 | Else
|
---|
411 | _PromptSys_NowBackColor=GetBasicColor(BackColorCode)
|
---|
412 | End If
|
---|
413 | End Macro
|
---|
414 |
|
---|
415 | '---------- Defined in "command.sbp" ----------
|
---|
416 | 'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
|
---|
417 | 'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
|
---|
418 | '----------------------------------------------
|
---|
419 | Sub INPUT_FromPrompt(ShowStr As String)
|
---|
420 | Dim i As Long ,i2 As Long, i3 As Long
|
---|
421 | Dim buf As String
|
---|
422 |
|
---|
423 | *InputReStart
|
---|
424 |
|
---|
425 | PRINT_ToPrompt(ShowStr)
|
---|
426 |
|
---|
427 | 'Input by keyboard
|
---|
428 | _PromptSys_InputLen=0
|
---|
429 | SendMessage(_PromptSys_hWnd,WM_SETFOCUS,0,0)
|
---|
430 | While _PromptSys_InputLen<>-1
|
---|
431 | Sleep(10)
|
---|
432 | Wend
|
---|
433 | SendMessage(_PromptSys_hWnd,WM_KILLFOCUS,0,0)
|
---|
434 |
|
---|
435 | 'Set value to variable
|
---|
436 | i = 0
|
---|
437 | i2 = 0
|
---|
438 | buf = ZeroString(lstrlen(_PromptSys_InputStr))
|
---|
439 | While 1
|
---|
440 | i3 = 0
|
---|
441 | While 1
|
---|
442 | If _PromptSys_InputStr[i2] = &h2c Then
|
---|
443 | buf.Chars[i3] = 0
|
---|
444 | Exit While
|
---|
445 | End If
|
---|
446 |
|
---|
447 | buf.Chars[i3] = _PromptSys_InputStr[i2]
|
---|
448 |
|
---|
449 | If _PromptSys_InputStr[i2] = 0 Then Exit While
|
---|
450 |
|
---|
451 | i2++
|
---|
452 | i3++
|
---|
453 | Wend
|
---|
454 |
|
---|
455 | _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
|
---|
456 |
|
---|
457 | i++
|
---|
458 | If _System_InputDataPtr[i]=0 and _PromptSys_InputStr[i2]=&h2c Then 'Asc(",")
|
---|
459 | PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
|
---|
460 | Goto *InputReStart
|
---|
461 | ElseIf _PromptSys_InputStr[i2]=0 Then
|
---|
462 | If _System_InputDataPtr[i]<>0 Then
|
---|
463 | PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
|
---|
464 | Goto *InputReStart
|
---|
465 | Else
|
---|
466 | Exit While
|
---|
467 | End If
|
---|
468 | End If
|
---|
469 |
|
---|
470 | i2++
|
---|
471 | Wend
|
---|
472 | End Sub
|
---|
473 |
|
---|
474 | Sub PRINTUSING_ToPrompt(UsingStr As String)
|
---|
475 | PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
|
---|
476 | End Sub
|
---|
477 |
|
---|
478 | Macro LOCATE(x As Long, y As Long)
|
---|
479 | Dim i As Long, i2 As Long
|
---|
480 |
|
---|
481 | If x<0 Then x=0
|
---|
482 | If y<0 Then y=0
|
---|
483 | If y>100 Then y=100
|
---|
484 | With _PromptSys_CurPos
|
---|
485 | .x = x
|
---|
486 | .y = y
|
---|
487 | End With
|
---|
488 | i=0
|
---|
489 | While _PromptSys_Buffer[y][i]
|
---|
490 | i++
|
---|
491 | Wend
|
---|
492 |
|
---|
493 | If i < x Then
|
---|
494 | _System_FillChar(VarPtr(_PromptSys_Buffer[y][i]), x - i, &h20) 'Asc(" ")
|
---|
495 | For i2 = i To x - 1
|
---|
496 | _PromptSys_BackColor[y][i2] = -1
|
---|
497 | Next
|
---|
498 | End If
|
---|
499 | End Macro
|
---|
500 |
|
---|
501 |
|
---|
502 | '-------------------
|
---|
503 | ' Graphics Commands
|
---|
504 | '-------------------
|
---|
505 |
|
---|
506 | Macro CIRCLE(x As Long , y As Long, radius As Long)(ColorCode As Long, StartPos As Double, EndPos As Double, Aspect As Double, bFill As Long, BrushColor As Long)
|
---|
507 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
508 | 'Circle (x, y), radius [, color] [, start] [, end] [, aspect] [, f] [, color2]
|
---|
509 |
|
---|
510 | Dim hBrush As HBRUSH
|
---|
511 | Dim radi2 As Long
|
---|
512 | Dim sw As Long
|
---|
513 | Dim i1 As Long, i2 As Long, i3 As Long, i4 As Long
|
---|
514 |
|
---|
515 | Dim hPen = CreatePen(PS_SOLID,1,GetBasicColor(ColorCode))
|
---|
516 | If bFill Then
|
---|
517 | hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
518 | Else
|
---|
519 | hBrush=GetStockObject(NULL_BRUSH)
|
---|
520 | End If
|
---|
521 |
|
---|
522 | Dim hDC=GetDC(_PromptSys_hWnd)
|
---|
523 | SelectObject(hDC,hPen)
|
---|
524 | SelectObject(hDC,hBrush)
|
---|
525 | Dim hOldPen=SelectObject(_PromptSys_hMemDC,hPen)
|
---|
526 | Dim hOldBrush=SelectObject(_PromptSys_hMemDC,hBrush)
|
---|
527 |
|
---|
528 | If Aspect<1 Then
|
---|
529 | radi2=(CDbl(radius)*Aspect) As Long
|
---|
530 | Else
|
---|
531 | radi2=radius
|
---|
532 | radius=(CDbl(radius)/Aspect) As Long
|
---|
533 | End If
|
---|
534 |
|
---|
535 | If StartPos=0 And EndPos=0 Then
|
---|
536 | Ellipse(hDC,x-radius,y-radi2,x+radius,y+radi2)
|
---|
537 | Ellipse(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2)
|
---|
538 | Else
|
---|
539 | StartPos *=StartPos
|
---|
540 | EndPos *=EndPos
|
---|
541 |
|
---|
542 | If StartPos<0 Or EndPos<0 Then
|
---|
543 | sw=1
|
---|
544 | Else
|
---|
545 | sw=0
|
---|
546 | End If
|
---|
547 |
|
---|
548 | StartPos = Abs(StartPos)
|
---|
549 | EndPos = Abs(EndPos)
|
---|
550 |
|
---|
551 | If StartPos<=78.5 Then
|
---|
552 | i1=78
|
---|
553 | i2=Int(StartPos)
|
---|
554 | ElseIf StartPos<=235.5 Then
|
---|
555 | StartPos -= 78.5
|
---|
556 | i1=78-Int(StartPos)
|
---|
557 | i2=78
|
---|
558 | ElseIf StartPos<=392.5 Then
|
---|
559 | StartPos -= 235.5
|
---|
560 | i1=-78
|
---|
561 | i2=78-Int(StartPos)
|
---|
562 | ElseIf StartPos<=549.5 Then
|
---|
563 | StartPos -= 392.5
|
---|
564 | i1=-78+Int(StartPos)
|
---|
565 | i2=-78
|
---|
566 | ElseIf StartPos<=628 Then
|
---|
567 | StartPos -= 549.5
|
---|
568 | i1=78
|
---|
569 | i2=-78+Int(StartPos)
|
---|
570 | End If
|
---|
571 |
|
---|
572 | If EndPos<=78.5 Then
|
---|
573 | i3=78
|
---|
574 | i4=Int(EndPos)
|
---|
575 | ElseIf EndPos<=235.5 Then
|
---|
576 | EndPos -= 78.5
|
---|
577 | i3=78-Int(EndPos)
|
---|
578 | i4=78
|
---|
579 | ElseIf EndPos<=392.5 Then
|
---|
580 | EndPos -= 235.5
|
---|
581 | i3=-78
|
---|
582 | i4=78-Int(EndPos)
|
---|
583 | ElseIf EndPos<=549.5 Then
|
---|
584 | EndPos -= 392.5
|
---|
585 | i3=-78+Int(EndPos)
|
---|
586 | i4=-78
|
---|
587 | ElseIf EndPos<=628 Then
|
---|
588 | EndPos -= 549.5
|
---|
589 | i3=78
|
---|
590 | i4=-78+Int(EndPos)
|
---|
591 | End If
|
---|
592 |
|
---|
593 | If sw Then
|
---|
594 | Pie(hDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
595 | Pie(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
596 | Else
|
---|
597 | Arc(hDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
598 | Arc(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
599 | End If
|
---|
600 | End If
|
---|
601 |
|
---|
602 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
603 | SelectObject(_PromptSys_hMemDC,hOldPen)
|
---|
604 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
605 | DeleteObject(hPen)
|
---|
606 | If bFill Then DeleteObject(hBrush)
|
---|
607 | End Macro
|
---|
608 |
|
---|
609 | Macro LINE(sx As Long, sy As Long, bStep As Long, ex As Long, ey As Long)(ColorCode As Long, fType As Long, BrushColor As Long)
|
---|
610 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
611 | 'Line (sx,sy)-[STEP](ex,ey),[ColorCode],[B/Bf],[BrushColor]
|
---|
612 | Dim temp As Long
|
---|
613 |
|
---|
614 | If sx=&H80000000 And sy=&H80000000 Then
|
---|
615 | sx=_PromptSys_GlobalPos.x
|
---|
616 | sy=_PromptSys_GlobalPos.y
|
---|
617 | End If
|
---|
618 |
|
---|
619 | If bStep Then
|
---|
620 | ex += sx
|
---|
621 | ey += sy
|
---|
622 | Else
|
---|
623 | If fType Then
|
---|
624 | 'ラインの場合(四角形でない場合)
|
---|
625 | If sx>ex Then
|
---|
626 | temp=ex
|
---|
627 | ex=sx
|
---|
628 | sx=temp
|
---|
629 | End If
|
---|
630 | If sy>ey Then
|
---|
631 | temp=ey
|
---|
632 | ey=sy
|
---|
633 | sy=temp
|
---|
634 | End If
|
---|
635 | End If
|
---|
636 | End If
|
---|
637 |
|
---|
638 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
639 | Dim hPen = CreatePen(PS_SOLID, 1, GetBasicColor(ColorCode))
|
---|
640 | Dim hBrush As HBRUSH
|
---|
641 | If fType=2 Then
|
---|
642 | hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
643 | Else
|
---|
644 | hBrush=GetStockObject(NULL_BRUSH)
|
---|
645 | End If
|
---|
646 |
|
---|
647 | SelectObject(hDC,hPen)
|
---|
648 | SelectObject(hDC,hBrush)
|
---|
649 | Dim hOldPen = SelectObject(_PromptSys_hMemDC,hPen)
|
---|
650 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC,hBrush)
|
---|
651 |
|
---|
652 | Select Case fType
|
---|
653 | Case 0
|
---|
654 | 'line
|
---|
655 | MoveToEx(_PromptSys_hMemDC,sx,sy,ByVal NULL)
|
---|
656 | LineTo(_PromptSys_hMemDC,ex,ey)
|
---|
657 | SetPixel(_PromptSys_hMemDC,ex,ey,GetBasicColor(ColorCode))
|
---|
658 | MoveToEx(hDC,sx,sy,ByVal NULL)
|
---|
659 | LineTo(hDC,ex,ey)
|
---|
660 | SetPixel(hDC,ex,ey,GetBasicColor(ColorCode))
|
---|
661 | Case Else
|
---|
662 | 'Rectangle
|
---|
663 | Rectangle(hDC,sx,sy,ex+1,ey+1)
|
---|
664 | Rectangle(_PromptSys_hMemDC,sx,sy,ex+1,ey+1)
|
---|
665 | End Select
|
---|
666 |
|
---|
667 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
668 | SelectObject(_PromptSys_hMemDC,hOldPen)
|
---|
669 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
670 | DeleteObject(hPen)
|
---|
671 | If fType=2 Then DeleteObject(hBrush)
|
---|
672 |
|
---|
673 | _PromptSys_GlobalPos.x=ex
|
---|
674 | _PromptSys_GlobalPos.y=ey
|
---|
675 | End Macro
|
---|
676 |
|
---|
677 | Macro PSET(x As Long, y As Long)(ColorCode As Long)
|
---|
678 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
679 | 'PSet (x,y),ColorCode
|
---|
680 |
|
---|
681 | Dim hDC=GetDC(_PromptSys_hWnd)
|
---|
682 | SetPixel(hDC,x,y,GetBasicColor(ColorCode))
|
---|
683 | SetPixel(_PromptSys_hMemDC,x,y,GetBasicColor(ColorCode))
|
---|
684 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
685 |
|
---|
686 | _PromptSys_GlobalPos.x=x
|
---|
687 | _PromptSys_GlobalPos.y=y
|
---|
688 | End Macro
|
---|
689 |
|
---|
690 | Macro PAINT(x As Long, y As Long, BrushColor As Long)(ByVal LineColor As Long)
|
---|
691 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
692 | 'Paint (x,y),BrushColor,LineColor
|
---|
693 |
|
---|
694 | Dim hDC As HDC
|
---|
695 | Dim hBrush As HBRUSH, hOldBrush As VoidPtr
|
---|
696 |
|
---|
697 | hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
698 |
|
---|
699 | hDC=GetDC(_PromptSys_hWnd)
|
---|
700 | SelectObject(hDC,hBrush)
|
---|
701 | hOldBrush=SelectObject(_PromptSys_hMemDC,hBrush)
|
---|
702 |
|
---|
703 | ExtFloodFill(hDC,x,y,GetBasicColor(LineColor),FLOODFILLBORDER)
|
---|
704 | ExtFloodFill(_PromptSys_hMemDC,x,y,GetBasicColor(LineColor),FLOODFILLBORDER)
|
---|
705 |
|
---|
706 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
707 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
708 | DeleteObject(hBrush)
|
---|
709 | End Macro
|
---|
710 |
|
---|
711 |
|
---|
712 | '-----------
|
---|
713 | ' Functions
|
---|
714 | '-----------
|
---|
715 |
|
---|
716 | Function Inkey$() As String
|
---|
717 | If _PromptSys_KeyChar=0 Then
|
---|
718 | Inkey$=""
|
---|
719 | Else
|
---|
720 | Inkey$=Chr$(_PromptSys_KeyChar)
|
---|
721 | End If
|
---|
722 | _PromptSys_KeyChar=0
|
---|
723 | End Function
|
---|
724 |
|
---|
725 | Function Input$(length As Long) As String
|
---|
726 | Dim i As Long
|
---|
727 |
|
---|
728 | If length<=0 Then
|
---|
729 | Input$=""
|
---|
730 | Exit Function
|
---|
731 | End If
|
---|
732 |
|
---|
733 | i=0
|
---|
734 | While 1
|
---|
735 | If _PromptSys_KeyChar Then
|
---|
736 | Input$=Input$+Chr$(_PromptSys_KeyChar)
|
---|
737 | _PromptSys_KeyChar=0
|
---|
738 | i++
|
---|
739 | If i>=length Then
|
---|
740 | Exit While
|
---|
741 | End If
|
---|
742 | End If
|
---|
743 | Sleep(1)
|
---|
744 | Wend
|
---|
745 | End Function
|
---|
746 |
|
---|
747 |
|
---|
748 | #endif '_INC_PROMPT
|
---|