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