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