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