Changeset 629 for trunk


Ignore:
Timestamp:
Sep 21, 2008, 2:06:46 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

Console.Title(取得側)が正しく動かないバグを除去

Location:
trunk/ab5.0/ablib/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/Console.ab

    r627 r629  
    240240            Exit Sub
    241241        Else
    242             SetConsoleTitle(StrPtr(title))
     242            SetConsoleTitle(ToTCStr(title))
    243243        End If
    244244    End Sub
    245245    Static Function Title() As String
    246         Dim sb = New Text.StringBuilder(24500*SizeOf(Char))
    247246        If Console.hconsoleout =NULL Then
    248247            Return ""
    249248        Else
    250             GetConsoleTitle(sb.__Chars(),sb.Length())
     249            Dim sb = New Text.StringBuilder
     250            sb.Length = 24500
     251            Dim ret = GetConsoleTitle(StrPtr(sb),sb.Length())
     252            If ret = 0 Then
     253                Dim error = GetLastError()
     254                If error <> ERROR_SUCSESS Then
     255                    ActiveBasic.Windows.ThrowWithErrorCode(error, "Console.Title")
     256                End If
     257            End If
     258            sb.Length = ret
     259            Return sb.ToString()
    251260        End If
    252261    End Function
  • trunk/ab5.0/ablib/src/Classes/System/Text/StringBuilder.ab

    r521 r629  
    456456    End Function
    457457
     458    /*!
     459    @brief 内部用
     460    代わりにStrPtr使ってください。
     461    */
    458462    Function __Chars() As *Char
    459463        Return chars
    460464    End Function
    461465
     466    /*!
     467    @brief 内部用
     468    使わないでください。
     469    */
    462470    Sub __Stringized()
    463471        stringized = True
     
    467475    Sub initialize(capacity As Long, maxCapacity = LONG_MAX As Long)
    468476        If capacity < 0 Or maxCapacity < 1 Or maxCapacity < capacity Then
    469             Throw New ArgumentOutOfRangeException("StringBuilder constructor: One or more arguments are out of range value.", "capacity or maxCapacity or both")
     477            Throw New ArgumentOutOfRangeException("StringBuilder constructor", "capacity or maxCapacity or both")
    470478        End If
    471479
     
    494502    Sub rangeCheck(index As Long)
    495503        If index < 0 Or index > size Then
    496             Throw New ArgumentOutOfRangeException("StringBuilder: Index argument is out of range value.")
     504            Throw New ArgumentOutOfRangeException("StringBuilder")
    497505        End If
    498506    End Sub
     
    505513        'length < 0は判定に入っていないことに注意
    506514        If startIndex < 0 Or count < 0 Or startIndex + count > length Then
    507             Throw New ArgumentOutOfRangeException("StringBuilder: One or more arguments are out of range value.", "startIndex or count or both")
     515            Throw New ArgumentOutOfRangeException("StringBuilder", "startIndex or count or both")
    508516        End If
    509517    End Sub
  • trunk/ab5.0/ablib/src/api_console.sbp

    r622 r629  
    210210Declare Function AllocConsole Lib "kernel32" () As BOOL
    211211Declare Function FreeConsole Lib "kernel32" () As BOOL
    212 Declare Function GetConsoleTitle Lib "kernel32" Alias _FuncName_GetConsoleTitle (lpConsoleTitle As LPSTR, nSize As DWord) As DWord
    213 Declare Function SetConsoleTitle Lib "kernel32" Alias _FuncName_SetConsoleTitle (lpConsoleTitle As LPSTR) As BOOL
     212Declare Function GetConsoleTitle Lib "kernel32" Alias _FuncName_GetConsoleTitle (lpConsoleTitle As LPTSTR, nSize As DWord) As DWord
     213Declare Function SetConsoleTitle Lib "kernel32" Alias _FuncName_SetConsoleTitle (lpConsoleTitle As LPTSTR) As BOOL
    214214Declare Function ReadConsole Lib "kernel32" Alias _FuncName_ReadConsole (hConsoleInput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToRead As DWord, ByRef lpNumberOfCharsRead As DWord, lpReserved As VoidPtr) As BOOL
    215215Declare Function WriteConsole Lib "kernel32" Alias _FuncName_WriteConsole (hConsoleOutput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToWrite As DWord, ByRef lpNumberOfCharsWritten As DWord, lpReserved As VoidPtr) As BOOL
     
    223223Declare Function SetConsoleOutputCP Lib "kernel32" (wCodePageID As DWord) As BOOL
    224224
    225 Function COORDtoDWORD ( ByRef coord As COORD) As DWord
     225Function COORDtoDWORD(ByRef coord As COORD) As DWord
    226226    Return GetDWord(VarPtr(coord))
    227227End Function
Note: See TracChangeset for help on using the changeset viewer.