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