[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
|
---|
[497] | 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
|
---|
[497] | 49 | Text As *Char
|
---|
[126] | 50 | CharInfo As *_PromptSys_CharacterInformation
|
---|
| 51 | End Type
|
---|
| 52 |
|
---|
[1] | 53 | Dim _PromptSys_hFont As HFONT
|
---|
| 54 | Dim _PromptSys_FontSize As SIZE
|
---|
[497] | 55 | Dim _PromptSys_InputStr[255] As Char
|
---|
[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
|
---|
[497] | 99 | _PromptSys_TextLine[100].Text = _System_calloc(SizeOf (Char) * 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
|
---|
[537] | 126 | ' Debug
|
---|
[411] | 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
|
---|
[497] | 138 | _PromptSys_TextOut(hDC, currentLineCharInfo[i2].StartPos, i * .cy, VarPtr(_PromptSys_TextLine[i].Text[i2]) As *Char, 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
|
---|
[497] | 193 | _PromptSys_GetTextExtentPoint32(hdc, VarPtr(p[i2]) As *Char, 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
|
---|
[685] | 246 | ClearGraphicsScreen()
|
---|
[1] | 247 |
|
---|
[126] | 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 |
|
---|
[411] | 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 |
|
---|
[126] | 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)
|
---|
[258] | 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)
|
---|
[126] | 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
|
---|
[121] | 304 | End With
|
---|
[126] | 305 | ImmSetCompositionWindow(himc, CompForm)
|
---|
[258] | 306 |
|
---|
| 307 | Dim lf As LOGFONT
|
---|
| 308 | GetObject(_PromptSys_hFont, Len(lf), lf)
|
---|
| 309 | ImmSetCompositionFont(himc, lf)
|
---|
[126] | 310 | End If
|
---|
| 311 | ImmReleaseContext(hwnd, himc)
|
---|
[1] | 312 |
|
---|
[126] | 313 | CreateCaret(hwnd, 0, 9, 6)
|
---|
[132] | 314 | With _PromptSys_CurPos
|
---|
| 315 | SetCaretPos(_PromptSys_TextLine[.y].CharInfo[.x].StartPos, (.y + 1) * _PromptSys_FontSize.cy - 7)
|
---|
| 316 | End With
|
---|
[126] | 317 | ShowCaret(hwnd)
|
---|
| 318 | End If
|
---|
| 319 | End Sub
|
---|
[1] | 320 |
|
---|
[126] | 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
|
---|
[1] | 351 | End If
|
---|
[126] | 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
|
---|
[142] | 357 | /*
|
---|
[126] | 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
|
---|
[121] | 363 | #ifdef UNICODE 'A版ウィンドウプロシージャ用
|
---|
[126] | 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)
|
---|
[119] | 368 | #else
|
---|
[126] | 369 | TempStr = ZeroString(lstrlen(pTemp) + 1)
|
---|
| 370 | lstrcpy(StrPtr(TempStr), pTemp)
|
---|
[119] | 371 | #endif
|
---|
[126] | 372 | memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), TempStr.Chars, SizeOf (Char) * TempStr.Length)
|
---|
| 373 | _PromptSys_InputLen += TempStr.Length
|
---|
[1] | 374 |
|
---|
[126] | 375 | GlobalUnlock(hGlobal)
|
---|
| 376 | CloseClipboard()
|
---|
[142] | 377 | */
|
---|
[126] | 378 | Else
|
---|
[272] | 379 | Dim t = wParam As TCHAR
|
---|
| 380 | TempStr = New String(VarPtr(t), 1)
|
---|
| 381 | _PromptSys_InputStr[_PromptSys_InputLen] = TempStr[0]
|
---|
[126] | 382 | _PromptSys_InputLen++
|
---|
| 383 | End If
|
---|
[1] | 384 |
|
---|
[126] | 385 | SendMessage(hwnd, WM_KILLFOCUS, 0, 0)
|
---|
[258] | 386 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(TempStr)
|
---|
[126] | 387 | SendMessage(hwnd, WM_SETFOCUS, 0, 0)
|
---|
| 388 | End If
|
---|
| 389 | End Sub
|
---|
[1] | 390 |
|
---|
[142] | 391 | Function _PromptWnd_GetCompositionStringW(himc As HIMC, ByRef rpsz As PWSTR) As Long
|
---|
| 392 | Dim size = ImmGetCompositionStringW(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位
|
---|
[411] | 393 | rpsz = GC_malloc(size) As PWSTR
|
---|
[142] | 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はバイト単位
|
---|
[411] | 403 | rpsz = GC_malloc(size) As PSTR
|
---|
[142] | 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 |
|
---|
[126] | 411 | Function _PromptWnd_OnImeCompostion(hwnd As HWND, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
[125] | 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
|
---|
[272] | 418 | Dim tempStr = Nothing As String
|
---|
[497] | 419 | Dim str As *Char
|
---|
| 420 | #ifdef UNICODE
|
---|
[258] | 421 | Dim osver = System.Environment.OSVersion
|
---|
| 422 | With osver
|
---|
[497] | 423 | ' GetCompositionStringW is not implimented in Windows 95
|
---|
[258] | 424 | If .Version.Major = 4 And .Version.Minor = 0 And .Platform = System.PlatformID.Win32Windows Then
|
---|
[142] | 425 | Dim strA As PCSTR
|
---|
| 426 | Dim sizeA = _PromptWnd_GetCompositionStringA(himc, strA)
|
---|
[272] | 427 | tempStr = New String(strA, sizeA As Long)
|
---|
[142] | 428 | Else
|
---|
| 429 | Dim size = _PromptWnd_GetCompositionStringW(himc, str)
|
---|
[272] | 430 | tempStr = New String(str, (size \ SizeOf (WCHAR)) As Long)
|
---|
[142] | 431 | End If
|
---|
| 432 | End With
|
---|
[497] | 433 | #else
|
---|
| 434 | Dim size = _PromptWnd_GetCompositionStringA(himc, str)
|
---|
| 435 | tempStr = New String(str, size As Long)
|
---|
[142] | 436 | #endif
|
---|
[125] | 437 | ImmReleaseContext(hwnd, himc)
|
---|
| 438 |
|
---|
[272] | 439 | ActiveBasic.Strings.ChrCopy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), tempStr.StrPtr, tempStr.Length As SIZE_T)
|
---|
[142] | 440 | _PromptSys_InputLen += tempStr.Length
|
---|
[125] | 441 |
|
---|
[258] | 442 | SendMessage(hwnd, WM_KILLFOCUS, 0, 0)
|
---|
| 443 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(tempStr)
|
---|
[125] | 444 | SendMessage(hwnd, WM_SETFOCUS, 0, 0)
|
---|
| 445 |
|
---|
[126] | 446 | _PromptWnd_OnImeCompostion = 0
|
---|
[125] | 447 | Else
|
---|
[126] | 448 | _PromptWnd_OnImeCompostion = DefWindowProc(hwnd, WM_IME_COMPOSITION, wp, lp)
|
---|
[125] | 449 | End If
|
---|
| 450 | End Function
|
---|
| 451 |
|
---|
[537] | 452 | Function PromptMain(data As VoidPtr) As DWord
|
---|
[1] | 453 | Dim i As Long
|
---|
| 454 | 'Allocate
|
---|
[126] | 455 | For i = 0 To 100
|
---|
| 456 | With _PromptSys_TextLine[i]
|
---|
| 457 | .Length = 0
|
---|
[497] | 458 | .Text = _System_calloc(SizeOf (Char) * 255)
|
---|
[126] | 459 | .CharInfo = _System_calloc(SizeOf (_PromptSys_CharacterInformation) * 255)
|
---|
| 460 | End With
|
---|
[1] | 461 | Next
|
---|
| 462 |
|
---|
| 463 | 'Current Colors initialize
|
---|
[126] | 464 | _PromptSys_NowTextColor = RGB(255, 255, 255)
|
---|
| 465 | _PromptSys_NowBackColor = RGB(0, 0, 0)
|
---|
[1] | 466 |
|
---|
| 467 | 'Setup
|
---|
[125] | 468 | With _PromptSys_ScreenSize
|
---|
| 469 | .cx = GetSystemMetrics(SM_CXSCREEN)
|
---|
| 470 | .cy = GetSystemMetrics(SM_CYSCREEN)
|
---|
| 471 | End With
|
---|
[1] | 472 |
|
---|
| 473 | 'Critical Section
|
---|
| 474 | InitializeCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 475 |
|
---|
| 476 | 'Regist Prompt Class
|
---|
| 477 | Dim wcl As WNDCLASSEX
|
---|
[123] | 478 | ZeroMemory(VarPtr(wcl), Len(wcl))
|
---|
| 479 | With wcl
|
---|
| 480 | .cbSize = Len(wcl)
|
---|
| 481 | .hInstance = GetModuleHandle(0)
|
---|
[126] | 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
|
---|
[258] | 486 | .lpszClassName = ToTCStr("PROMPT")
|
---|
[123] | 487 | .lpfnWndProc = AddressOf(PromptProc)
|
---|
| 488 | .hbrBackground = GetStockObject(BLACK_BRUSH)
|
---|
| 489 | End With
|
---|
[121] | 490 | Dim atom = RegisterClassEx(wcl)
|
---|
[1] | 491 |
|
---|
| 492 | 'Create Prompt Window
|
---|
[258] | 493 | _PromptSys_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, atom As ULONG_PTR As LPCTSTR, ToTCStr("BASIC PROMPT"), _
|
---|
[192] | 494 | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
|
---|
[125] | 495 | 0, 0, wcl.hInstance, 0)
|
---|
[123] | 496 | ShowWindow(_PromptSys_hWnd, SW_SHOW)
|
---|
[119] | 497 | UpdateWindow(_PromptSys_hWnd)
|
---|
[127] | 498 | SetEvent(_PromptSys_hInitFinish)
|
---|
[123] | 499 | Dim msg As MSG
|
---|
[1] | 500 | Do
|
---|
[123] | 501 | Dim iResult = GetMessage(msg, 0, 0, 0)
|
---|
[258] | 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
|
---|
[1] | 508 | TranslateMessage(msg)
|
---|
| 509 | DispatchMessage(msg)
|
---|
| 510 | Loop
|
---|
| 511 |
|
---|
[121] | 512 | '強制的に終了する
|
---|
[258] | 513 | End
|
---|
[121] | 514 |
|
---|
[1] | 515 | EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
[126] | 516 |
|
---|
| 517 | For i = 0 to 100
|
---|
| 518 | _System_free(_PromptSys_TextLine[i].Text)
|
---|
| 519 | _System_free(_PromptSys_TextLine[i].CharInfo)
|
---|
[121] | 520 | Next
|
---|
[17] | 521 |
|
---|
[1] | 522 | LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 523 |
|
---|
| 524 | DeleteCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 525 |
|
---|
[258] | 526 | End
|
---|
[1] | 527 | End Function
|
---|
| 528 |
|
---|
[685] | 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 |
|
---|
[258] | 541 | 'Prompt text command functoins
|
---|
[1] | 542 |
|
---|
[258] | 543 | Sub Cls(n As Long)
|
---|
[1] | 544 | Dim i As Long
|
---|
| 545 |
|
---|
| 546 | 'When parameter was omitted, num is set to 1
|
---|
[258] | 547 | If n = 0 Then n = 1
|
---|
[1] | 548 |
|
---|
[258] | 549 | If n = 1 Or n = 3 Then
|
---|
[1] | 550 | 'Clear the text screen
|
---|
[123] | 551 | For i = 0 To 100
|
---|
[126] | 552 | With _PromptSys_TextLine[i]
|
---|
[497] | 553 | .Text[0] = 0 '_System_FillChar(_PromptSys_TextLine[i].Text, -1 As Char, 0)
|
---|
[126] | 554 | .Length = 0
|
---|
| 555 | End With
|
---|
[1] | 556 | Next
|
---|
[123] | 557 | With _PromptSys_CurPos
|
---|
| 558 | .x = 0
|
---|
| 559 | .y = 0
|
---|
| 560 | End With
|
---|
[1] | 561 | End If
|
---|
| 562 |
|
---|
[258] | 563 | If n = 2 Or n = 3 Then
|
---|
[1] | 564 | 'Clear the graphics screen
|
---|
[685] | 565 | ClearGraphicsScreen()
|
---|
[1] | 566 | End If
|
---|
| 567 |
|
---|
| 568 | 'Redraw
|
---|
[126] | 569 | InvalidateRect(_PromptSys_hWnd, ByVal 0, 0)
|
---|
[258] | 570 | End Sub
|
---|
[1] | 571 |
|
---|
[258] | 572 | Sub Color(textColorCode As Long, backColorCode As Long)
|
---|
| 573 | _PromptSys_NowTextColor = GetBasicColor(textColorCode)
|
---|
| 574 | If backColorCode = -1 Then
|
---|
[126] | 575 | _PromptSys_NowBackColor = -1
|
---|
[1] | 576 | Else
|
---|
[258] | 577 | _PromptSys_NowBackColor = GetBasicColor(backColorCode)
|
---|
[1] | 578 | End If
|
---|
[258] | 579 | End Sub
|
---|
[1] | 580 |
|
---|
[258] | 581 | Sub INPUT_FromPrompt(showStr As String)
|
---|
[1] | 582 | *InputReStart
|
---|
| 583 |
|
---|
[258] | 584 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(showStr)
|
---|
[1] | 585 |
|
---|
| 586 | 'Input by keyboard
|
---|
[126] | 587 | _PromptSys_InputLen = 0
|
---|
| 588 | SendMessage(_PromptSys_hWnd, WM_SETFOCUS, 0, 0)
|
---|
| 589 | While _PromptSys_InputLen <> -1
|
---|
[1] | 590 | Sleep(10)
|
---|
| 591 | Wend
|
---|
[126] | 592 | SendMessage(_PromptSys_hWnd, WM_KILLFOCUS, 0, 0)
|
---|
[1] | 593 |
|
---|
| 594 | 'Set value to variable
|
---|
[497] | 595 | Const comma = &h2c As Char 'Asc(",")
|
---|
[272] | 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
|
---|
[258] | 600 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
|
---|
[1] | 601 | Goto *InputReStart
|
---|
| 602 | End If
|
---|
[635] | 603 | _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken.Item[i])
|
---|
[272] | 604 | Next
|
---|
[1] | 605 |
|
---|
[272] | 606 | If _System_InputDataPtr[i]<>0 Then
|
---|
| 607 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
|
---|
| 608 | Goto *InputReStart
|
---|
| 609 | End If
|
---|
[1] | 610 | End Sub
|
---|
| 611 |
|
---|
[258] | 612 | Sub Locate(x As Long, y As Long)
|
---|
[126] | 613 | If x < 0 Then x = 0
|
---|
| 614 | If y < 0 Then y = 0
|
---|
| 615 | If y > 100 Then y = 100
|
---|
[123] | 616 | With _PromptSys_CurPos
|
---|
| 617 | .x = x
|
---|
| 618 | .y = y
|
---|
| 619 | End With
|
---|
[1] | 620 |
|
---|
[126] | 621 | Dim i = _PromptSys_TextLine[y].Length
|
---|
[123] | 622 | If i < x Then
|
---|
[497] | 623 | ActiveBasic.Strings.ChrFill(VarPtr(_PromptSys_TextLine[y].Text[i]), x - i, &h20 As Char) 'Asc(" ")
|
---|
[126] | 624 | Dim i2 As Long
|
---|
| 625 | For i2 = i To ELM(x)
|
---|
| 626 | _PromptSys_TextLine[y].CharInfo[i2].BackColor = -1
|
---|
[1] | 627 | Next
|
---|
[126] | 628 | _PromptSys_TextLine[y].Length = x
|
---|
[1] | 629 | End If
|
---|
[258] | 630 | End Sub
|
---|
[1] | 631 |
|
---|
[258] | 632 | 'Prompt graphic command functions
|
---|
[1] | 633 |
|
---|
[684] | 634 | Sub Circle(x As Long , y As Long, radius As Double, ColorCode As Long, StartPos As Double, EndPos As Double, Aspect As Double, bFill As Long, BrushColor As Long)
|
---|
[1] | 635 | Dim i1 As Long, i2 As Long, i3 As Long, i4 As Long
|
---|
| 636 |
|
---|
[121] | 637 | Dim hPen = CreatePen(PS_SOLID,1,GetBasicColor(ColorCode))
|
---|
[126] | 638 | Dim hBrush As HBRUSH
|
---|
[1] | 639 | If bFill Then
|
---|
[126] | 640 | hBrush = CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
[1] | 641 | Else
|
---|
[126] | 642 | hBrush = GetStockObject(NULL_BRUSH)
|
---|
[1] | 643 | End If
|
---|
| 644 |
|
---|
[126] | 645 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
| 646 | Dim hOldPenDC = SelectObject(hDC, hPen)
|
---|
| 647 | Dim hOldBrushDC = SelectObject(hDC, hBrush)
|
---|
| 648 | Dim hOldPen = SelectObject(_PromptSys_hMemDC, hPen)
|
---|
| 649 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
|
---|
[1] | 650 |
|
---|
[126] | 651 | Dim radi2 As Long
|
---|
[684] | 652 | Dim iRadius As Long
|
---|
[1] | 653 | If Aspect<1 Then
|
---|
[684] | 654 | radi2 = (radius * Aspect) As Long
|
---|
| 655 | iRadius = radius As Long
|
---|
[1] | 656 | Else
|
---|
[684] | 657 | radi2 = radius As Long
|
---|
| 658 | iRadius = (radius / Aspect) As Long
|
---|
[1] | 659 | End If
|
---|
| 660 |
|
---|
| 661 | If StartPos=0 And EndPos=0 Then
|
---|
[684] | 662 | Ellipse(hDC,x-iRadius,y-radi2,x+iRadius,y+radi2)
|
---|
| 663 | Ellipse(_PromptSys_hMemDC,x-iRadius,y-radi2,x+iRadius,y+radi2)
|
---|
[1] | 664 | Else
|
---|
[411] | 665 | Dim sw As Boolean
|
---|
[684] | 666 | StartPos *= 100
|
---|
| 667 | EndPos *= 100
|
---|
[1] | 668 |
|
---|
| 669 | If StartPos<0 Or EndPos<0 Then
|
---|
[411] | 670 | sw = True
|
---|
[684] | 671 | StartPos = Math.Abs(StartPos)
|
---|
| 672 | EndPos = Math.Abs(EndPos)
|
---|
[1] | 673 | Else
|
---|
[411] | 674 | sw = False
|
---|
[1] | 675 | End If
|
---|
| 676 |
|
---|
| 677 | If StartPos<=78.5 Then
|
---|
| 678 | i1=78
|
---|
| 679 | i2=Int(StartPos)
|
---|
| 680 | ElseIf StartPos<=235.5 Then
|
---|
[90] | 681 | StartPos -= 78.5
|
---|
[1] | 682 | i1=78-Int(StartPos)
|
---|
| 683 | i2=78
|
---|
| 684 | ElseIf StartPos<=392.5 Then
|
---|
[90] | 685 | StartPos -= 235.5
|
---|
[1] | 686 | i1=-78
|
---|
| 687 | i2=78-Int(StartPos)
|
---|
| 688 | ElseIf StartPos<=549.5 Then
|
---|
[90] | 689 | StartPos -= 392.5
|
---|
[1] | 690 | i1=-78+Int(StartPos)
|
---|
| 691 | i2=-78
|
---|
| 692 | ElseIf StartPos<=628 Then
|
---|
[90] | 693 | StartPos -= 549.5
|
---|
[1] | 694 | i1=78
|
---|
| 695 | i2=-78+Int(StartPos)
|
---|
| 696 | End If
|
---|
| 697 |
|
---|
| 698 | If EndPos<=78.5 Then
|
---|
| 699 | i3=78
|
---|
| 700 | i4=Int(EndPos)
|
---|
| 701 | ElseIf EndPos<=235.5 Then
|
---|
[90] | 702 | EndPos -= 78.5
|
---|
[1] | 703 | i3=78-Int(EndPos)
|
---|
| 704 | i4=78
|
---|
| 705 | ElseIf EndPos<=392.5 Then
|
---|
[90] | 706 | EndPos -= 235.5
|
---|
[1] | 707 | i3=-78
|
---|
| 708 | i4=78-Int(EndPos)
|
---|
| 709 | ElseIf EndPos<=549.5 Then
|
---|
[90] | 710 | EndPos -= 392.5
|
---|
[1] | 711 | i3=-78+Int(EndPos)
|
---|
| 712 | i4=-78
|
---|
| 713 | ElseIf EndPos<=628 Then
|
---|
[90] | 714 | EndPos -= 549.5
|
---|
[1] | 715 | i3=78
|
---|
| 716 | i4=-78+Int(EndPos)
|
---|
| 717 | End If
|
---|
| 718 |
|
---|
| 719 | If sw Then
|
---|
[684] | 720 | Pie(hDC,x-iRadius,y-radi2,x+iRadius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 721 | Pie(_PromptSys_hMemDC,x-iRadius,y-radi2,x+iRadius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
[1] | 722 | Else
|
---|
[684] | 723 | Arc(hDC,x-iRadius,y-radi2,x+iRadius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 724 | Arc(_PromptSys_hMemDC,x-iRadius,y-radi2,x+iRadius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
[1] | 725 | End If
|
---|
| 726 | End If
|
---|
| 727 |
|
---|
[126] | 728 | SelectObject(hDC, hOldPenDC)
|
---|
| 729 | SelectObject(hDC, hOldBrushDC)
|
---|
| 730 | ReleaseDC(_PromptSys_hWnd, hDC)
|
---|
| 731 | SelectObject(_PromptSys_hMemDC, hOldPen)
|
---|
| 732 | SelectObject(_PromptSys_hMemDC, hOldBrush)
|
---|
[1] | 733 | DeleteObject(hPen)
|
---|
| 734 | If bFill Then DeleteObject(hBrush)
|
---|
[258] | 735 | End Sub
|
---|
[1] | 736 |
|
---|
[258] | 737 | 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] | 738 | Dim temp As Long
|
---|
| 739 |
|
---|
[126] | 740 | If sx = &H80000000 And sy = &H80000000 Then
|
---|
| 741 | With _PromptSys_GlobalPos
|
---|
| 742 | sx = .x
|
---|
| 743 | sy = .y
|
---|
| 744 | End With
|
---|
[1] | 745 | End If
|
---|
| 746 |
|
---|
| 747 | If bStep Then
|
---|
[90] | 748 | ex += sx
|
---|
| 749 | ey += sy
|
---|
[1] | 750 | Else
|
---|
| 751 | If fType Then
|
---|
| 752 | 'ラインの場合(四角形でない場合)
|
---|
| 753 | If sx>ex Then
|
---|
| 754 | temp=ex
|
---|
| 755 | ex=sx
|
---|
| 756 | sx=temp
|
---|
| 757 | End If
|
---|
| 758 | If sy>ey Then
|
---|
| 759 | temp=ey
|
---|
| 760 | ey=sy
|
---|
| 761 | sy=temp
|
---|
| 762 | End If
|
---|
| 763 | End If
|
---|
| 764 | End If
|
---|
| 765 |
|
---|
[258] | 766 | Dim hdc = GetDC(_PromptSys_hWnd)
|
---|
[121] | 767 | Dim hPen = CreatePen(PS_SOLID, 1, GetBasicColor(ColorCode))
|
---|
| 768 | Dim hBrush As HBRUSH
|
---|
[1] | 769 | If fType=2 Then
|
---|
[126] | 770 | hBrush = CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
[1] | 771 | Else
|
---|
[126] | 772 | hBrush = GetStockObject(NULL_BRUSH)
|
---|
[1] | 773 | End If
|
---|
| 774 |
|
---|
[258] | 775 | SelectObject(hdc, hPen)
|
---|
| 776 | SelectObject(hdc, hBrush)
|
---|
[126] | 777 | Dim hOldPen = SelectObject(_PromptSys_hMemDC, hPen)
|
---|
| 778 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
|
---|
[1] | 779 |
|
---|
| 780 | Select Case fType
|
---|
| 781 | Case 0
|
---|
| 782 | 'line
|
---|
| 783 | MoveToEx(_PromptSys_hMemDC,sx,sy,ByVal NULL)
|
---|
| 784 | LineTo(_PromptSys_hMemDC,ex,ey)
|
---|
| 785 | SetPixel(_PromptSys_hMemDC,ex,ey,GetBasicColor(ColorCode))
|
---|
[258] | 786 | MoveToEx(hdc,sx,sy,ByVal NULL)
|
---|
| 787 | LineTo(hdc,ex,ey)
|
---|
| 788 | SetPixel(hdc,ex,ey,GetBasicColor(ColorCode))
|
---|
[1] | 789 | Case Else
|
---|
| 790 | 'Rectangle
|
---|
[258] | 791 | Rectangle(hdc,sx,sy,ex+1,ey+1)
|
---|
[1] | 792 | Rectangle(_PromptSys_hMemDC,sx,sy,ex+1,ey+1)
|
---|
| 793 | End Select
|
---|
| 794 |
|
---|
[258] | 795 | ReleaseDC(_PromptSys_hWnd,hdc)
|
---|
[1] | 796 | SelectObject(_PromptSys_hMemDC,hOldPen)
|
---|
| 797 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
| 798 | DeleteObject(hPen)
|
---|
[126] | 799 | If fType = 2 Then DeleteObject(hBrush)
|
---|
| 800 | With _PromptSys_GlobalPos
|
---|
| 801 | .x = ex
|
---|
| 802 | .y = ey
|
---|
| 803 | End With
|
---|
[258] | 804 | End Sub
|
---|
[1] | 805 |
|
---|
[258] | 806 | Sub PSet(x As Long, y As Long, ColorCode As Long)
|
---|
| 807 | Dim hdc = GetDC(_PromptSys_hWnd)
|
---|
| 808 | SetPixel(hdc, x, y, GetBasicColor(ColorCode))
|
---|
[126] | 809 | SetPixel(_PromptSys_hMemDC, x, y, GetBasicColor(ColorCode))
|
---|
[258] | 810 | ReleaseDC(_PromptSys_hWnd, hdc)
|
---|
[126] | 811 | With _PromptSys_GlobalPos
|
---|
| 812 | .x = x
|
---|
| 813 | .y = y
|
---|
| 814 | End With
|
---|
[258] | 815 | End Sub
|
---|
[1] | 816 |
|
---|
[258] | 817 | Sub Paint(x As Long, y As Long, BrushColor As Long, LineColor As Long)
|
---|
| 818 | Dim hbr = CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
[1] | 819 |
|
---|
[258] | 820 | Dim hdc = GetDC(_PromptSys_hWnd)
|
---|
| 821 | Dim hbrOld = SelectObject(_PromptSys_hMemDC, hbr)
|
---|
| 822 | Dim hbrOldWndDC = SelectObject(hdc, hbr)
|
---|
[1] | 823 |
|
---|
[258] | 824 | ExtFloodFill(hdc, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
|
---|
[126] | 825 | ExtFloodFill(_PromptSys_hMemDC, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
|
---|
[1] | 826 |
|
---|
[258] | 827 | ReleaseDC(_PromptSys_hWnd, hdc)
|
---|
| 828 | SelectObject(_PromptSys_hMemDC, hbrOld)
|
---|
| 829 | SelectObject(hdc, hbrOldWndDC)
|
---|
| 830 | DeleteObject(hbr)
|
---|
| 831 | End Sub
|
---|
[1] | 832 |
|
---|
| 833 | Function Inkey$() As String
|
---|
| 834 | If _PromptSys_KeyChar=0 Then
|
---|
| 835 | Inkey$=""
|
---|
| 836 | Else
|
---|
| 837 | Inkey$=Chr$(_PromptSys_KeyChar)
|
---|
| 838 | End If
|
---|
| 839 | _PromptSys_KeyChar=0
|
---|
| 840 | End Function
|
---|
| 841 |
|
---|
| 842 | Function Input$(length As Long) As String
|
---|
[258] | 843 | Dim i = 0 As Long
|
---|
[1] | 844 |
|
---|
| 845 | If length<=0 Then
|
---|
| 846 | Input$=""
|
---|
| 847 | Exit Function
|
---|
| 848 | End If
|
---|
| 849 |
|
---|
| 850 | While 1
|
---|
| 851 | If _PromptSys_KeyChar Then
|
---|
| 852 | Input$=Input$+Chr$(_PromptSys_KeyChar)
|
---|
| 853 | _PromptSys_KeyChar=0
|
---|
[90] | 854 | i++
|
---|
[126] | 855 | If i >= length Then
|
---|
[1] | 856 | Exit While
|
---|
| 857 | End If
|
---|
| 858 | End If
|
---|
| 859 | Sleep(1)
|
---|
| 860 | Wend
|
---|
| 861 | End Function
|
---|
| 862 |
|
---|
[258] | 863 | End Namespace 'Detail
|
---|
[1] | 864 |
|
---|
[258] | 865 | Function OwnerWnd() As HWND
|
---|
| 866 | Return Detail._PromptSys_hWnd
|
---|
| 867 | End Function
|
---|
| 868 |
|
---|
| 869 | End Namespace 'Prompt
|
---|
| 870 | End Namespace 'ActiveBasic
|
---|
| 871 |
|
---|
| 872 | '----------------------
|
---|
| 873 | ' Prompt text Commands
|
---|
| 874 | '----------------------
|
---|
| 875 |
|
---|
| 876 | Sub PRINT_ToPrompt(s As String)
|
---|
| 877 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(s)
|
---|
| 878 | End Sub
|
---|
| 879 |
|
---|
| 880 | Macro CLS()(num As Long)
|
---|
| 881 | ActiveBasic.Prompt.Detail.Cls(num)
|
---|
| 882 | End Macro
|
---|
| 883 |
|
---|
| 884 | Macro COLOR(TextColorCode As Long)(BackColorCode As Long)
|
---|
| 885 | ActiveBasic.Prompt.Detail.Color(TextColorCode, BackColorCode)
|
---|
| 886 | End Macro
|
---|
| 887 |
|
---|
| 888 | '---------- Defined in "command.sbp" ----------
|
---|
| 889 | 'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
|
---|
| 890 | 'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
|
---|
| 891 | '----------------------------------------------
|
---|
| 892 | Sub INPUT_FromPrompt(ShowStr As String)
|
---|
| 893 | ActiveBasic.Prompt.Detail.INPUT_FromPrompt(ShowStr)
|
---|
| 894 | End Sub
|
---|
| 895 |
|
---|
[288] | 896 | /* TODO: _System_GetUsingFormatを用意して実装する
|
---|
[258] | 897 | Sub PRINTUSING_ToPrompt(UsingStr As String)
|
---|
| 898 | ActiveBasic.Prompt.Detail.PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
|
---|
| 899 | End Sub
|
---|
[288] | 900 | */
|
---|
[258] | 901 |
|
---|
[684] | 902 | Macro LOCATE(x As Double, y As Double)
|
---|
| 903 | ActiveBasic.Prompt.Detail.Locate(x As Long, y As Long)
|
---|
[258] | 904 | End Macro
|
---|
| 905 |
|
---|
| 906 |
|
---|
| 907 | '-------------------
|
---|
| 908 | ' Graphics Commands
|
---|
| 909 | '-------------------
|
---|
| 910 |
|
---|
[684] | 911 | 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)
|
---|
[258] | 912 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 913 | 'Circle (x, y), radius [, color] [, start] [, end] [, aspect] [, f] [, color2]
|
---|
[684] | 914 | ActiveBasic.Prompt.Detail.Circle(x As Long, y As Long, radius, ColorCode, StartPos, EndPos, Aspect, bFill, BrushColor)
|
---|
[258] | 915 | End Macro
|
---|
| 916 |
|
---|
[684] | 917 | 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)
|
---|
[258] | 918 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 919 | 'Line (sx,sy)-[STEP](ex,ey),[ColorCode],[B/Bf],[BrushColor]
|
---|
[684] | 920 | ActiveBasic.Prompt.Detail.Line(sx As Long, sy As Long, bStep, ex As Long, ey As Long, ColorCode, fType, BrushColor)
|
---|
[258] | 921 | End Macro
|
---|
| 922 |
|
---|
[684] | 923 | Macro PSET(x As Double, y As Double)(ColorCode As Long)
|
---|
[258] | 924 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 925 | 'PSet (x,y),ColorCode
|
---|
[684] | 926 | ActiveBasic.Prompt.Detail.PSet(x As Long, y As Long, ColorCode)
|
---|
[258] | 927 | End Macro
|
---|
| 928 |
|
---|
[684] | 929 | Macro PAINT(x As Double, y As Double, BrushColor As Long)(ByVal LineColor As Long)
|
---|
[258] | 930 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 931 | 'Paint (x,y),BrushColor,LineColor
|
---|
[684] | 932 | ActiveBasic.Prompt.Detail.Paint(x As Long, y As Long, BrushColor, LineColor)
|
---|
[258] | 933 | End Macro
|
---|
| 934 |
|
---|
| 935 |
|
---|
| 936 | '-----------
|
---|
| 937 | ' Functions
|
---|
| 938 | '-----------
|
---|
| 939 |
|
---|
| 940 | Function Inkey$() As String
|
---|
| 941 | Return ActiveBasic.Prompt.Detail.Inkey$()
|
---|
| 942 | End Function
|
---|
| 943 |
|
---|
| 944 | Function Input$(length As Long) As String
|
---|
| 945 | Return ActiveBasic.Prompt.Detail.Input$(length)
|
---|
| 946 | End Function
|
---|
| 947 |
|
---|
| 948 | ActiveBasic.Prompt.Detail._PromptSys_Initialize()
|
---|
| 949 |
|
---|
| 950 | #endif '_INC_PROMPT
|
---|