| 1 | 'prompt.sbp
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 | #ifndef _INC_PROMPT
|
|---|
| 5 | #define _INC_PROMPT
|
|---|
| 6 |
|
|---|
| 7 | Namespace ActiveBasic
|
|---|
| 8 | Namespace Prompt
|
|---|
| 9 | Namespace Detail
|
|---|
| 10 |
|
|---|
| 11 | Function _PromptSys_GetTextExtentPoint32(hdc As HDC, psz As PCSTR, cb As Long, ByRef Size As SIZE) As Long
|
|---|
| 12 | _PromptSys_GetTextExtentPoint32 = GetTextExtentPoint32A(hdc, psz, cb, Size)
|
|---|
| 13 | End Function
|
|---|
| 14 |
|
|---|
| 15 | Function _PromptSys_GetTextExtentPoint32(hdc As HDC, psz As PCWSTR, cb As Long, ByRef Size As SIZE) As Long
|
|---|
| 16 | _PromptSys_GetTextExtentPoint32 = GetTextExtentPoint32W(hdc, psz, cb, Size)
|
|---|
| 17 | End Function
|
|---|
| 18 |
|
|---|
| 19 | Function _PromptSys_TextOut(hdc As HDC, x As Long, y As Long, psz As PCSTR, cb As Long) As Long
|
|---|
| 20 | _PromptSys_TextOut = TextOutA(hdc, x, y, psz, cb)
|
|---|
| 21 | If _PromptSys_TextOut = 0 Then Debug
|
|---|
| 22 | End Function
|
|---|
| 23 |
|
|---|
| 24 | Function _PromptSys_TextOut(hdc As HDC, x As Long, y As Long, psz As PCWSTR, cb As Long) As Long
|
|---|
| 25 | _PromptSys_TextOut = TextOutW(hdc, x, y, psz, cb)
|
|---|
| 26 | End Function
|
|---|
| 27 |
|
|---|
| 28 | Function _PromptSys_ImmGetCompositionString(himc As HIMC, index As DWord, pBuf As PSTR, bufLen As DWord) As Long
|
|---|
| 29 | _PromptSys_ImmGetCompositionString = ImmGetCompositionStringA(himc, index, pBuf, bufLen)
|
|---|
| 30 | End Function
|
|---|
| 31 |
|
|---|
| 32 | Function _PromptSys_ImmGetCompositionString(himc As HIMC, index As DWord, pBuf As PWSTR, bufLen As DWord) As Long
|
|---|
| 33 | _PromptSys_ImmGetCompositionString = ImmGetCompositionStringW(himc, index, pBuf, bufLen)
|
|---|
| 34 | End Function
|
|---|
| 35 |
|
|---|
| 36 | Dim _PromptSys_hWnd As HWND
|
|---|
| 37 | Dim _PromptSys_dwThreadID As DWord
|
|---|
| 38 | Dim _PromptSys_hInitFinish As HANDLE
|
|---|
| 39 |
|
|---|
| 40 | 'text
|
|---|
| 41 | Type _PromptSys_CharacterInformation
|
|---|
| 42 | ForeColor As COLORREF
|
|---|
| 43 | BackColor As COLORREF
|
|---|
| 44 | StartPos As Long
|
|---|
| 45 | End Type
|
|---|
| 46 |
|
|---|
| 47 | Type _PromptSys_LineInformation
|
|---|
| 48 | Length As Long
|
|---|
| 49 | Text As *Char
|
|---|
| 50 | CharInfo As *_PromptSys_CharacterInformation
|
|---|
| 51 | End Type
|
|---|
| 52 |
|
|---|
| 53 | Dim _PromptSys_hFont As HFONT
|
|---|
| 54 | Dim _PromptSys_FontSize As SIZE
|
|---|
| 55 | Dim _PromptSys_InputStr[255] As Char
|
|---|
| 56 | Dim _PromptSys_InputLen = -1 As Long
|
|---|
| 57 | Dim _PromptSys_KeyChar As Byte
|
|---|
| 58 | Dim _PromptSys_CurPos As POINTAPI
|
|---|
| 59 | Dim _PromptSys_TextLine[100] As _PromptSys_LineInformation
|
|---|
| 60 | Dim _PromptSys_NowTextColor As COLORREF
|
|---|
| 61 | Dim _PromptSys_NowBackColor As COLORREF
|
|---|
| 62 | Dim _PromptSys_SectionOfBufferAccess As CRITICAL_SECTION
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 | 'graphic
|
|---|
| 66 | Dim _PromptSys_hBitmap As HBITMAP
|
|---|
| 67 | Dim _PromptSys_hMemDC As HDC
|
|---|
| 68 | Dim _PromptSys_ScreenSize As SIZE
|
|---|
| 69 | Dim _PromptSys_GlobalPos As POINTAPI
|
|---|
| 70 |
|
|---|
| 71 | Sub _PromptSys_Initialize()
|
|---|
| 72 | _PromptSys_hInitFinish = CreateEvent(0, FALSE, FALSE, 0)
|
|---|
| 73 | Dim _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain), 0, 0, _PromptSys_dwThreadID)
|
|---|
| 74 | If _PromptSys_hThread = 0 Then
|
|---|
| 75 | Debug
|
|---|
| 76 | ExitProcess(1)
|
|---|
| 77 | End If
|
|---|
| 78 | WaitForSingleObject(_PromptSys_hInitFinish, INFINITE)
|
|---|
| 79 | End Sub
|
|---|
| 80 |
|
|---|
| 81 | Sub DrawPromptBuffer(hDC As HDC, StartLine As Long, EndLine As Long)
|
|---|
| 82 | Dim i As Long, i2 As Long, i3 As Long
|
|---|
| 83 | Dim ret As Long
|
|---|
| 84 |
|
|---|
| 85 | Dim hOldFont = SelectObject(hDC, _PromptSys_hFont) As HFONT
|
|---|
| 86 |
|
|---|
| 87 | 'Scroll
|
|---|
| 88 | Dim rc As RECT
|
|---|
| 89 | GetClientRect(_PromptSys_hWnd, rc)
|
|---|
| 90 | While (_PromptSys_CurPos.y+1) * _PromptSys_FontSize.cy > rc.bottom and _PromptSys_CurPos.y > 0
|
|---|
| 91 | _System_free(_PromptSys_TextLine[0].Text)
|
|---|
| 92 | _System_free(_PromptSys_TextLine[0].CharInfo)
|
|---|
| 93 | For i = 0 To 100 - 1
|
|---|
| 94 | _PromptSys_TextLine[i].Length = _PromptSys_TextLine[i+1].Length
|
|---|
| 95 | _PromptSys_TextLine[i].Text = _PromptSys_TextLine[i+1].Text
|
|---|
| 96 | _PromptSys_TextLine[i].CharInfo = _PromptSys_TextLine[i+1].CharInfo
|
|---|
| 97 | Next
|
|---|
| 98 | _PromptSys_TextLine[100].Length = 0
|
|---|
| 99 | _PromptSys_TextLine[100].Text = _System_calloc(SizeOf (Char) * 255)
|
|---|
| 100 | _PromptSys_TextLine[100].CharInfo = _System_calloc(SizeOf (_PromptSys_CharacterInformation) * 255)
|
|---|
| 101 | _PromptSys_CurPos.y--
|
|---|
| 102 |
|
|---|
| 103 | 'Redraw
|
|---|
| 104 | StartLine = -1
|
|---|
| 105 | Wend
|
|---|
| 106 |
|
|---|
| 107 | i = 0' : Debug
|
|---|
| 108 | While i * _PromptSys_FontSize.cy < rc.bottom and i <= 100
|
|---|
| 109 | If StartLine=-1 or (StartLine<=i and i<=EndLine) Then
|
|---|
| 110 | Dim currentLineCharInfo = _PromptSys_TextLine[i].CharInfo
|
|---|
| 111 |
|
|---|
| 112 | Dim sz As SIZE
|
|---|
| 113 | i3 = _PromptSys_TextLine[i].Length
|
|---|
| 114 | _PromptSys_GetTextExtentPoint32(hDC, _PromptSys_TextLine[i].Text, i3, sz)
|
|---|
| 115 |
|
|---|
| 116 | ' BitBlt(hDC,_
|
|---|
| 117 | ' sz.cx, i * _PromptSys_FontSize.cy, _
|
|---|
| 118 | ' rc.right, _PromptSys_FontSize.cy, _
|
|---|
| 119 | ' _PromptSys_hMemDC, sz.cx, i * _PromptSys_FontSize.cy, SRCCOPY)
|
|---|
| 120 |
|
|---|
| 121 | While i2 < i3
|
|---|
| 122 | SetTextColor(hDC, currentLineCharInfo[i2].ForeColor)
|
|---|
| 123 | If currentLineCharInfo[i2].BackColor = -1 Then
|
|---|
| 124 | SetBkMode(hDC, TRANSPARENT)
|
|---|
| 125 | Else
|
|---|
| 126 | ' Debug
|
|---|
| 127 | ret = SetBkMode(hDC, OPAQUE)
|
|---|
| 128 | ret = SetBkColor(hDC, currentLineCharInfo[i2].BackColor)
|
|---|
| 129 | End If
|
|---|
| 130 |
|
|---|
| 131 | Dim tempLen As Long
|
|---|
| 132 | If _System_IsDoubleUnitChar(_PromptSys_TextLine[i].Text[i2], _PromptSys_TextLine[i].Text[i2+1]) Then
|
|---|
| 133 | tempLen = 2
|
|---|
| 134 | Else
|
|---|
| 135 | tempLen = 1
|
|---|
| 136 | End If
|
|---|
| 137 | With _PromptSys_FontSize
|
|---|
| 138 | _PromptSys_TextOut(hDC, currentLineCharInfo[i2].StartPos, i * .cy, VarPtr(_PromptSys_TextLine[i].Text[i2]) As *Char, tempLen)
|
|---|
| 139 | End With
|
|---|
| 140 | i2 += tempLen
|
|---|
| 141 | Wend
|
|---|
| 142 | End If
|
|---|
| 143 |
|
|---|
| 144 | i++
|
|---|
| 145 | Wend
|
|---|
| 146 |
|
|---|
| 147 | SelectObject(hDC, hOldFont)
|
|---|
| 148 | End Sub
|
|---|
| 149 |
|
|---|
| 150 | Sub PRINT_ToPrompt(buf As String)
|
|---|
| 151 | OutputDebugString(ToTCStr(Ex"PRINT_ToPrompt " + buf + Ex"\r\n"))
|
|---|
| 152 | EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
|
|---|
| 153 | If buf = "あ" Then Debug
|
|---|
| 154 | With _PromptSys_CurPos
|
|---|
| 155 | Dim hdc = GetDC(_PromptSys_hWnd)
|
|---|
| 156 | Dim hOldFont = SelectObject(hdc, _PromptSys_hFont)
|
|---|
| 157 | Dim StartLine = .y As Long
|
|---|
| 158 | Dim bufLen = buf.Length
|
|---|
| 159 | Dim doubleUnitChar = False As Boolean
|
|---|
| 160 | 'Addition
|
|---|
| 161 | Dim i2 = 0 As Long, i3 As Long
|
|---|
| 162 | For i2 = 0 To ELM(bufLen)
|
|---|
| 163 | If buf[i2] = &h0d Then 'CR \r
|
|---|
| 164 | _PromptSys_TextLine[.y].Length = .x
|
|---|
| 165 | .x = 0
|
|---|
| 166 | ElseIf buf[i2] = &h0a Then 'LF \n
|
|---|
| 167 | _PromptSys_TextLine[.y].Length = System.Math.Max(_PromptSys_TextLine[.y].Length, .x)
|
|---|
| 168 | .y++
|
|---|
| 169 | Else
|
|---|
| 170 | Dim currentLineCharInfo = _PromptSys_TextLine[.y].CharInfo
|
|---|
| 171 | _PromptSys_TextLine[.y].Text[.x] = buf[i2]
|
|---|
| 172 | currentLineCharInfo[.x].ForeColor = _PromptSys_NowTextColor
|
|---|
| 173 | currentLineCharInfo[.x].BackColor = _PromptSys_NowBackColor
|
|---|
| 174 |
|
|---|
| 175 | If buf[i2] = &h09 Then 'tab
|
|---|
| 176 | Dim tabStop = _PromptSys_FontSize.cx * 8
|
|---|
| 177 | currentLineCharInfo[.x + 1].StartPos = currentLineCharInfo[.x].StartPos + _
|
|---|
| 178 | tabStop - currentLineCharInfo[.x].StartPos Mod tabStop
|
|---|
| 179 | Else
|
|---|
| 180 | If doubleUnitChar <> False Then
|
|---|
| 181 | doubleUnitChar = False
|
|---|
| 182 | currentLineCharInfo[.x + 1].StartPos = currentLineCharInfo[.x].StartPos
|
|---|
| 183 | Else
|
|---|
| 184 | Dim sz As SIZE
|
|---|
| 185 | Dim charLen As Long
|
|---|
| 186 | If _System_IsDoubleUnitChar(buf[i2], buf[i2 + 1]) Then
|
|---|
| 187 | charLen = 2
|
|---|
| 188 | doubleUnitChar = True
|
|---|
| 189 | Else
|
|---|
| 190 | charLen = 1
|
|---|
| 191 | EndIf
|
|---|
| 192 | Dim p = buf.StrPtr
|
|---|
| 193 | _PromptSys_GetTextExtentPoint32(hdc, VarPtr(p[i2]) As *Char, charLen, sz)
|
|---|
| 194 | currentLineCharInfo[.x + 1].StartPos = currentLineCharInfo[.x].StartPos + sz.cx
|
|---|
| 195 | End If
|
|---|
| 196 | End If
|
|---|
| 197 | .x++
|
|---|
| 198 | End If
|
|---|
| 199 | Next
|
|---|
| 200 | _PromptSys_TextLine[.y].Length = System.Math.Max(_PromptSys_TextLine[.y].Length, .x)
|
|---|
| 201 |
|
|---|
| 202 | 'Draw the text buffer added
|
|---|
| 203 | 'DrawPromptBuffer(hdc, StartLine, .y)
|
|---|
| 204 | InvalidateRect(_PromptSys_hWnd, ByVal 0, TRUE)
|
|---|
| 205 | UpdateWindow(_PromptSys_hWnd)
|
|---|
| 206 | SelectObject(hdc, hOldFont)
|
|---|
| 207 | ReleaseDC(_PromptSys_hWnd, hdc)
|
|---|
| 208 | End With
|
|---|
| 209 | LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
|
|---|
| 210 | End Sub
|
|---|
| 211 |
|
|---|
| 212 | Function PromptProc(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT
|
|---|
| 213 | Select Case message
|
|---|
| 214 | Case WM_CREATE
|
|---|
| 215 | Return _PromptWnd_OnCreate(hWnd, ByVal lParam As *CREATESTRUCT)
|
|---|
| 216 | Case WM_PAINT
|
|---|
| 217 | _PromptWnd_OnPaint(hWnd)
|
|---|
| 218 | Case WM_SETFOCUS
|
|---|
| 219 | _PromptWnd_OnSetFocus(hWnd, wParam As HWND)
|
|---|
| 220 | Case WM_KILLFOCUS
|
|---|
| 221 | _PromptWnd_OnKillForcus(hWnd, wParam As HWND)
|
|---|
| 222 | Case WM_KEYDOWN
|
|---|
| 223 | _PromptWnd_OnKeyDown(wParam As DWord, LOWORD(lParam) As DWord, HIWORD(lParam) As DWord)
|
|---|
| 224 | Case WM_CHAR
|
|---|
| 225 | _PromptWnd_OnChar(hWnd, wParam, lParam)
|
|---|
| 226 | Case WM_IME_COMPOSITION
|
|---|
| 227 | Return _PromptWnd_OnImeCompostion(hWnd, wParam, lParam)
|
|---|
| 228 | Case WM_DESTROY
|
|---|
| 229 | _PromptWnd_OnDestroy(hWnd)
|
|---|
| 230 | Case Else
|
|---|
| 231 | PromptProc = DefWindowProc(hWnd, message, wParam, lParam)
|
|---|
| 232 | Exit Function
|
|---|
| 233 | End Select
|
|---|
| 234 | PromptProc = 0
|
|---|
| 235 | End Function
|
|---|
| 236 |
|
|---|
| 237 | Function _PromptWnd_OnCreate(hwnd As HWND, ByRef cs As CREATESTRUCT) As LRESULT
|
|---|
| 238 | Dim hdc = GetDC(hwnd)
|
|---|
| 239 | With _PromptSys_ScreenSize
|
|---|
| 240 | _PromptSys_hBitmap = CreateCompatibleBitmap(hdc, .cx, .cy)
|
|---|
| 241 | End With
|
|---|
| 242 | _PromptSys_hMemDC = CreateCompatibleDC(hdc)
|
|---|
| 243 | SelectObject(_PromptSys_hMemDC, _PromptSys_hBitmap)
|
|---|
| 244 |
|
|---|
| 245 | 'Initialize for Win9x
|
|---|
| 246 | ClearGraphicsScreen()
|
|---|
| 247 |
|
|---|
| 248 | Dim tm As TEXTMETRIC
|
|---|
| 249 | Dim hOldFont = SelectObject(_PromptSys_hMemDC, _PromptSys_hFont) As HFONT
|
|---|
| 250 | GetTextMetrics(_PromptSys_hMemDC, tm)
|
|---|
| 251 | SelectObject(_PromptSys_hMemDC, hOldFont)
|
|---|
| 252 | With _PromptSys_FontSize
|
|---|
| 253 | .cx = tm.tmAveCharWidth
|
|---|
| 254 | .cy = tm.tmHeight
|
|---|
| 255 | End With
|
|---|
| 256 |
|
|---|
| 257 | '_PromptSys_hFont initialize
|
|---|
| 258 | Dim lf As LOGFONT
|
|---|
| 259 | With lf
|
|---|
| 260 | .lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72)
|
|---|
| 261 | .lfWidth = 0
|
|---|
| 262 | .lfEscapement = 0
|
|---|
| 263 | .lfOrientation = 0
|
|---|
| 264 | .lfWeight = 0
|
|---|
| 265 | .lfItalic = 0
|
|---|
| 266 | .lfUnderline = 0
|
|---|
| 267 | .lfStrikeOut = 0
|
|---|
| 268 | .lfCharSet = SHIFTJIS_CHARSET
|
|---|
| 269 | .lfOutPrecision = OUT_DEFAULT_PRECIS
|
|---|
| 270 | .lfClipPrecision = CLIP_DEFAULT_PRECIS
|
|---|
| 271 | .lfQuality = DEFAULT_QUALITY
|
|---|
| 272 | .lfPitchAndFamily = FIXED_PITCH
|
|---|
| 273 | lstrcpy(.lfFaceName, ToTCStr("MS 明朝"))
|
|---|
| 274 | End With
|
|---|
| 275 |
|
|---|
| 276 | _PromptSys_hFont = CreateFontIndirect(lf)
|
|---|
| 277 |
|
|---|
| 278 | ReleaseDC(hwnd, hdc)
|
|---|
| 279 |
|
|---|
| 280 | _PromptWnd_OnCreate = 0
|
|---|
| 281 | End Function
|
|---|
| 282 |
|
|---|
| 283 | Sub _PromptWnd_OnPaint(hwnd As HWND)
|
|---|
| 284 | Dim ps As PAINTSTRUCT
|
|---|
| 285 | Dim hdc = BeginPaint(hwnd, ps)
|
|---|
| 286 | With _PromptSys_ScreenSize
|
|---|
| 287 | BitBlt(hdc, 0, 0, .cx, .cy, _PromptSys_hMemDC, 0, 0, SRCCOPY)
|
|---|
| 288 | ' With ps.rcPaint
|
|---|
| 289 | ' BitBlt(hdc, .left, .top, .right - .left, .bottom - .top, _PromptSys_hMemDC, .left, .top, SRCCOPY)
|
|---|
| 290 | End With
|
|---|
| 291 | DrawPromptBuffer(hdc, -1, 0)
|
|---|
| 292 | EndPaint(hwnd, ps)
|
|---|
| 293 | End Sub
|
|---|
| 294 |
|
|---|
| 295 | Sub _PromptWnd_OnSetFocus(hwnd As HWND, hwndOldFocus As HWND)
|
|---|
| 296 | If _PromptSys_InputLen <> -1 Then
|
|---|
| 297 | Dim himc = ImmGetContext(hwnd)
|
|---|
| 298 | If himc Then
|
|---|
| 299 | Dim CompForm As COMPOSITIONFORM
|
|---|
| 300 | With CompForm
|
|---|
| 301 | .dwStyle = CFS_POINT
|
|---|
| 302 | .ptCurrentPos.x = _PromptSys_CurPos.x * _PromptSys_FontSize.cx
|
|---|
| 303 | .ptCurrentPos.y = _PromptSys_CurPos.y * _PromptSys_FontSize.cy
|
|---|
| 304 | End With
|
|---|
| 305 | ImmSetCompositionWindow(himc, CompForm)
|
|---|
| 306 |
|
|---|
| 307 | Dim lf As LOGFONT
|
|---|
| 308 | GetObject(_PromptSys_hFont, Len(lf), lf)
|
|---|
| 309 | ImmSetCompositionFont(himc, lf)
|
|---|
| 310 | End If
|
|---|
| 311 | ImmReleaseContext(hwnd, himc)
|
|---|
| 312 |
|
|---|
| 313 | CreateCaret(hwnd, 0, 9, 6)
|
|---|
| 314 | With _PromptSys_CurPos
|
|---|
| 315 | SetCaretPos(_PromptSys_TextLine[.y].CharInfo[.x].StartPos, (.y + 1) * _PromptSys_FontSize.cy - 7)
|
|---|
| 316 | End With
|
|---|
| 317 | ShowCaret(hwnd)
|
|---|
| 318 | End If
|
|---|
| 319 | End Sub
|
|---|
| 320 |
|
|---|
| 321 | Sub _PromptWnd_OnKillForcus(hwnd As HWND, hwndNewFocus As HWND)
|
|---|
| 322 | HideCaret(hwnd)
|
|---|
| 323 | DestroyCaret()
|
|---|
| 324 | End Sub
|
|---|
| 325 |
|
|---|
| 326 | Sub _PromptWnd_OnKeyDown(vk As DWord, repeat As DWord, flags As DWord)
|
|---|
| 327 | If _PromptSys_InputLen = -1 Then
|
|---|
| 328 | _PromptSys_KeyChar = vk As Byte
|
|---|
| 329 | End If
|
|---|
| 330 | End Sub
|
|---|
| 331 |
|
|---|
| 332 | Sub _PromptWnd_OnDestroy(hwnd As HWND)
|
|---|
| 333 | DeleteDC(_PromptSys_hMemDC)
|
|---|
| 334 | DeleteObject(_PromptSys_hBitmap)
|
|---|
| 335 |
|
|---|
| 336 | PostQuitMessage(0)
|
|---|
| 337 | End Sub
|
|---|
| 338 |
|
|---|
| 339 | Sub _PromptWnd_OnChar(hwnd As HWND, wParam As WPARAM, lParam As LPARAM)
|
|---|
| 340 | Dim TempStr As String
|
|---|
| 341 | If _PromptSys_InputLen <> -1 Then
|
|---|
| 342 | If wParam = VK_BACK Then
|
|---|
| 343 | If _PromptSys_InputLen Then
|
|---|
| 344 | _PromptSys_InputLen--
|
|---|
| 345 | _PromptSys_InputStr[_PromptSys_InputLen] = 0
|
|---|
| 346 |
|
|---|
| 347 | _PromptSys_CurPos.x--
|
|---|
| 348 | With _PromptSys_CurPos
|
|---|
| 349 | _PromptSys_TextLine[.y].Text[.x] = 0
|
|---|
| 350 | End With
|
|---|
| 351 | End If
|
|---|
| 352 | ElseIf wParam = VK_RETURN Then
|
|---|
| 353 | _PromptSys_InputStr[_PromptSys_InputLen] = 0
|
|---|
| 354 | _PromptSys_InputLen = -1
|
|---|
| 355 | TempStr = Ex"\r\n"
|
|---|
| 356 | ElseIf wParam = &H16 Then
|
|---|
| 357 | /*
|
|---|
| 358 | 'Paste Command(Use Clippboard)
|
|---|
| 359 | OpenClipboard(hwnd)
|
|---|
| 360 | Dim hGlobal = GetClipboardData(CF_TEXT) As HGLOBAL
|
|---|
| 361 | If hGlobal = 0 Then Exit Sub
|
|---|
| 362 | Dim pTemp = GlobalLock(hGlobal) As PCSTR
|
|---|
| 363 | #ifdef UNICODE 'A版ウィンドウプロシージャ用
|
|---|
| 364 | Dim tempSizeA = lstrlenA(pTemp)
|
|---|
| 365 | Dim tempSizeW = MultiByteToWideChar(CP_ACP, 0, pTemp, tempSizeA, 0, 0) + 1
|
|---|
| 366 | TempStr = ZeroString(tempSizeW)
|
|---|
| 367 | MultiByteToWideChar(CP_ACP, 0, pTemp, tempSizeA, StrPtr(TempStr), tempSizeW)
|
|---|
| 368 | #else
|
|---|
| 369 | TempStr = ZeroString(lstrlen(pTemp) + 1)
|
|---|
| 370 | lstrcpy(StrPtr(TempStr), pTemp)
|
|---|
| 371 | #endif
|
|---|
| 372 | memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), TempStr.Chars, SizeOf (Char) * TempStr.Length)
|
|---|
| 373 | _PromptSys_InputLen += TempStr.Length
|
|---|
| 374 |
|
|---|
| 375 | GlobalUnlock(hGlobal)
|
|---|
| 376 | CloseClipboard()
|
|---|
| 377 | */
|
|---|
| 378 | Else
|
|---|
| 379 | Dim t = wParam As TCHAR
|
|---|
| 380 | TempStr = New String(VarPtr(t), 1)
|
|---|
| 381 | _PromptSys_InputStr[_PromptSys_InputLen] = TempStr[0]
|
|---|
| 382 | _PromptSys_InputLen++
|
|---|
| 383 | End If
|
|---|
| 384 |
|
|---|
| 385 | SendMessage(hwnd, WM_KILLFOCUS, 0, 0)
|
|---|
| 386 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(TempStr)
|
|---|
| 387 | SendMessage(hwnd, WM_SETFOCUS, 0, 0)
|
|---|
| 388 | End If
|
|---|
| 389 | End Sub
|
|---|
| 390 |
|
|---|
| 391 | Function _PromptWnd_GetCompositionStringW(himc As HIMC, ByRef rpsz As PWSTR) As Long
|
|---|
| 392 | Dim size = ImmGetCompositionStringW(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位
|
|---|
| 393 | rpsz = GC_malloc(size) As PWSTR
|
|---|
| 394 | If rpsz = 0 Then
|
|---|
| 395 | 'Debug
|
|---|
| 396 | Return 0
|
|---|
| 397 | End If
|
|---|
| 398 | Return ImmGetCompositionStringW(himc, GCS_RESULTSTR, rpsz, size)
|
|---|
| 399 | End Function
|
|---|
| 400 |
|
|---|
| 401 | Function _PromptWnd_GetCompositionStringA(himc As HIMC, ByRef rpsz As PSTR) As Long
|
|---|
| 402 | Dim size = ImmGetCompositionStringA(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位
|
|---|
| 403 | rpsz = GC_malloc(size) As PSTR
|
|---|
| 404 | If rpsz = 0 Then
|
|---|
| 405 | 'Debug
|
|---|
| 406 | Return 0
|
|---|
| 407 | End If
|
|---|
| 408 | Return ImmGetCompositionStringA(himc, GCS_RESULTSTR, rpsz, size)
|
|---|
| 409 | End Function
|
|---|
| 410 |
|
|---|
| 411 | Function _PromptWnd_OnImeCompostion(hwnd As HWND, wp As WPARAM, lp As LPARAM) As LRESULT
|
|---|
| 412 | If (lp And GCS_RESULTSTR) <> 0 Then
|
|---|
| 413 | Dim himc = ImmGetContext(hwnd)
|
|---|
| 414 | If himc = 0 Then
|
|---|
| 415 | 'Debug
|
|---|
| 416 | Return 0
|
|---|
| 417 | End If
|
|---|
| 418 | Dim tempStr = Nothing As String
|
|---|
| 419 | Dim str As *Char
|
|---|
| 420 | #ifdef UNICODE
|
|---|
| 421 | Dim osver = System.Environment.OSVersion
|
|---|
| 422 | With osver
|
|---|
| 423 | ' GetCompositionStringW is not implimented in Windows 95
|
|---|
| 424 | If .Version.Major = 4 And .Version.Minor = 0 And .Platform = System.PlatformID.Win32Windows Then
|
|---|
| 425 | Dim strA As PCSTR
|
|---|
| 426 | Dim sizeA = _PromptWnd_GetCompositionStringA(himc, strA)
|
|---|
| 427 | tempStr = New String(strA, sizeA As Long)
|
|---|
| 428 | Else
|
|---|
| 429 | Dim size = _PromptWnd_GetCompositionStringW(himc, str)
|
|---|
| 430 | tempStr = New String(str, (size \ SizeOf (WCHAR)) As Long)
|
|---|
| 431 | End If
|
|---|
| 432 | End With
|
|---|
| 433 | #else
|
|---|
| 434 | Dim size = _PromptWnd_GetCompositionStringA(himc, str)
|
|---|
| 435 | tempStr = New String(str, size As Long)
|
|---|
| 436 | #endif
|
|---|
| 437 | ImmReleaseContext(hwnd, himc)
|
|---|
| 438 |
|
|---|
| 439 | ActiveBasic.Strings.ChrCopy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), tempStr.StrPtr, tempStr.Length As SIZE_T)
|
|---|
| 440 | _PromptSys_InputLen += tempStr.Length
|
|---|
| 441 |
|
|---|
| 442 | SendMessage(hwnd, WM_KILLFOCUS, 0, 0)
|
|---|
| 443 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(tempStr)
|
|---|
| 444 | SendMessage(hwnd, WM_SETFOCUS, 0, 0)
|
|---|
| 445 |
|
|---|
| 446 | _PromptWnd_OnImeCompostion = 0
|
|---|
| 447 | Else
|
|---|
| 448 | _PromptWnd_OnImeCompostion = DefWindowProc(hwnd, WM_IME_COMPOSITION, wp, lp)
|
|---|
| 449 | End If
|
|---|
| 450 | End Function
|
|---|
| 451 |
|
|---|
| 452 | Function PromptMain(data As VoidPtr) As DWord
|
|---|
| 453 | Dim i As Long
|
|---|
| 454 | 'Allocate
|
|---|
| 455 | For i = 0 To 100
|
|---|
| 456 | With _PromptSys_TextLine[i]
|
|---|
| 457 | .Length = 0
|
|---|
| 458 | .Text = _System_calloc(SizeOf (Char) * 255)
|
|---|
| 459 | .CharInfo = _System_calloc(SizeOf (_PromptSys_CharacterInformation) * 255)
|
|---|
| 460 | End With
|
|---|
| 461 | Next
|
|---|
| 462 |
|
|---|
| 463 | 'Current Colors initialize
|
|---|
| 464 | _PromptSys_NowTextColor = RGB(255, 255, 255)
|
|---|
| 465 | _PromptSys_NowBackColor = RGB(0, 0, 0)
|
|---|
| 466 |
|
|---|
| 467 | 'Setup
|
|---|
| 468 | With _PromptSys_ScreenSize
|
|---|
| 469 | .cx = GetSystemMetrics(SM_CXSCREEN)
|
|---|
| 470 | .cy = GetSystemMetrics(SM_CYSCREEN)
|
|---|
| 471 | End With
|
|---|
| 472 |
|
|---|
| 473 | 'Critical Section
|
|---|
| 474 | InitializeCriticalSection(_PromptSys_SectionOfBufferAccess)
|
|---|
| 475 |
|
|---|
| 476 | 'Regist Prompt Class
|
|---|
| 477 | Dim wcl As WNDCLASSEX
|
|---|
| 478 | ZeroMemory(VarPtr(wcl), Len(wcl))
|
|---|
| 479 | With wcl
|
|---|
| 480 | .cbSize = Len(wcl)
|
|---|
| 481 | .hInstance = GetModuleHandle(0)
|
|---|
| 482 | .style = CS_HREDRAW Or CS_VREDRAW' or CS_DBLCLKS
|
|---|
| 483 | .hIcon = LoadImage(0, MAKEINTRESOURCE(IDI_APPLICATION), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HICON
|
|---|
| 484 | .hIconSm = LoadImage(0, MAKEINTRESOURCE(IDI_WINLOGO), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HICON
|
|---|
| 485 | .hCursor = LoadImage(0, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HCURSOR
|
|---|
| 486 | .lpszClassName = ToTCStr("PROMPT")
|
|---|
| 487 | .lpfnWndProc = AddressOf(PromptProc)
|
|---|
| 488 | .hbrBackground = GetStockObject(BLACK_BRUSH)
|
|---|
| 489 | End With
|
|---|
| 490 | Dim atom = RegisterClassEx(wcl)
|
|---|
| 491 |
|
|---|
| 492 | 'Create Prompt Window
|
|---|
| 493 | _PromptSys_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, atom As ULONG_PTR As LPCTSTR, ToTCStr("BASIC PROMPT"), _
|
|---|
| 494 | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
|
|---|
| 495 | 0, 0, wcl.hInstance, 0)
|
|---|
| 496 | ShowWindow(_PromptSys_hWnd, SW_SHOW)
|
|---|
| 497 | UpdateWindow(_PromptSys_hWnd)
|
|---|
| 498 | SetEvent(_PromptSys_hInitFinish)
|
|---|
| 499 | Dim msg As MSG
|
|---|
| 500 | Do
|
|---|
| 501 | Dim iResult = GetMessage(msg, 0, 0, 0)
|
|---|
| 502 | If iResult = 0 Then
|
|---|
| 503 | System.Environment.ExitCode = msg.wParam As Long
|
|---|
| 504 | Exit Do
|
|---|
| 505 | ElseIf iResult = -1 Then
|
|---|
| 506 | Exit Do
|
|---|
| 507 | End If
|
|---|
| 508 | TranslateMessage(msg)
|
|---|
| 509 | DispatchMessage(msg)
|
|---|
| 510 | Loop
|
|---|
| 511 |
|
|---|
| 512 | '強制的に終了する
|
|---|
| 513 | End
|
|---|
| 514 |
|
|---|
| 515 | EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
|
|---|
| 516 |
|
|---|
| 517 | For i = 0 to 100
|
|---|
| 518 | _System_free(_PromptSys_TextLine[i].Text)
|
|---|
| 519 | _System_free(_PromptSys_TextLine[i].CharInfo)
|
|---|
| 520 | Next
|
|---|
| 521 |
|
|---|
| 522 | LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
|
|---|
| 523 |
|
|---|
| 524 | DeleteCriticalSection(_PromptSys_SectionOfBufferAccess)
|
|---|
| 525 |
|
|---|
| 526 | End
|
|---|
| 527 | End Function
|
|---|
| 528 |
|
|---|
| 529 | Sub ClearGraphicsScreen()
|
|---|
| 530 | Dim rc As RECT
|
|---|
| 531 | With rc
|
|---|
| 532 | .left = 0
|
|---|
| 533 | .top = 0
|
|---|
| 534 | .right = _PromptSys_ScreenSize.cx
|
|---|
| 535 | .bottom = _PromptSys_ScreenSize.cy
|
|---|
| 536 | End With
|
|---|
| 537 | SetBkColor(_PromptSys_hMemDC, 0)
|
|---|
| 538 | ExtTextOut(_PromptSys_hMemDC, 0, 0, ETO_OPAQUE, rc, "", 0, 0) '矩形塗り潰しはExtTextOutが速いらしい
|
|---|
| 539 | End Sub
|
|---|
| 540 |
|
|---|
| 541 | 'Prompt text command functoins
|
|---|
| 542 |
|
|---|
| 543 | Sub Cls(n As Long)
|
|---|
| 544 | Dim i As Long
|
|---|
| 545 |
|
|---|
| 546 | 'When parameter was omitted, num is set to 1
|
|---|
| 547 | If n = 0 Then n = 1
|
|---|
| 548 |
|
|---|
| 549 | If n = 1 Or n = 3 Then
|
|---|
| 550 | 'Clear the text screen
|
|---|
| 551 | For i = 0 To 100
|
|---|
| 552 | With _PromptSys_TextLine[i]
|
|---|
| 553 | .Text[0] = 0 '_System_FillChar(_PromptSys_TextLine[i].Text, -1 As Char, 0)
|
|---|
| 554 | .Length = 0
|
|---|
| 555 | End With
|
|---|
| 556 | Next
|
|---|
| 557 | With _PromptSys_CurPos
|
|---|
| 558 | .x = 0
|
|---|
| 559 | .y = 0
|
|---|
| 560 | End With
|
|---|
| 561 | End If
|
|---|
| 562 |
|
|---|
| 563 | If n = 2 Or n = 3 Then
|
|---|
| 564 | 'Clear the graphics screen
|
|---|
| 565 | ClearGraphicsScreen()
|
|---|
| 566 | End If
|
|---|
| 567 |
|
|---|
| 568 | 'Redraw
|
|---|
| 569 | InvalidateRect(_PromptSys_hWnd, ByVal 0, 0)
|
|---|
| 570 | End Sub
|
|---|
| 571 |
|
|---|
| 572 | Sub Color(textColorCode As Long, backColorCode As Long)
|
|---|
| 573 | _PromptSys_NowTextColor = GetBasicColor(textColorCode)
|
|---|
| 574 | If backColorCode = -1 Then
|
|---|
| 575 | _PromptSys_NowBackColor = -1
|
|---|
| 576 | Else
|
|---|
| 577 | _PromptSys_NowBackColor = GetBasicColor(backColorCode)
|
|---|
| 578 | End If
|
|---|
| 579 | End Sub
|
|---|
| 580 |
|
|---|
| 581 | Sub INPUT_FromPrompt(showStr As String)
|
|---|
| 582 | *InputReStart
|
|---|
| 583 |
|
|---|
| 584 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(showStr)
|
|---|
| 585 |
|
|---|
| 586 | 'Input by keyboard
|
|---|
| 587 | _PromptSys_InputLen = 0
|
|---|
| 588 | SendMessage(_PromptSys_hWnd, WM_SETFOCUS, 0, 0)
|
|---|
| 589 | While _PromptSys_InputLen <> -1
|
|---|
| 590 | Sleep(10)
|
|---|
| 591 | Wend
|
|---|
| 592 | SendMessage(_PromptSys_hWnd, WM_KILLFOCUS, 0, 0)
|
|---|
| 593 |
|
|---|
| 594 | 'Set value to variable
|
|---|
| 595 | Const comma = &h2c As Char 'Asc(",")
|
|---|
| 596 | Dim broken = ActiveBasic.Strings.Detail.Split(New String(_PromptSys_InputStr), comma)
|
|---|
| 597 | Dim i As Long
|
|---|
| 598 | For i = 0 To ELM(broken.Count)
|
|---|
| 599 | If _System_InputDataPtr[i] = 0 Then
|
|---|
| 600 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
|
|---|
| 601 | Goto *InputReStart
|
|---|
| 602 | End If
|
|---|
| 603 | _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken.Item[i])
|
|---|
| 604 | Next
|
|---|
| 605 |
|
|---|
| 606 | If _System_InputDataPtr[i]<>0 Then
|
|---|
| 607 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
|
|---|
| 608 | Goto *InputReStart
|
|---|
| 609 | End If
|
|---|
| 610 | End Sub
|
|---|
| 611 |
|
|---|
| 612 | Sub Locate(x As Long, y As Long)
|
|---|
| 613 | If x < 0 Then x = 0
|
|---|
| 614 | If y < 0 Then y = 0
|
|---|
| 615 | If y > 100 Then y = 100
|
|---|
| 616 | With _PromptSys_CurPos
|
|---|
| 617 | .x = x
|
|---|
| 618 | .y = y
|
|---|
| 619 | End With
|
|---|
| 620 |
|
|---|
| 621 | Dim i = _PromptSys_TextLine[y].Length
|
|---|
| 622 | If i < x Then
|
|---|
| 623 | ActiveBasic.Strings.ChrFill(VarPtr(_PromptSys_TextLine[y].Text[i]), x - i, &h20 As Char) 'Asc(" ")
|
|---|
| 624 | Dim i2 As Long
|
|---|
| 625 | For i2 = i To ELM(x)
|
|---|
| 626 | _PromptSys_TextLine[y].CharInfo[i2].BackColor = -1
|
|---|
| 627 | Next
|
|---|
| 628 | _PromptSys_TextLine[y].Length = x
|
|---|
| 629 | End If
|
|---|
| 630 | End Sub
|
|---|
| 631 |
|
|---|
| 632 | 'Prompt graphic command functions
|
|---|
| 633 |
|
|---|
| 634 | Sub Circle(x As Double, y As Double, radius As Double, ColorCode As Long, StartPos As Double, EndPos As Double, Aspect As Double, bFill As Long, BrushColor As Long)
|
|---|
| 635 | Dim hPen = CreatePen(PS_SOLID, 1, GetBasicColor(ColorCode))
|
|---|
| 636 | Dim hBrush As HBRUSH
|
|---|
| 637 | If bFill Then
|
|---|
| 638 | hBrush = CreateSolidBrush(GetBasicColor(BrushColor))
|
|---|
| 639 | Else
|
|---|
| 640 | hBrush = GetStockObject(NULL_BRUSH)
|
|---|
| 641 | End If
|
|---|
| 642 |
|
|---|
| 643 | Dim hdc = GetDC(_PromptSys_hWnd)
|
|---|
| 644 | Dim hOldPenDC = SelectObject(hdc, hPen)
|
|---|
| 645 | Dim hOldBrushDC = SelectObject(hdc, hBrush)
|
|---|
| 646 | Dim hOldPen = SelectObject(_PromptSys_hMemDC, hPen)
|
|---|
| 647 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
|
|---|
| 648 |
|
|---|
| 649 | Dim yRadius As Double
|
|---|
| 650 | Dim xRadius As Double
|
|---|
| 651 | If Aspect = 1 Then
|
|---|
| 652 | yRadius = radius
|
|---|
| 653 | xRadius = radius
|
|---|
| 654 | ElseIf Aspect < 1 Then
|
|---|
| 655 | yRadius = radius * Aspect
|
|---|
| 656 | xRadius = radius
|
|---|
| 657 | Else
|
|---|
| 658 | yRadius = radius
|
|---|
| 659 | xRadius = radius / Aspect
|
|---|
| 660 | End If
|
|---|
| 661 |
|
|---|
| 662 | Dim x1 = (x - xRadius) As Long
|
|---|
| 663 | Dim x2 = (x + xRadius) As Long
|
|---|
| 664 | Dim y1 = (y - yRadius) As Long
|
|---|
| 665 | Dim y2 = (y + yRadius) As Long
|
|---|
| 666 |
|
|---|
| 667 | If StartPos = 0 And EndPos = 0 Then
|
|---|
| 668 | Ellipse(hdc, x1, y1, x2, y2)
|
|---|
| 669 | Ellipse(_PromptSys_hMemDC, x1, y1, x2, y2)
|
|---|
| 670 | Else
|
|---|
| 671 | Dim isPie As Boolean
|
|---|
| 672 | If StartPos < 0 Or EndPos < 0 Then
|
|---|
| 673 | isPie = True
|
|---|
| 674 | StartPos = Math.Abs(StartPos)
|
|---|
| 675 | EndPos = Math.Abs(EndPos)
|
|---|
| 676 | Else
|
|---|
| 677 | isPie = False
|
|---|
| 678 | End If
|
|---|
| 679 |
|
|---|
| 680 | Dim scaleRadial = (x + y) * 0.5
|
|---|
| 681 | Dim startX = (x + ActiveBasic.Math.Cos(StartPos) * scaleRadial) As Long
|
|---|
| 682 | Dim startY = (y - ActiveBasic.Math.Sin(StartPos) * scaleRadial) As Long
|
|---|
| 683 | Dim endX = (x + ActiveBasic.Math.Cos(EndPos) * scaleRadial) As Long
|
|---|
| 684 | Dim endY = (y - ActiveBasic.Math.Sin(EndPos) * scaleRadial) As Long
|
|---|
| 685 |
|
|---|
| 686 | If isPie Then
|
|---|
| 687 | Pie(hdc, x1, y1, x2, y2, startX, startY, endX, endY)
|
|---|
| 688 | Pie(_PromptSys_hMemDC, x1, y1, x2, y2, startX, startY, endX, endY)
|
|---|
| 689 | Else
|
|---|
| 690 | Arc(hdc, x1, y1, x2, y2, startX, startY, endX, endY)
|
|---|
| 691 | Arc(_PromptSys_hMemDC, x1, y1, x2, y2, startX, startY, endX, endY)
|
|---|
| 692 | End If
|
|---|
| 693 | End If
|
|---|
| 694 |
|
|---|
| 695 | SelectObject(hdc, hOldPenDC)
|
|---|
| 696 | SelectObject(hdc, hOldBrushDC)
|
|---|
| 697 | ReleaseDC(_PromptSys_hWnd, hdc)
|
|---|
| 698 | SelectObject(_PromptSys_hMemDC, hOldPen)
|
|---|
| 699 | SelectObject(_PromptSys_hMemDC, hOldBrush)
|
|---|
| 700 | DeleteObject(hPen)
|
|---|
| 701 | If bFill Then DeleteObject(hBrush)
|
|---|
| 702 | End Sub
|
|---|
| 703 |
|
|---|
| 704 | Sub 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)
|
|---|
| 705 | Dim temp As Long
|
|---|
| 706 |
|
|---|
| 707 | If sx = &H80000000 And sy = &H80000000 Then
|
|---|
| 708 | With _PromptSys_GlobalPos
|
|---|
| 709 | sx = .x
|
|---|
| 710 | sy = .y
|
|---|
| 711 | End With
|
|---|
| 712 | End If
|
|---|
| 713 |
|
|---|
| 714 | If bStep Then
|
|---|
| 715 | ex += sx
|
|---|
| 716 | ey += sy
|
|---|
| 717 | Else
|
|---|
| 718 | If fType Then
|
|---|
| 719 | 'ラインの場合(四角形でない場合)
|
|---|
| 720 | If sx>ex Then
|
|---|
| 721 | temp=ex
|
|---|
| 722 | ex=sx
|
|---|
| 723 | sx=temp
|
|---|
| 724 | End If
|
|---|
| 725 | If sy>ey Then
|
|---|
| 726 | temp=ey
|
|---|
| 727 | ey=sy
|
|---|
| 728 | sy=temp
|
|---|
| 729 | End If
|
|---|
| 730 | End If
|
|---|
| 731 | End If
|
|---|
| 732 |
|
|---|
| 733 | Dim hdc = GetDC(_PromptSys_hWnd)
|
|---|
| 734 | Dim hPen = CreatePen(PS_SOLID, 1, GetBasicColor(ColorCode))
|
|---|
| 735 | Dim hBrush As HBRUSH
|
|---|
| 736 | If fType=2 Then
|
|---|
| 737 | hBrush = CreateSolidBrush(GetBasicColor(BrushColor))
|
|---|
| 738 | Else
|
|---|
| 739 | hBrush = GetStockObject(NULL_BRUSH)
|
|---|
| 740 | End If
|
|---|
| 741 |
|
|---|
| 742 | SelectObject(hdc, hPen)
|
|---|
| 743 | SelectObject(hdc, hBrush)
|
|---|
| 744 | Dim hOldPen = SelectObject(_PromptSys_hMemDC, hPen)
|
|---|
| 745 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
|
|---|
| 746 |
|
|---|
| 747 | Select Case fType
|
|---|
| 748 | Case 0
|
|---|
| 749 | 'line
|
|---|
| 750 | MoveToEx(_PromptSys_hMemDC,sx,sy,ByVal NULL)
|
|---|
| 751 | LineTo(_PromptSys_hMemDC,ex,ey)
|
|---|
| 752 | SetPixel(_PromptSys_hMemDC,ex,ey,GetBasicColor(ColorCode))
|
|---|
| 753 | MoveToEx(hdc,sx,sy,ByVal NULL)
|
|---|
| 754 | LineTo(hdc,ex,ey)
|
|---|
| 755 | SetPixel(hdc,ex,ey,GetBasicColor(ColorCode))
|
|---|
| 756 | Case Else
|
|---|
| 757 | 'Rectangle
|
|---|
| 758 | Rectangle(hdc,sx,sy,ex+1,ey+1)
|
|---|
| 759 | Rectangle(_PromptSys_hMemDC,sx,sy,ex+1,ey+1)
|
|---|
| 760 | End Select
|
|---|
| 761 |
|
|---|
| 762 | ReleaseDC(_PromptSys_hWnd,hdc)
|
|---|
| 763 | SelectObject(_PromptSys_hMemDC,hOldPen)
|
|---|
| 764 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
|---|
| 765 | DeleteObject(hPen)
|
|---|
| 766 | If fType = 2 Then DeleteObject(hBrush)
|
|---|
| 767 | With _PromptSys_GlobalPos
|
|---|
| 768 | .x = ex
|
|---|
| 769 | .y = ey
|
|---|
| 770 | End With
|
|---|
| 771 | End Sub
|
|---|
| 772 |
|
|---|
| 773 | Sub PSet(x As Long, y As Long, ColorCode As Long)
|
|---|
| 774 | Dim hdc = GetDC(_PromptSys_hWnd)
|
|---|
| 775 | SetPixel(hdc, x, y, GetBasicColor(ColorCode))
|
|---|
| 776 | SetPixel(_PromptSys_hMemDC, x, y, GetBasicColor(ColorCode))
|
|---|
| 777 | ReleaseDC(_PromptSys_hWnd, hdc)
|
|---|
| 778 | With _PromptSys_GlobalPos
|
|---|
| 779 | .x = x
|
|---|
| 780 | .y = y
|
|---|
| 781 | End With
|
|---|
| 782 | End Sub
|
|---|
| 783 |
|
|---|
| 784 | Sub Paint(x As Long, y As Long, BrushColor As Long, LineColor As Long)
|
|---|
| 785 | Dim hbr = CreateSolidBrush(GetBasicColor(BrushColor))
|
|---|
| 786 |
|
|---|
| 787 | Dim hdc = GetDC(_PromptSys_hWnd)
|
|---|
| 788 | Dim hbrOld = SelectObject(_PromptSys_hMemDC, hbr)
|
|---|
| 789 | Dim hbrOldWndDC = SelectObject(hdc, hbr)
|
|---|
| 790 |
|
|---|
| 791 | ExtFloodFill(hdc, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
|
|---|
| 792 | ExtFloodFill(_PromptSys_hMemDC, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
|
|---|
| 793 |
|
|---|
| 794 | ReleaseDC(_PromptSys_hWnd, hdc)
|
|---|
| 795 | SelectObject(_PromptSys_hMemDC, hbrOld)
|
|---|
| 796 | SelectObject(hdc, hbrOldWndDC)
|
|---|
| 797 | DeleteObject(hbr)
|
|---|
| 798 | End Sub
|
|---|
| 799 |
|
|---|
| 800 | Function Inkey$() As String
|
|---|
| 801 | If _PromptSys_KeyChar=0 Then
|
|---|
| 802 | Inkey$=""
|
|---|
| 803 | Else
|
|---|
| 804 | Inkey$=Chr$(_PromptSys_KeyChar)
|
|---|
| 805 | End If
|
|---|
| 806 | _PromptSys_KeyChar=0
|
|---|
| 807 | End Function
|
|---|
| 808 |
|
|---|
| 809 | Function Input$(length As Long) As String
|
|---|
| 810 | Dim i = 0 As Long
|
|---|
| 811 |
|
|---|
| 812 | If length<=0 Then
|
|---|
| 813 | Input$=""
|
|---|
| 814 | Exit Function
|
|---|
| 815 | End If
|
|---|
| 816 |
|
|---|
| 817 | While 1
|
|---|
| 818 | If _PromptSys_KeyChar Then
|
|---|
| 819 | Input$=Input$+Chr$(_PromptSys_KeyChar)
|
|---|
| 820 | _PromptSys_KeyChar=0
|
|---|
| 821 | i++
|
|---|
| 822 | If i >= length Then
|
|---|
| 823 | Exit While
|
|---|
| 824 | End If
|
|---|
| 825 | End If
|
|---|
| 826 | Sleep(1)
|
|---|
| 827 | Wend
|
|---|
| 828 | End Function
|
|---|
| 829 |
|
|---|
| 830 | End Namespace 'Detail
|
|---|
| 831 |
|
|---|
| 832 | Function OwnerWnd() As HWND
|
|---|
| 833 | Return Detail._PromptSys_hWnd
|
|---|
| 834 | End Function
|
|---|
| 835 |
|
|---|
| 836 | End Namespace 'Prompt
|
|---|
| 837 | End Namespace 'ActiveBasic
|
|---|
| 838 |
|
|---|
| 839 | '----------------------
|
|---|
| 840 | ' Prompt text Commands
|
|---|
| 841 | '----------------------
|
|---|
| 842 |
|
|---|
| 843 | Sub PRINT_ToPrompt(s As String)
|
|---|
| 844 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(s)
|
|---|
| 845 | End Sub
|
|---|
| 846 |
|
|---|
| 847 | Macro CLS()(num As Long)
|
|---|
| 848 | ActiveBasic.Prompt.Detail.Cls(num)
|
|---|
| 849 | End Macro
|
|---|
| 850 |
|
|---|
| 851 | Macro COLOR(TextColorCode As Long)(BackColorCode As Long)
|
|---|
| 852 | ActiveBasic.Prompt.Detail.Color(TextColorCode, BackColorCode)
|
|---|
| 853 | End Macro
|
|---|
| 854 |
|
|---|
| 855 | '---------- Defined in "command.sbp" ----------
|
|---|
| 856 | 'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
|
|---|
| 857 | 'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
|
|---|
| 858 | '----------------------------------------------
|
|---|
| 859 | Sub INPUT_FromPrompt(ShowStr As String)
|
|---|
| 860 | ActiveBasic.Prompt.Detail.INPUT_FromPrompt(ShowStr)
|
|---|
| 861 | End Sub
|
|---|
| 862 |
|
|---|
| 863 | /* TODO: _System_GetUsingFormatを用意して実装する
|
|---|
| 864 | Sub PRINTUSING_ToPrompt(UsingStr As String)
|
|---|
| 865 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
|
|---|
| 866 | End Sub
|
|---|
| 867 | */
|
|---|
| 868 |
|
|---|
| 869 | Macro LOCATE(x As Double, y As Double)
|
|---|
| 870 | ActiveBasic.Prompt.Detail.Locate(x As Long, y As Long)
|
|---|
| 871 | End Macro
|
|---|
| 872 |
|
|---|
| 873 |
|
|---|
| 874 | '-------------------
|
|---|
| 875 | ' Graphics Commands
|
|---|
| 876 | '-------------------
|
|---|
| 877 |
|
|---|
| 878 | Macro CIRCLE(x As Double , y As Double, radius As Double)(ColorCode As Long, StartPos As Double, EndPos As Double, Aspect As Double, bFill As Long, BrushColor As Long)
|
|---|
| 879 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
|---|
| 880 | 'Circle (x, y), radius [, color] [, start] [, end] [, aspect] [, f] [, color2]
|
|---|
| 881 | ActiveBasic.Prompt.Detail.Circle(x, y, radius, ColorCode, StartPos, EndPos, Aspect, bFill, BrushColor)
|
|---|
| 882 | End Macro
|
|---|
| 883 |
|
|---|
| 884 | Macro LINE(sx As Double, sy As Double, bStep As Long, ex As Double, ey As Double)(ColorCode As Long, fType As Long, BrushColor As Long)
|
|---|
| 885 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
|---|
| 886 | 'Line (sx,sy)-[STEP](ex,ey),[ColorCode],[B/Bf],[BrushColor]
|
|---|
| 887 | ActiveBasic.Prompt.Detail.Line(sx As Long, sy As Long, bStep, ex As Long, ey As Long, ColorCode, fType, BrushColor)
|
|---|
| 888 | End Macro
|
|---|
| 889 |
|
|---|
| 890 | Macro PSET(x As Double, y As Double)(ColorCode As Long)
|
|---|
| 891 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
|---|
| 892 | 'PSet (x,y),ColorCode
|
|---|
| 893 | ActiveBasic.Prompt.Detail.PSet(x As Long, y As Long, ColorCode)
|
|---|
| 894 | End Macro
|
|---|
| 895 |
|
|---|
| 896 | Macro PAINT(x As Double, y As Double, BrushColor As Long)(ByVal LineColor As Long)
|
|---|
| 897 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
|---|
| 898 | 'Paint (x,y),BrushColor,LineColor
|
|---|
| 899 | ActiveBasic.Prompt.Detail.Paint(x As Long, y As Long, BrushColor, LineColor)
|
|---|
| 900 | End Macro
|
|---|
| 901 |
|
|---|
| 902 |
|
|---|
| 903 | '-----------
|
|---|
| 904 | ' Functions
|
|---|
| 905 | '-----------
|
|---|
| 906 |
|
|---|
| 907 | Function Inkey$() As String
|
|---|
| 908 | Return ActiveBasic.Prompt.Detail.Inkey$()
|
|---|
| 909 | End Function
|
|---|
| 910 |
|
|---|
| 911 | Function Input$(length As Long) As String
|
|---|
| 912 | Return ActiveBasic.Prompt.Detail.Input$(length)
|
|---|
| 913 | End Function
|
|---|
| 914 |
|
|---|
| 915 | ActiveBasic.Prompt.Detail._PromptSys_Initialize()
|
|---|
| 916 |
|
|---|
| 917 | #endif '_INC_PROMPT
|
|---|