[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 |
|
---|
[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 |
|
---|
[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
|
---|
| 138 | Dim currentLineCharInfo = _PromptSys_TextLine[.y].CharInfo As *_PromptSys_CharacterInformation
|
---|
| 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)
|
---|
| 259 | ImmSetCompositionFontA(himc, _PromptSys_LogFont)
|
---|
| 260 | End If
|
---|
| 261 | ImmReleaseContext(hwnd, himc)
|
---|
[1] | 262 |
|
---|
[126] | 263 | CreateCaret(hwnd, 0, 9, 6)
|
---|
| 264 | SetCaretPos(_PromptSys_CurPos.x * _PromptSys_FontSize.cx, (_PromptSys_CurPos.y + 1) * _PromptSys_FontSize.cy - 7)
|
---|
| 265 | ShowCaret(hwnd)
|
---|
| 266 | End If
|
---|
| 267 | End Sub
|
---|
[1] | 268 |
|
---|
[126] | 269 | Sub _PromptWnd_OnKillForcus(hwnd As HWND, hwndNewFocus As HWND)
|
---|
| 270 | HideCaret(hwnd)
|
---|
| 271 | DestroyCaret()
|
---|
| 272 | End Sub
|
---|
| 273 |
|
---|
| 274 | Sub _PromptWnd_OnKeyDown(vk As DWord, repeat As DWord, flags As DWord)
|
---|
| 275 | If _PromptSys_InputLen = -1 Then
|
---|
| 276 | _PromptSys_KeyChar = vk As Byte
|
---|
| 277 | End If
|
---|
| 278 | End Sub
|
---|
| 279 |
|
---|
| 280 | Sub _PromptWnd_OnDestroy(hwnd As HWND)
|
---|
| 281 | DeleteDC(_PromptSys_hMemDC)
|
---|
| 282 | DeleteObject(_PromptSys_hBitmap)
|
---|
| 283 |
|
---|
| 284 | PostQuitMessage(0)
|
---|
| 285 | End Sub
|
---|
| 286 |
|
---|
| 287 | Sub _PromptWnd_OnChar(hwnd As HWND, wParam As WPARAM, lParam As LPARAM)
|
---|
| 288 | Dim TempStr As String
|
---|
| 289 | If _PromptSys_InputLen <> -1 Then
|
---|
| 290 | If wParam = VK_BACK Then
|
---|
| 291 | If _PromptSys_InputLen Then
|
---|
| 292 | _PromptSys_InputLen--
|
---|
| 293 | _PromptSys_InputStr[_PromptSys_InputLen] = 0
|
---|
| 294 |
|
---|
| 295 | _PromptSys_CurPos.x--
|
---|
| 296 | With _PromptSys_CurPos
|
---|
| 297 | _PromptSys_TextLine[.y].Text[.x] = 0
|
---|
| 298 | End With
|
---|
[1] | 299 | End If
|
---|
[126] | 300 | ElseIf wParam = VK_RETURN Then
|
---|
| 301 | _PromptSys_InputStr[_PromptSys_InputLen] = 0
|
---|
| 302 | _PromptSys_InputLen = -1
|
---|
| 303 | TempStr = Ex"\r\n"
|
---|
| 304 | ElseIf wParam = &H16 Then
|
---|
| 305 | 'Paste Command(Use Clippboard)
|
---|
| 306 | OpenClipboard(hwnd)
|
---|
| 307 | Dim hGlobal = GetClipboardData(CF_TEXT) As HGLOBAL
|
---|
| 308 | If hGlobal = 0 Then Exit Sub
|
---|
| 309 | Dim pTemp = GlobalLock(hGlobal) As PCSTR
|
---|
[121] | 310 | #ifdef UNICODE 'A版ウィンドウプロシージャ用
|
---|
[126] | 311 | Dim tempSizeA = lstrlenA(pTemp)
|
---|
| 312 | Dim tempSizeW = MultiByteToWideChar(CP_ACP, 0, pTemp, tempSizeA, 0, 0) + 1
|
---|
| 313 | TempStr = ZeroString(tempSizeW)
|
---|
| 314 | MultiByteToWideChar(CP_ACP, 0, pTemp, tempSizeA, StrPtr(TempStr), tempSizeW)
|
---|
[119] | 315 | #else
|
---|
[126] | 316 | TempStr = ZeroString(lstrlen(pTemp) + 1)
|
---|
| 317 | lstrcpy(StrPtr(TempStr), pTemp)
|
---|
[119] | 318 | #endif
|
---|
[126] | 319 | memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), TempStr.Chars, SizeOf (Char) * TempStr.Length)
|
---|
| 320 | _PromptSys_InputLen += TempStr.Length
|
---|
[1] | 321 |
|
---|
[126] | 322 | GlobalUnlock(hGlobal)
|
---|
| 323 | CloseClipboard()
|
---|
| 324 | Else
|
---|
| 325 | _PromptSys_InputStr[_PromptSys_InputLen] = wParam As Byte
|
---|
| 326 | _PromptSys_InputLen++
|
---|
[1] | 327 |
|
---|
[126] | 328 | TempStr.ReSize(1)
|
---|
| 329 | TempStr[0] = wParam As Char
|
---|
| 330 | End If
|
---|
[1] | 331 |
|
---|
[126] | 332 | SendMessage(hwnd, WM_KILLFOCUS, 0, 0)
|
---|
| 333 | PRINT_ToPrompt(TempStr)
|
---|
| 334 | SendMessage(hwnd, WM_SETFOCUS, 0, 0)
|
---|
| 335 | End If
|
---|
| 336 | End Sub
|
---|
[1] | 337 |
|
---|
[126] | 338 | Function _PromptWnd_OnImeCompostion(hwnd As HWND, wp As WPARAM, lp As LPARAM) As LRESULT
|
---|
[125] | 339 | If (lp And GCS_RESULTSTR) <> 0 Then
|
---|
| 340 | Dim himc = ImmGetContext(hwnd)
|
---|
| 341 | If himc = 0 Then
|
---|
| 342 | 'Debug
|
---|
| 343 | Return 0
|
---|
| 344 | End If
|
---|
| 345 | Dim size = ImmGetCompositionString(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位
|
---|
| 346 | Dim str = _System_malloc(size) As PTSTR
|
---|
| 347 | If str = 0 Then
|
---|
| 348 | 'Debug
|
---|
| 349 | Return 0
|
---|
| 350 | End If
|
---|
| 351 | ImmGetCompositionString(himc, GCS_RESULTSTR, str, size)
|
---|
| 352 | ImmReleaseContext(hwnd, himc)
|
---|
| 353 |
|
---|
| 354 | memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), str, size)
|
---|
| 355 | _PromptSys_InputLen += size
|
---|
| 356 |
|
---|
| 357 | Dim tempStr As String(str, size \ SizeOf (Char))
|
---|
| 358 | _System_free(str)
|
---|
| 359 |
|
---|
| 360 | SendMessage(hwnd, WM_KILLFOCUS, 0, 0)
|
---|
| 361 | PRINT_ToPrompt(tempStr)
|
---|
| 362 | SendMessage(hwnd, WM_SETFOCUS, 0, 0)
|
---|
| 363 |
|
---|
[126] | 364 | _PromptWnd_OnImeCompostion = 0
|
---|
[125] | 365 | Else
|
---|
[126] | 366 | _PromptWnd_OnImeCompostion = DefWindowProc(hwnd, WM_IME_COMPOSITION, wp, lp)
|
---|
[125] | 367 | End If
|
---|
| 368 | End Function
|
---|
| 369 |
|
---|
[1] | 370 | Function PromptMain(dwData As Long) As Long
|
---|
| 371 | Dim i As Long
|
---|
| 372 |
|
---|
| 373 | 'Allocate
|
---|
[126] | 374 | For i = 0 To 100
|
---|
| 375 | With _PromptSys_TextLine[i]
|
---|
| 376 | .Length = 0
|
---|
| 377 | .Text = _System_calloc(SizeOf (Char) * 255)
|
---|
| 378 | .CharInfo = _System_calloc(SizeOf (_PromptSys_CharacterInformation) * 255)
|
---|
| 379 | End With
|
---|
[1] | 380 | Next
|
---|
| 381 |
|
---|
| 382 | 'Current Colors initialize
|
---|
[126] | 383 | _PromptSys_NowTextColor = RGB(255, 255, 255)
|
---|
| 384 | _PromptSys_NowBackColor = RGB(0, 0, 0)
|
---|
[1] | 385 |
|
---|
| 386 | 'Setup
|
---|
[125] | 387 | With _PromptSys_ScreenSize
|
---|
| 388 | .cx = GetSystemMetrics(SM_CXSCREEN)
|
---|
| 389 | .cy = GetSystemMetrics(SM_CYSCREEN)
|
---|
| 390 | End With
|
---|
[1] | 391 |
|
---|
| 392 | 'LogFont initialize
|
---|
[121] | 393 | With _PromptSys_LogFont
|
---|
| 394 | .lfHeight = -16
|
---|
| 395 | .lfWidth = 0
|
---|
| 396 | .lfEscapement = 0
|
---|
| 397 | .lfOrientation = 0
|
---|
| 398 | .lfWeight = 0
|
---|
| 399 | .lfItalic = 0
|
---|
| 400 | .lfUnderline = 0
|
---|
| 401 | .lfStrikeOut = 0
|
---|
| 402 | .lfCharSet = SHIFTJIS_CHARSET
|
---|
| 403 | .lfOutPrecision = OUT_DEFAULT_PRECIS
|
---|
| 404 | .lfClipPrecision = CLIP_DEFAULT_PRECIS
|
---|
| 405 | .lfQuality = DEFAULT_QUALITY
|
---|
| 406 | .lfPitchAndFamily = FIXED_PITCH
|
---|
[125] | 407 | #ifdef UNICODE
|
---|
| 408 | WideCharToMultiByte(CP_ACP, 0, "MS 明朝", 5, .lfFaceName, LF_FACESIZE, 0, 0)
|
---|
| 409 | #else
|
---|
[121] | 410 | lstrcpy(.lfFaceName, "MS 明朝")
|
---|
[125] | 411 | #endif
|
---|
[121] | 412 | End With
|
---|
[1] | 413 |
|
---|
[126] | 414 | _PromptSys_hFont = CreateFontIndirectA(_PromptSys_LogFont)
|
---|
[1] | 415 |
|
---|
| 416 | 'Critical Section
|
---|
| 417 | InitializeCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 418 |
|
---|
| 419 | 'Regist Prompt Class
|
---|
| 420 | Dim wcl As WNDCLASSEX
|
---|
[123] | 421 | ZeroMemory(VarPtr(wcl), Len(wcl))
|
---|
| 422 | With wcl
|
---|
| 423 | .cbSize = Len(wcl)
|
---|
| 424 | .hInstance = GetModuleHandle(0)
|
---|
[126] | 425 | .style = CS_HREDRAW Or CS_VREDRAW' or CS_DBLCLKS
|
---|
| 426 | .hIcon = LoadImage(0, MAKEINTRESOURCE(IDI_APPLICATION), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HICON
|
---|
| 427 | .hIconSm = LoadImage(0, MAKEINTRESOURCE(IDI_WINLOGO), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HICON
|
---|
| 428 | .hCursor = LoadImage(0, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HCURSOR
|
---|
[123] | 429 | .lpszClassName = "PROMPT"
|
---|
| 430 | .lpfnWndProc = AddressOf(PromptProc)
|
---|
| 431 | .hbrBackground = GetStockObject(BLACK_BRUSH)
|
---|
| 432 | End With
|
---|
[121] | 433 | Dim atom = RegisterClassEx(wcl)
|
---|
[1] | 434 |
|
---|
| 435 | 'Create Prompt Window
|
---|
[125] | 436 | _PromptSys_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, atom As ULONG_PTR As PCSTR, "BASIC PROMPT",
|
---|
| 437 | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
| 438 | 0, 0, wcl.hInstance, 0)
|
---|
[123] | 439 | ShowWindow(_PromptSys_hWnd, SW_SHOW)
|
---|
[119] | 440 | UpdateWindow(_PromptSys_hWnd)
|
---|
[127] | 441 | SetEvent(_PromptSys_hInitFinish)
|
---|
[123] | 442 | Dim msg As MSG
|
---|
[1] | 443 | Do
|
---|
[123] | 444 | Dim iResult = GetMessage(msg, 0, 0, 0)
|
---|
[126] | 445 | If iResult = 0 Or iResult = -1 Then Exit Do
|
---|
[1] | 446 | TranslateMessage(msg)
|
---|
| 447 | DispatchMessage(msg)
|
---|
| 448 | Loop
|
---|
| 449 |
|
---|
[121] | 450 | '強制的に終了する
|
---|
| 451 | ExitProcess(0)
|
---|
| 452 |
|
---|
[1] | 453 | EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
[126] | 454 |
|
---|
| 455 | For i = 0 to 100
|
---|
| 456 | _System_free(_PromptSys_TextLine[i].Text)
|
---|
| 457 | _System_free(_PromptSys_TextLine[i].CharInfo)
|
---|
[121] | 458 | Next
|
---|
[17] | 459 |
|
---|
[1] | 460 | LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 461 |
|
---|
| 462 | DeleteCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 463 |
|
---|
| 464 | ExitProcess(0)
|
---|
| 465 | End Function
|
---|
| 466 |
|
---|
| 467 |
|
---|
| 468 | '----------------------
|
---|
| 469 | ' Prompt text Commands
|
---|
| 470 | '----------------------
|
---|
| 471 |
|
---|
| 472 | Macro CLS()(num As Long)
|
---|
| 473 | Dim i As Long
|
---|
| 474 |
|
---|
| 475 | 'When parameter was omitted, num is set to 1
|
---|
[126] | 476 | If num = 0 Then num = 1
|
---|
[1] | 477 |
|
---|
[126] | 478 | If num = 1 Or num = 3 Then
|
---|
[1] | 479 | 'Clear the text screen
|
---|
[123] | 480 | For i = 0 To 100
|
---|
[126] | 481 | With _PromptSys_TextLine[i]
|
---|
| 482 | .Text[0] = 0 '_System_FillChar(_PromptSys_TextLine[i].Text, -1 As Char, 0)
|
---|
| 483 | .Length = 0
|
---|
| 484 | End With
|
---|
[1] | 485 | Next
|
---|
[123] | 486 | With _PromptSys_CurPos
|
---|
| 487 | .x = 0
|
---|
| 488 | .y = 0
|
---|
| 489 | End With
|
---|
[1] | 490 | End If
|
---|
| 491 |
|
---|
[126] | 492 | If num = 2 Or num = 3 Then
|
---|
[1] | 493 | 'Clear the graphics screen
|
---|
[126] | 494 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, GetStockObject(BLACK_BRUSH))
|
---|
| 495 | With _PromptSys_ScreenSize
|
---|
| 496 | PatBlt(_PromptSys_hMemDC, 0, 0, .cx, .cy, PATCOPY)
|
---|
| 497 | End With
|
---|
| 498 | SelectObject(_PromptSys_hMemDC, hOldBrush)
|
---|
[1] | 499 | End If
|
---|
| 500 |
|
---|
| 501 | 'Redraw
|
---|
[126] | 502 | InvalidateRect(_PromptSys_hWnd, ByVal 0, 0)
|
---|
[1] | 503 | End Macro
|
---|
| 504 |
|
---|
| 505 | Macro COLOR(TextColorCode As Long)(BackColorCode As Long)
|
---|
[126] | 506 | _PromptSys_NowTextColor = GetBasicColor(TextColorCode)
|
---|
| 507 | If BackColorCode = -1 Then
|
---|
| 508 | _PromptSys_NowBackColor = -1
|
---|
[1] | 509 | Else
|
---|
[126] | 510 | _PromptSys_NowBackColor = GetBasicColor(BackColorCode)
|
---|
[1] | 511 | End If
|
---|
| 512 | End Macro
|
---|
| 513 |
|
---|
| 514 | '---------- Defined in "command.sbp" ----------
|
---|
| 515 | 'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
|
---|
| 516 | 'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
|
---|
| 517 | '----------------------------------------------
|
---|
| 518 | Sub INPUT_FromPrompt(ShowStr As String)
|
---|
| 519 | Dim i As Long ,i2 As Long, i3 As Long
|
---|
| 520 | Dim buf As String
|
---|
| 521 |
|
---|
| 522 | *InputReStart
|
---|
| 523 |
|
---|
| 524 | PRINT_ToPrompt(ShowStr)
|
---|
| 525 |
|
---|
| 526 | 'Input by keyboard
|
---|
[126] | 527 | _PromptSys_InputLen = 0
|
---|
| 528 | SendMessage(_PromptSys_hWnd, WM_SETFOCUS, 0, 0)
|
---|
| 529 | While _PromptSys_InputLen <> -1
|
---|
[1] | 530 | Sleep(10)
|
---|
| 531 | Wend
|
---|
[126] | 532 | SendMessage(_PromptSys_hWnd, WM_KILLFOCUS, 0, 0)
|
---|
[1] | 533 |
|
---|
| 534 | 'Set value to variable
|
---|
[121] | 535 | i = 0
|
---|
| 536 | i2 = 0
|
---|
| 537 | buf = ZeroString(lstrlen(_PromptSys_InputStr))
|
---|
[1] | 538 | While 1
|
---|
[121] | 539 | i3 = 0
|
---|
[1] | 540 | While 1
|
---|
[121] | 541 | If _PromptSys_InputStr[i2] = &h2c Then
|
---|
| 542 | buf.Chars[i3] = 0
|
---|
[1] | 543 | Exit While
|
---|
| 544 | End If
|
---|
| 545 |
|
---|
[121] | 546 | buf.Chars[i3] = _PromptSys_InputStr[i2]
|
---|
[1] | 547 |
|
---|
[121] | 548 | If _PromptSys_InputStr[i2] = 0 Then Exit While
|
---|
[1] | 549 |
|
---|
[90] | 550 | i2++
|
---|
| 551 | i3++
|
---|
[1] | 552 | Wend
|
---|
| 553 |
|
---|
[121] | 554 | _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
|
---|
[1] | 555 |
|
---|
[90] | 556 | i++
|
---|
[126] | 557 | If _System_InputDataPtr[i] = 0 and _PromptSys_InputStr[i2] = &h2c Then 'Asc(",")
|
---|
[1] | 558 | PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
|
---|
| 559 | Goto *InputReStart
|
---|
[126] | 560 | ElseIf _PromptSys_InputStr[i2] = 0 Then
|
---|
[1] | 561 | If _System_InputDataPtr[i]<>0 Then
|
---|
| 562 | PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
|
---|
| 563 | Goto *InputReStart
|
---|
| 564 | Else
|
---|
| 565 | Exit While
|
---|
| 566 | End If
|
---|
| 567 | End If
|
---|
| 568 |
|
---|
[121] | 569 | i2++
|
---|
[1] | 570 | Wend
|
---|
| 571 | End Sub
|
---|
| 572 |
|
---|
| 573 | Sub PRINTUSING_ToPrompt(UsingStr As String)
|
---|
| 574 | PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
|
---|
| 575 | End Sub
|
---|
| 576 |
|
---|
| 577 | Macro LOCATE(x As Long, y As Long)
|
---|
[126] | 578 | If x < 0 Then x = 0
|
---|
| 579 | If y < 0 Then y = 0
|
---|
| 580 | If y > 100 Then y = 100
|
---|
[123] | 581 | With _PromptSys_CurPos
|
---|
| 582 | .x = x
|
---|
| 583 | .y = y
|
---|
| 584 | End With
|
---|
[1] | 585 |
|
---|
[126] | 586 | Dim i = _PromptSys_TextLine[y].Length
|
---|
[123] | 587 | If i < x Then
|
---|
[126] | 588 | _System_FillChar(VarPtr(_PromptSys_TextLine[y].Text[i]), x - i, &h20) 'Asc(" ")
|
---|
| 589 | Dim i2 As Long
|
---|
| 590 | For i2 = i To ELM(x)
|
---|
| 591 | _PromptSys_TextLine[y].CharInfo[i2].BackColor = -1
|
---|
[1] | 592 | Next
|
---|
[126] | 593 | _PromptSys_TextLine[y].Length = x
|
---|
[1] | 594 | End If
|
---|
| 595 | End Macro
|
---|
| 596 |
|
---|
| 597 |
|
---|
| 598 | '-------------------
|
---|
| 599 | ' Graphics Commands
|
---|
| 600 | '-------------------
|
---|
| 601 |
|
---|
| 602 | 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)
|
---|
| 603 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 604 | 'Circle (x, y), radius [, color] [, start] [, end] [, aspect] [, f] [, color2]
|
---|
| 605 |
|
---|
| 606 | Dim i1 As Long, i2 As Long, i3 As Long, i4 As Long
|
---|
| 607 |
|
---|
[121] | 608 | Dim hPen = CreatePen(PS_SOLID,1,GetBasicColor(ColorCode))
|
---|
[126] | 609 | Dim hBrush As HBRUSH
|
---|
[1] | 610 | If bFill Then
|
---|
[126] | 611 | hBrush = CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
[1] | 612 | Else
|
---|
[126] | 613 | hBrush = GetStockObject(NULL_BRUSH)
|
---|
[1] | 614 | End If
|
---|
| 615 |
|
---|
[126] | 616 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
| 617 | Dim hOldPenDC = SelectObject(hDC, hPen)
|
---|
| 618 | Dim hOldBrushDC = SelectObject(hDC, hBrush)
|
---|
| 619 | Dim hOldPen = SelectObject(_PromptSys_hMemDC, hPen)
|
---|
| 620 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
|
---|
[1] | 621 |
|
---|
[126] | 622 | Dim radi2 As Long
|
---|
[1] | 623 | If Aspect<1 Then
|
---|
[89] | 624 | radi2=(CDbl(radius)*Aspect) As Long
|
---|
[1] | 625 | Else
|
---|
| 626 | radi2=radius
|
---|
[89] | 627 | radius=(CDbl(radius)/Aspect) As Long
|
---|
[1] | 628 | End If
|
---|
| 629 |
|
---|
| 630 | If StartPos=0 And EndPos=0 Then
|
---|
| 631 | Ellipse(hDC,x-radius,y-radi2,x+radius,y+radi2)
|
---|
| 632 | Ellipse(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2)
|
---|
| 633 | Else
|
---|
[126] | 634 | Dim sw As Long
|
---|
[90] | 635 | StartPos *=StartPos
|
---|
| 636 | EndPos *=EndPos
|
---|
[1] | 637 |
|
---|
| 638 | If StartPos<0 Or EndPos<0 Then
|
---|
| 639 | sw=1
|
---|
| 640 | Else
|
---|
| 641 | sw=0
|
---|
| 642 | End If
|
---|
| 643 |
|
---|
[90] | 644 | StartPos = Abs(StartPos)
|
---|
| 645 | EndPos = Abs(EndPos)
|
---|
[1] | 646 |
|
---|
| 647 | If StartPos<=78.5 Then
|
---|
| 648 | i1=78
|
---|
| 649 | i2=Int(StartPos)
|
---|
| 650 | ElseIf StartPos<=235.5 Then
|
---|
[90] | 651 | StartPos -= 78.5
|
---|
[1] | 652 | i1=78-Int(StartPos)
|
---|
| 653 | i2=78
|
---|
| 654 | ElseIf StartPos<=392.5 Then
|
---|
[90] | 655 | StartPos -= 235.5
|
---|
[1] | 656 | i1=-78
|
---|
| 657 | i2=78-Int(StartPos)
|
---|
| 658 | ElseIf StartPos<=549.5 Then
|
---|
[90] | 659 | StartPos -= 392.5
|
---|
[1] | 660 | i1=-78+Int(StartPos)
|
---|
| 661 | i2=-78
|
---|
| 662 | ElseIf StartPos<=628 Then
|
---|
[90] | 663 | StartPos -= 549.5
|
---|
[1] | 664 | i1=78
|
---|
| 665 | i2=-78+Int(StartPos)
|
---|
| 666 | End If
|
---|
| 667 |
|
---|
| 668 | If EndPos<=78.5 Then
|
---|
| 669 | i3=78
|
---|
| 670 | i4=Int(EndPos)
|
---|
| 671 | ElseIf EndPos<=235.5 Then
|
---|
[90] | 672 | EndPos -= 78.5
|
---|
[1] | 673 | i3=78-Int(EndPos)
|
---|
| 674 | i4=78
|
---|
| 675 | ElseIf EndPos<=392.5 Then
|
---|
[90] | 676 | EndPos -= 235.5
|
---|
[1] | 677 | i3=-78
|
---|
| 678 | i4=78-Int(EndPos)
|
---|
| 679 | ElseIf EndPos<=549.5 Then
|
---|
[90] | 680 | EndPos -= 392.5
|
---|
[1] | 681 | i3=-78+Int(EndPos)
|
---|
| 682 | i4=-78
|
---|
| 683 | ElseIf EndPos<=628 Then
|
---|
[90] | 684 | EndPos -= 549.5
|
---|
[1] | 685 | i3=78
|
---|
| 686 | i4=-78+Int(EndPos)
|
---|
| 687 | End If
|
---|
| 688 |
|
---|
| 689 | If sw Then
|
---|
| 690 | Pie(hDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 691 | Pie(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 692 | Else
|
---|
| 693 | Arc(hDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 694 | Arc(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 695 | End If
|
---|
| 696 | End If
|
---|
| 697 |
|
---|
[126] | 698 | SelectObject(hDC, hOldPenDC)
|
---|
| 699 | SelectObject(hDC, hOldBrushDC)
|
---|
| 700 | ReleaseDC(_PromptSys_hWnd, hDC)
|
---|
| 701 | SelectObject(_PromptSys_hMemDC, hOldPen)
|
---|
| 702 | SelectObject(_PromptSys_hMemDC, hOldBrush)
|
---|
[1] | 703 | DeleteObject(hPen)
|
---|
| 704 | If bFill Then DeleteObject(hBrush)
|
---|
| 705 | End Macro
|
---|
| 706 |
|
---|
| 707 | 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)
|
---|
| 708 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 709 | 'Line (sx,sy)-[STEP](ex,ey),[ColorCode],[B/Bf],[BrushColor]
|
---|
| 710 | Dim temp As Long
|
---|
| 711 |
|
---|
[126] | 712 | If sx = &H80000000 And sy = &H80000000 Then
|
---|
| 713 | With _PromptSys_GlobalPos
|
---|
| 714 | sx = .x
|
---|
| 715 | sy = .y
|
---|
| 716 | End With
|
---|
[1] | 717 | End If
|
---|
| 718 |
|
---|
| 719 | If bStep Then
|
---|
[90] | 720 | ex += sx
|
---|
| 721 | ey += sy
|
---|
[1] | 722 | Else
|
---|
| 723 | If fType Then
|
---|
| 724 | 'ラインの場合(四角形でない場合)
|
---|
| 725 | If sx>ex Then
|
---|
| 726 | temp=ex
|
---|
| 727 | ex=sx
|
---|
| 728 | sx=temp
|
---|
| 729 | End If
|
---|
| 730 | If sy>ey Then
|
---|
| 731 | temp=ey
|
---|
| 732 | ey=sy
|
---|
| 733 | sy=temp
|
---|
| 734 | End If
|
---|
| 735 | End If
|
---|
| 736 | End If
|
---|
| 737 |
|
---|
[121] | 738 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
| 739 | Dim hPen = CreatePen(PS_SOLID, 1, GetBasicColor(ColorCode))
|
---|
| 740 | Dim hBrush As HBRUSH
|
---|
[1] | 741 | If fType=2 Then
|
---|
[126] | 742 | hBrush = CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
[1] | 743 | Else
|
---|
[126] | 744 | hBrush = GetStockObject(NULL_BRUSH)
|
---|
[1] | 745 | End If
|
---|
| 746 |
|
---|
[126] | 747 | SelectObject(hDC, hPen)
|
---|
| 748 | SelectObject(hDC, hBrush)
|
---|
| 749 | Dim hOldPen = SelectObject(_PromptSys_hMemDC, hPen)
|
---|
| 750 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
|
---|
[1] | 751 |
|
---|
| 752 | Select Case fType
|
---|
| 753 | Case 0
|
---|
| 754 | 'line
|
---|
| 755 | MoveToEx(_PromptSys_hMemDC,sx,sy,ByVal NULL)
|
---|
| 756 | LineTo(_PromptSys_hMemDC,ex,ey)
|
---|
| 757 | SetPixel(_PromptSys_hMemDC,ex,ey,GetBasicColor(ColorCode))
|
---|
| 758 | MoveToEx(hDC,sx,sy,ByVal NULL)
|
---|
| 759 | LineTo(hDC,ex,ey)
|
---|
| 760 | SetPixel(hDC,ex,ey,GetBasicColor(ColorCode))
|
---|
| 761 | Case Else
|
---|
| 762 | 'Rectangle
|
---|
| 763 | Rectangle(hDC,sx,sy,ex+1,ey+1)
|
---|
| 764 | Rectangle(_PromptSys_hMemDC,sx,sy,ex+1,ey+1)
|
---|
| 765 | End Select
|
---|
| 766 |
|
---|
| 767 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
| 768 | SelectObject(_PromptSys_hMemDC,hOldPen)
|
---|
| 769 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
| 770 | DeleteObject(hPen)
|
---|
[126] | 771 | If fType = 2 Then DeleteObject(hBrush)
|
---|
| 772 | With _PromptSys_GlobalPos
|
---|
| 773 | .x = ex
|
---|
| 774 | .y = ey
|
---|
| 775 | End With
|
---|
[1] | 776 | End Macro
|
---|
| 777 |
|
---|
| 778 | Macro PSET(x As Long, y As Long)(ColorCode As Long)
|
---|
| 779 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 780 | 'PSet (x,y),ColorCode
|
---|
| 781 |
|
---|
[126] | 782 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
| 783 | SetPixel(hDC, x, y, GetBasicColor(ColorCode))
|
---|
| 784 | SetPixel(_PromptSys_hMemDC, x, y, GetBasicColor(ColorCode))
|
---|
| 785 | ReleaseDC(_PromptSys_hWnd, hDC)
|
---|
| 786 | With _PromptSys_GlobalPos
|
---|
| 787 | .x = x
|
---|
| 788 | .y = y
|
---|
| 789 | End With
|
---|
[1] | 790 | End Macro
|
---|
| 791 |
|
---|
| 792 | Macro PAINT(x As Long, y As Long, BrushColor As Long)(ByVal LineColor As Long)
|
---|
| 793 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 794 | 'Paint (x,y),BrushColor,LineColor
|
---|
| 795 |
|
---|
[126] | 796 | Dim hBrush = CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
[1] | 797 |
|
---|
[126] | 798 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
| 799 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
|
---|
| 800 | Dim hOldBrushWndDC = SelectObject(hDC, hBrush)
|
---|
[1] | 801 |
|
---|
[126] | 802 | ExtFloodFill(hDC, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
|
---|
| 803 | ExtFloodFill(_PromptSys_hMemDC, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
|
---|
[1] | 804 |
|
---|
[126] | 805 | ReleaseDC(_PromptSys_hWnd, hDC)
|
---|
| 806 | SelectObject(_PromptSys_hMemDC, hOldBrush)
|
---|
| 807 | SelectObject(hDC, hOldBrushWndDC)
|
---|
[1] | 808 | DeleteObject(hBrush)
|
---|
| 809 | End Macro
|
---|
| 810 |
|
---|
| 811 |
|
---|
| 812 | '-----------
|
---|
| 813 | ' Functions
|
---|
| 814 | '-----------
|
---|
| 815 |
|
---|
| 816 | Function Inkey$() As String
|
---|
| 817 | If _PromptSys_KeyChar=0 Then
|
---|
| 818 | Inkey$=""
|
---|
| 819 | Else
|
---|
| 820 | Inkey$=Chr$(_PromptSys_KeyChar)
|
---|
| 821 | End If
|
---|
| 822 | _PromptSys_KeyChar=0
|
---|
| 823 | End Function
|
---|
| 824 |
|
---|
| 825 | Function Input$(length As Long) As String
|
---|
| 826 | Dim i As Long
|
---|
| 827 |
|
---|
| 828 | If length<=0 Then
|
---|
| 829 | Input$=""
|
---|
| 830 | Exit Function
|
---|
| 831 | End If
|
---|
| 832 |
|
---|
| 833 | i=0
|
---|
| 834 | While 1
|
---|
| 835 | If _PromptSys_KeyChar Then
|
---|
| 836 | Input$=Input$+Chr$(_PromptSys_KeyChar)
|
---|
| 837 | _PromptSys_KeyChar=0
|
---|
[90] | 838 | i++
|
---|
[126] | 839 | If i >= length Then
|
---|
[1] | 840 | Exit While
|
---|
| 841 | End If
|
---|
| 842 | End If
|
---|
| 843 | Sleep(1)
|
---|
| 844 | Wend
|
---|
| 845 | End Function
|
---|
| 846 |
|
---|
| 847 |
|
---|
[89] | 848 | #endif '_INC_PROMPT
|
---|