Changeset 258 for Include


Ignore:
Timestamp:
May 21, 2007, 1:03:21 AM (18 years ago)
Author:
イグトランス (egtra)
Message:

Prompt.sbp内を名前空間に入れた。EnvironmentのMachineName, UserName, GetFolderPathを実装。

Location:
Include
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • Include/Classes/System/Environment.ab

    r237 r258  
    33#require <api_psapi.sbp>
    44#require <Classes/System/OperatingSystem.ab>
     5
     6Namespace System
     7
     8Namespace Detail
     9    TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL
     10End Namespace
    511
    612Class Environment
     
    4551    End Function
    4652
    47     ' MachineName
     53    Static Function MachineName() As String
     54        If Object.ReferenceEquals(machineName, Nothing) Then
     55            Dim buf[MAX_COMPUTERNAME_LENGTH] As TCHAR
     56            Dim len = (MAX_COMPUTERNAME_LENGTH + 1) As DWord
     57            GetComputerName(buf, len)
     58            machineName = New String(buf, len As Long)
     59        End If
     60        Return machineName
     61    End Function           
    4862
    4963    Static Function NewLine() As String
     
    90104    ' UserInteractive
    91105
    92     ' UserName
     106    Static Function UserName() As String
     107        If Object.ReferenceEquals(userName, Nothing) Then
     108            Dim buf[UNLEN] As TCHAR
     109            Dim len = (UNLEN + 1) As DWord
     110            GetUserName(buf, len)
     111            userName = New String(buf, len As Long)
     112        End If
     113        Return userName
     114    End Function           
    93115
    94116    ' Version
    95117
     118Public
     119    'NTでしか使用できない仕様
    96120    Static Function WorkingSet() As Int64
    97         TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL
    98         Dim pGetProcessMemoryInfo As PFNGetProcessMemoryInfo
    99121        Dim hmodPSAPI = LoadLibrary("PSAPI.DLL")
    100122        If hmodPSAPI = 0 Then Return 0
    101         pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) As PFNGetProcessMemoryInfo
     123        Dim pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) As Detail.PFNGetProcessMemoryInfo
    102124        If pGetProcessMemoryInfo <> 0 Then
    103125            Dim mc As PROCESS_MEMORY_COUNTERS
     
    136158    ' GetEnvironmentVariables
    137159
     160    Static Function GetFolderPath(f As Environment_SpecialFolder) As String
     161'       If ... Then
     162'           Throw New ArgumentException
     163'       End If
     164        Dim x As Long
     165        x = f
     166        Return ActiveBasic.Windows.GetFolderPath(x)
     167    End Function
     168
    138169    ' GetLogicalDrives
    139170
     
    143174    Static cmdLine = Nothing As String
    144175    Static exitCode = 0 As Long
     176    Static machineName = Nothing As String
    145177    Static osVer = Nothing As OperatingSystem
    146178    Static processorCount = 0 As Long
    147179    Static sysDir = Nothing As String
     180    Static userName = Nothing As String
    148181End Class
     182
     183Enum Environment_SpecialFolder
     184    Desktop = CSIDL_DESKTOP
     185    Programs = CSIDL_PROGRAMS
     186    Personal = CSIDL_PERSONAL
     187    MyDocuments = CSIDL_PERSONAL
     188    Favorites = CSIDL_FAVORITES
     189    Startup = CSIDL_STARTUP
     190    Recent = CSIDL_RECENT
     191    SendTo = CSIDL_SENDTO
     192    StartMenu = CSIDL_STARTMENU
     193    MyMusic = CSIDL_MYMUSIC
     194    DesktopDirectory = CSIDL_DESKTOPDIRECTORY
     195    MyComputer = CSIDL_DRIVES
     196    Templates = CSIDL_TEMPLATES
     197    ApplicationData = CSIDL_APPDATA '4.71
     198    LocalApplicationData = CSIDL_LOCAL_APPDATA
     199    InternetCache = CSIDL_INTERNET_CACHE
     200    Cookies = CSIDL_COOKIES
     201    History = CSIDL_HISTORY
     202    CommonApplicationData = CSIDL_COMMON_APPDATA '5.0
     203    System = CSIDL_SYSTEM
     204    CommonProgramFiles = CSIDL_PROGRAM_FILES
     205    ProgramFiles = CSIDL_PROGRAM_FILES
     206    MyPictures = CSIDL_MYPICTURES
     207End Enum
     208
     209
     210End Namespace 'System
  • Include/Classes/System/OperatingSystem.ab

    r257 r258  
    66#require <Classes/System/Version.ab>
    77
     8Namespace System
     9
    810Class OperatingSystem
    911    ' Inherits ICloneable', ISerializable
    1012Public
    1113    ' Constractor
    12     Sub OperatingSystem(platform As PlatformID, version As System.Version)
     14    Sub OperatingSystem(platform As PlatformID, version As Version)
    1315        pf = platform
    1416        ver = version
     
    1820    Sub OperatingSystem(vi As OSVERSIONINFOA)
    1921        pf = vi.dwPlatformId As PlatformID
    20         ver = New System.Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
     22        ver = New Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
    2123        sp = New String(vi.szCSDVersion As PCSTR)
    2224    End Sub
     
    2426    Sub OperatingSystem(vi As OSVERSIONINFOW)
    2527        pf = vi.dwPlatformId As PlatformID
    26         ver = New System.Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
     28        ver = New Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
    2729        sp = New String(vi.szCSDVersion As PCSTR)
    2830    End Sub
     
    3335    End Function
    3436
    35     Const Function Version() As System.Version
     37    Const Function Version() As Version
    3638        Return ver
    3739    End Function
     
    7173Private
    7274    pf As PlatformID
    73     ver As System.Version
     75    ver As Version
    7476    sp As String
    7577End Class
     
    8385End Enum
    8486
     87End Namespace
     88
    8589#endif '__SYSYTEM_OPERATINGSYSTEM_AB__
  • Include/Classes/System/Threading/WaitHandle.ab

    r237 r258  
    33#ifndef __SYSTEM_THREADING_WAITHANDLE_AB__
    44#define __SYSTEM_THREADING_WAITHANDLE_AB__
     5
     6'Namespace System
     7'Namespace Threading
     8
     9Namespace Detail
     10    TypeDef PFNSignalObjectAndWait = *Function(hObjectToSignal As HANDLE, hObjectToWaitOn As HANDLE, dwMilliseconds As DWord, bAlertable As DWord) As DWord
     11End Namespace
    512
    613Class WaitHandle
     
    6269    End Function
    6370
     71Public
    6472    Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As BOOL
    65         TypeDef PFNSignalObjectAndWait = *Function(hObjectToSignal As HANDLE, hObjectToWaitOn As HANDLE, dwMilliseconds As DWord, bAlertable As DWord) As DWord
    66         Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") As PFNSignalObjectAndWait
     73        Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") As Detail.PFNSignalObjectAndWait
    6774        If pSignalObjectAndWait = 0 Then
    6875            ' PlatformNotSupportedException
     
    105112End Class
    106113
     114'End Namespace 'Threading
     115'End Namespace 'System
     116
    107117#endif '__SYSTEM_THREADING_WAITHANDLE_AB__
  • Include/api_shell.sbp

    r170 r258  
    374374
    375375' ShlObj.h
     376
     377'要IE4
    376378Declare Function SHGetSpecialFolderPath Lib "shell32" Alias _FuncName_SHGetSpecialFolderPath (hwndOwner As HWND, lpszPath As LPTSTR, nFolder As Long, fCreate As BOOL) As BOOL
    377379
     
    379381Declare Function SHGetInstanceExplorer Lib "shell32" (ByRef ppunk As *IUnknown) As HRESULT
    380382
    381 Const CSIDL_PERSONAL = 5
    382 Const CSIDL_FAVORITIES = 6
     383'shlobj.h
     384Declare Function SHGetSpecialFolderLocation Lib "shell32" (hwndOwner As HWND, nFolder As Long, ByRef pidl As LPITEMIDLIST) As HRESULT
     385
     386'shlobj.h
     387'要Win2k/Me
     388'Declare Function SHGetFolderLocation Lib "shell32" (hwndOwner As HWND, nFolder As Long, hToken As HANDLE, dwReserved As DWord, ByRef pidl As LPITEMIDLIST) As HRESULT
     389
     390Const CSIDL_DESKTOP = &h0000
     391Const CSIDL_INTERNET = &h0001
     392Const CSIDL_PROGRAMS = &h0002
     393Const CSIDL_CONTROLS = &h0003
     394Const CSIDL_PRINTERS = &h0004
     395Const CSIDL_PERSONAL = &h0005
     396Const CSIDL_FAVORITES = &h0006
     397Const CSIDL_STARTUP = &h0007
     398Const CSIDL_RECENT = &h0008
     399Const CSIDL_SENDTO = &h0009
     400Const CSIDL_BITBUCKET = &h000a
     401Const CSIDL_STARTMENU = &h000b
     402Const CSIDL_MYMUSIC = &h000d
     403Const CSIDL_DESKTOPDIRECTORY = &h0010
     404Const CSIDL_DRIVES = &h0011
     405Const CSIDL_NETWORK = &h0012
     406Const CSIDL_NETHOOD = &h0013
     407Const CSIDL_FONTS = &h0014
     408Const CSIDL_TEMPLATES = &h0015
     409Const CSIDL_COMMON_STARTMENU = &h0016
     410Const CSIDL_COMMON_PROGRAMS = &h0017
     411Const CSIDL_COMMON_STARTUP = &h0018
     412Const CSIDL_COMMON_DESKTOPDIRECTORY = &h0019
     413Const CSIDL_APPDATA = &h001a
     414Const CSIDL_PRINTHOOD = &h001b
     415Const CSIDL_LOCAL_APPDATA = &h001c
     416Const CSIDL_ALTSTARTUP = &h001d
     417Const CSIDL_COMMON_ALTSTARTUP = &h001e
     418Const CSIDL_COMMON_FAVORITES = &h001f
     419Const CSIDL_INTERNET_CACHE = &h0020
     420Const CSIDL_COOKIES = &h0021
     421Const CSIDL_HISTORY = &h0022
     422Const CSIDL_COMMON_APPDATA = &h0023
     423Const CSIDL_WINDOWS = &h0024
     424Const CSIDL_SYSTEM = &h0025
     425Const CSIDL_PROGRAM_FILES = &h0026
     426Const CSIDL_MYPICTURES = &h0027
     427Const CSIDL_PROFILE = &h0028
     428Const CSIDL_PROGRAM_FILES_COMMON = &h002b
     429Const CSIDL_COMMON_TEMPLATES = &h002d
     430Const CSIDL_COMMON_DOCUMENTS = &h002e
     431Const CSIDL_COMMON_ADMINTOOLS = &h002f
     432Const CSIDL_ADMINTOOLS = &h0030
    383433
    384434Const SHGFI_ICON              = &H000000100
  • Include/api_system.sbp

    r173 r258  
    213213Const MUTEX_ALL_ACCESS = MUTANT_ALL_ACCESS
    214214
     215'Lmcons.ab
     216Const UNLEN = 256
     217
    215218'----------------------
    216219' Kernel Operation API
     
    465468
    466469Const MAX_COMPUTERNAME_LENGTH = 15
    467 Declare Function GetComputerName Lib "kernel32" Alias _FuncName_GetComputerName (pBuffer As PTSTR, ByRef nSize As Long) As Long
     470Declare Function GetComputerName Lib "kernel32" Alias _FuncName_GetComputerName (pBuffer As PTSTR, ByRef nSize As DWord) As BOOL
    468471
    469472Declare Function GetCurrentDirectory Lib "kernel32" Alias _FuncName_GetCurrentDirectory (nBufferLength As DWord, pBuffer As PTSTR) As DWord
  • Include/basic.sbp

    r255 r258  
    1212End Sub
    1313
     14Const QWORD_MAX = &HFFFFFFFFFFFFFFFF As QWord
     15Const INT64_MAX = &H7FFFFFFFFFFFFFFF As Int64
     16Const INT64_MIN = &H8000000000000000 As Int64
    1417
    15 Const LONG_MAX = &H7FFFFFFF
    16 Const LONG_MIN = &H80000000
     18Const DWORD_MAX = &HFFFFFFFF As DWord
     19Const LONG_MAX = &H7FFFFFFF As Long
     20Const LONG_MIN = &H80000000 As Long
     21
     22Const WORD_MAX = &HFFFF As Word
     23Const INTEGER_MAX = &H7FFF As Integer
     24Const INTEGER_MIN = &H8000 As Integer
     25
     26Const BYTE_MAX = &HFF As Byte
     27Const SBYTE_MAX = &H7F As SByte
     28Const SBYTE_MIN = &H80 As SByte
     29
     30Const DBL_MAX = 1.7976931348623158e+308
     31Const DBL_MIN = 2.2250738585072014e-308
    1732
    1833Const FLT_MAX = 3.402823466e+38
  • Include/basic/command.sbp

    r251 r258  
    3434
    3535Sub _System_End()
    36     Dim exitCode = Environment.ExitCode
     36    Dim exitCode = System.Environment.ExitCode
    3737    _System_EndProgram()
    3838    ExitProcess(exitCode)
  • Include/basic/function.sbp

    r257 r258  
    12311231End Function
    12321232
     1233Namespace ActiveBasic
     1234    Namespace Windows
     1235        Function GetPathFromIDList(pidl As LPITEMIDLIST) As String
     1236            Dim buf[ELM(MAX_PATH)] As TCHAR
     1237            If SHGetPathFromIDList(pidl, buf) Then
     1238                Return New String(buf)
     1239            Else
     1240                Return ""
     1241            End If
     1242        End Function
     1243
     1244        Function GetFolderPath(hwnd As HWND, folder As Long) As String
     1245            Dim pidl As LPITEMIDLIST
     1246            Dim hr = SHGetSpecialFolderLocation(hwnd, folder, pidl)
     1247            If SUCCEEDED(hr) Then
     1248                GetFolderPath = GetPathFromIDList(pidl)
     1249                CoTaskMemFree(pidl)
     1250            Else
     1251                GetFolderPath = ""
     1252            End If
     1253        End Function
     1254
     1255        Function GetFolderPath(folder As Long) As String
     1256            Return GetFolderPath(0, folder)
     1257        End Function
     1258    End Namespace
     1259End Namespace
     1260
    12331261#endif '_INC_FUNCTION
  • Include/basic/prompt.sbp

    r208 r258  
    55#define _INC_PROMPT
    66
    7 
    87#require <api_imm.sbp>
    98#require <Classes/System/Math.ab>
    10 
     9#require <Classes/System/Environment.ab>
     10
     11Namespace ActiveBasic
     12Namespace Prompt
     13Namespace Detail
     14   
    1115Function _PromptSys_GetTextExtentPoint32(hdc As HDC, psz As PCSTR, cb As Long, ByRef Size As SIZE) As Long
    1216    _PromptSys_GetTextExtentPoint32 = GetTextExtentPoint32A(hdc, psz, cb, Size)
     
    5054End Type
    5155
    52 Dim _PromptSys_LogFont As LOGFONT
    5356Dim _PromptSys_hFont As HFONT
    5457Dim _PromptSys_FontSize As SIZE
    5558Dim _PromptSys_InputStr[255] As StrChar
    56 Dim _PromptSys_InputLen As Long
     59Dim _PromptSys_InputLen = -1 As Long
    5760Dim _PromptSys_KeyChar As Byte
    5861Dim _PromptSys_CurPos As POINTAPI
     
    6467Dim _System_OSVersionInfo As OSVERSIONINFO
    6568
    66 _PromptSys_InputLen = -1
    6769
    6870'graphic
     
    7274Dim _PromptSys_GlobalPos As POINTAPI
    7375
     76Sub _PromptSys_Initialize()
    7477_PromptSys_hInitFinish = CreateEvent(0, FALSE, FALSE, 0)
    75 Dim _PromptSys_hThread As HANDLE
    76 _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain) As LPTHREAD_START_ROUTINE, 0, 0, _PromptSys_dwThreadID)
     78Dim _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain), 0, 0, _PromptSys_dwThreadID)
    7779If _PromptSys_hThread = 0 Then
    7880    Debug
     
    8082End If
    8183WaitForSingleObject(_PromptSys_hInitFinish, INFINITE)
     84End Sub
    8285
    8386Sub DrawPromptBuffer(hDC As HDC, StartLine As Long, EndLine As Long)
     
    267270    Dim ps As PAINTSTRUCT
    268271    Dim hdc = BeginPaint(hwnd, ps)
    269 '   With _PromptSys_ScreenSize
    270 '       BitBlt(hdc, 0, 0, .cx, .cy, _PromptSys_hMemDC, 0, 0, SRCCOPY)
    271     With ps.rcPaint
    272         BitBlt(hdc, .left, .top, .right - .left, .bottom - .top, _PromptSys_hMemDC, .left, .top, SRCCOPY)
     272    With _PromptSys_ScreenSize
     273        BitBlt(hdc, 0, 0, .cx, .cy, _PromptSys_hMemDC, 0, 0, SRCCOPY)
     274'   With ps.rcPaint
     275'       BitBlt(hdc, .left, .top, .right - .left, .bottom - .top, _PromptSys_hMemDC, .left, .top, SRCCOPY)
    273276    End With
    274277    DrawPromptBuffer(hdc, -1, 0)
     
    287290            End With
    288291            ImmSetCompositionWindow(himc, CompForm)
    289             ImmSetCompositionFont(himc, _PromptSys_LogFont)
     292
     293            Dim lf As LOGFONT
     294            GetObject(_PromptSys_hFont, Len(lf), lf)
     295            ImmSetCompositionFont(himc, lf)
    290296        End If
    291297        ImmReleaseContext(hwnd, himc)
     
    365371
    366372        SendMessage(hwnd, WM_KILLFOCUS, 0, 0)
    367         PRINT_ToPrompt(TempStr)
     373        ActiveBasic.Prompt.Detail.PRINT_ToPrompt(TempStr)
    368374        SendMessage(hwnd, WM_SETFOCUS, 0, 0)
    369375    End If
     
    372378Function _PromptWnd_GetCompositionStringW(himc As HIMC, ByRef rpsz As PWSTR) As Long
    373379    Dim size = ImmGetCompositionStringW(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位
    374     rpsz = _System_malloc(size) As PTSTR
     380    rpsz = _System_malloc(size) As PWSTR
    375381    If rpsz = 0 Then
    376382        'Debug
     
    382388Function _PromptWnd_GetCompositionStringA(himc As HIMC, ByRef rpsz As PSTR) As Long
    383389    Dim size = ImmGetCompositionStringA(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位
    384     rpsz = _System_malloc(size) As PTSTR
     390    rpsz = _System_malloc(size) As PSTR
    385391    If rpsz = 0 Then
    386392        'Debug
     
    403409        tempStr.Assign(str, size)
    404410#else
    405         With _System_OSVersionInfo
     411        Dim osver = System.Environment.OSVersion
     412        With osver
    406413            ' GetCompositionStringW is not implimented in Windows 95
    407             If .dwMajorVersion = 4 And .dwMinorVersion = 0 And .dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
     414            If .Version.Major = 4 And .Version.Minor = 0 And .Platform = System.PlatformID.Win32Windows Then
    408415                Dim strA As PCSTR
    409416                Dim sizeA = _PromptWnd_GetCompositionStringA(himc, strA)
     
    421428        _PromptSys_InputLen += tempStr.Length
    422429
    423         SendMessage(hwnd, WM_KILLFOCUS, 0, 0) : Debug
    424         PRINT_ToPrompt(tempStr)
     430        SendMessage(hwnd, WM_KILLFOCUS, 0, 0)
     431        ActiveBasic.Prompt.Detail.PRINT_ToPrompt(tempStr)
    425432        SendMessage(hwnd, WM_SETFOCUS, 0, 0)
    426433
     
    454461    End With
    455462
    456     'LogFont initialize
    457     With _PromptSys_LogFont
     463    '_PromptSys_hFont initialize
     464    Dim lf As LOGFONT
     465    With lf
    458466        .lfHeight = -16
    459467        .lfWidth = 0
     
    469477        .lfQuality = DEFAULT_QUALITY
    470478        .lfPitchAndFamily = FIXED_PITCH
    471         lstrcpy(.lfFaceName, "MS 明朝")
    472     End With
    473 
    474     _PromptSys_hFont = CreateFontIndirect(_PromptSys_LogFont)
     479        lstrcpy(.lfFaceName, ToTCStr("MS 明朝"))
     480    End With
     481
     482    _PromptSys_hFont = CreateFontIndirect(lf)
    475483
    476484    'Critical Section
     
    487495        .hIconSm = LoadImage(0, MAKEINTRESOURCE(IDI_WINLOGO), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HICON
    488496        .hCursor = LoadImage(0, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HCURSOR
    489         .lpszClassName = "PROMPT"
     497        .lpszClassName = ToTCStr("PROMPT")
    490498        .lpfnWndProc = AddressOf(PromptProc)
    491499        .hbrBackground = GetStockObject(BLACK_BRUSH)
     
    494502
    495503    'Create Prompt Window
    496     _PromptSys_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, atom As ULONG_PTR As LPCTSTR, "BASIC PROMPT", _
     504    _PromptSys_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, atom As ULONG_PTR As LPCTSTR, ToTCStr("BASIC PROMPT"), _
    497505        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
    498506        0, 0, wcl.hInstance, 0)
     
    503511    Do
    504512        Dim iResult = GetMessage(msg, 0, 0, 0)
    505         If iResult = 0 Or iResult = -1 Then Exit Do
     513        If iResult = 0 Then
     514            System.Environment.ExitCode = msg.wParam As Long
     515            Exit Do
     516        ElseIf iResult = -1 Then
     517            Exit Do
     518        End If
    506519        TranslateMessage(msg)
    507520        DispatchMessage(msg)
     
    509522
    510523    '強制的に終了する
    511     End 'ExitProcess(0)
     524    End
    512525
    513526    EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
     
    522535    DeleteCriticalSection(_PromptSys_SectionOfBufferAccess)
    523536
    524     End 'ExitProcess(0)
    525 End Function
    526 
    527 
    528 '----------------------
    529 ' Prompt text Commands
    530 '----------------------
    531 
    532 Macro CLS()(num As Long)
     537    End
     538End Function
     539
     540'Prompt text command functoins
     541
     542Sub Cls(n As Long)
    533543    Dim i As Long
    534544
    535545    'When parameter was omitted, num is set to 1
    536     If num = 0 Then num = 1
    537 
    538     If num = 1 Or num = 3 Then
     546    If n = 0 Then n = 1
     547
     548    If n = 1 Or n = 3 Then
    539549        'Clear the text screen
    540550        For i = 0 To 100
     
    550560    End If
    551561
    552     If num = 2 Or num = 3 Then
     562    If n = 2 Or n = 3 Then
    553563        'Clear the graphics screen
    554564        Dim hOldBrush = SelectObject(_PromptSys_hMemDC, GetStockObject(BLACK_BRUSH))
     
    561571    'Redraw
    562572    InvalidateRect(_PromptSys_hWnd, ByVal 0, 0)
    563 End Macro
    564 
    565 Macro COLOR(TextColorCode As Long)(BackColorCode As Long)
    566     _PromptSys_NowTextColor = GetBasicColor(TextColorCode)
    567     If BackColorCode = -1 Then
     573End Sub
     574
     575Sub Color(textColorCode As Long, backColorCode As Long)
     576    _PromptSys_NowTextColor = GetBasicColor(textColorCode)
     577    If backColorCode = -1 Then
    568578        _PromptSys_NowBackColor = -1
    569579    Else
    570         _PromptSys_NowBackColor = GetBasicColor(BackColorCode)
    571     End If
    572 End Macro
    573 
    574 '---------- Defined in "command.sbp" ----------
    575 'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
    576 'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
    577 '----------------------------------------------
    578 Sub INPUT_FromPrompt(ShowStr As String)
     580        _PromptSys_NowBackColor = GetBasicColor(backColorCode)
     581    End If
     582End Sub
     583
     584Sub INPUT_FromPrompt(showStr As String)
    579585    Dim i As Long, i2 As Long, i3 As Long
    580586    Dim buf As String
     
    582588*InputReStart
    583589
    584     PRINT_ToPrompt(ShowStr)
     590    ActiveBasic.Prompt.Detail.PRINT_ToPrompt(showStr)
    585591
    586592    'Input by keyboard
     
    616622        i++
    617623        If _System_InputDataPtr[i] = 0 and _PromptSys_InputStr[i2] = &h2c Then 'Asc(",")
    618             PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
     624            ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
    619625            Goto *InputReStart
    620626        ElseIf _PromptSys_InputStr[i2] = 0 Then
    621627            If _System_InputDataPtr[i]<>0 Then
    622                 PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
     628                ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
    623629                Goto *InputReStart
    624630            Else
     
    631637End Sub
    632638
    633 Sub PRINTUSING_ToPrompt(UsingStr As String)
    634     PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
    635 End Sub
    636 
    637 Macro LOCATE(x As Long, y As Long)
     639Sub Locate(x As Long, y As Long)
    638640    If x < 0 Then x = 0
    639641    If y < 0 Then y = 0
     
    653655        _PromptSys_TextLine[y].Length = x
    654656    End If
    655 End Macro
    656 
    657 
    658 '-------------------
    659 ' Graphics Commands
    660 '-------------------
    661 
    662 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)
    663     '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
    664     'Circle (x, y), radius [, color] [, start] [, end] [, aspect] [, f] [, color2]
    665 
     657End Sub
     658
     659'Prompt graphic command functions
     660
     661Sub 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)
    666662    Dim i1 As Long, i2 As Long, i3 As Long, i4 As Long
    667663
     
    763759    DeleteObject(hPen)
    764760    If bFill Then DeleteObject(hBrush)
    765 End Macro
    766 
    767 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)
    768     '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
    769     'Line (sx,sy)-[STEP](ex,ey),[ColorCode],[B/Bf],[BrushColor]
     761End Sub
     762
     763Sub 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)
    770764    Dim temp As Long
    771765
     
    796790    End If
    797791
    798     Dim hDC = GetDC(_PromptSys_hWnd)
     792    Dim hdc = GetDC(_PromptSys_hWnd)
    799793    Dim hPen = CreatePen(PS_SOLID, 1, GetBasicColor(ColorCode))
    800794    Dim hBrush As HBRUSH
     
    805799    End If
    806800
    807     SelectObject(hDC, hPen)
    808     SelectObject(hDC, hBrush)
     801    SelectObject(hdc, hPen)
     802    SelectObject(hdc, hBrush)
    809803    Dim hOldPen = SelectObject(_PromptSys_hMemDC, hPen)
    810804    Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
     
    816810            LineTo(_PromptSys_hMemDC,ex,ey)
    817811            SetPixel(_PromptSys_hMemDC,ex,ey,GetBasicColor(ColorCode))
    818             MoveToEx(hDC,sx,sy,ByVal NULL)
    819             LineTo(hDC,ex,ey)
    820             SetPixel(hDC,ex,ey,GetBasicColor(ColorCode))
     812            MoveToEx(hdc,sx,sy,ByVal NULL)
     813            LineTo(hdc,ex,ey)
     814            SetPixel(hdc,ex,ey,GetBasicColor(ColorCode))
    821815        Case Else
    822816            'Rectangle
    823             Rectangle(hDC,sx,sy,ex+1,ey+1)
     817            Rectangle(hdc,sx,sy,ex+1,ey+1)
    824818            Rectangle(_PromptSys_hMemDC,sx,sy,ex+1,ey+1)
    825819    End Select
    826820
    827     ReleaseDC(_PromptSys_hWnd,hDC)
     821    ReleaseDC(_PromptSys_hWnd,hdc)
    828822    SelectObject(_PromptSys_hMemDC,hOldPen)
    829823    SelectObject(_PromptSys_hMemDC,hOldBrush)
     
    834828        .y = ey
    835829    End With
    836 End Macro
    837 
    838 Macro PSET(x As Long, y As Long)(ColorCode As Long)
    839     '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
    840     'PSet (x,y),ColorCode
    841 
    842     Dim hDC = GetDC(_PromptSys_hWnd)
    843     SetPixel(hDC, x, y, GetBasicColor(ColorCode))
     830End Sub
     831
     832Sub PSet(x As Long, y As Long, ColorCode As Long)
     833    Dim hdc = GetDC(_PromptSys_hWnd)
     834    SetPixel(hdc, x, y, GetBasicColor(ColorCode))
    844835    SetPixel(_PromptSys_hMemDC, x, y, GetBasicColor(ColorCode))
    845     ReleaseDC(_PromptSys_hWnd, hDC)
     836    ReleaseDC(_PromptSys_hWnd, hdc)
    846837    With _PromptSys_GlobalPos
    847838        .x = x
    848839        .y = y
    849840    End With
    850 End Macro
    851 
    852 Macro PAINT(x As Long, y As Long, BrushColor As Long)(ByVal LineColor As Long)
    853     '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
    854     'Paint (x,y),BrushColor,LineColor
    855 
    856     Dim hBrush = CreateSolidBrush(GetBasicColor(BrushColor))
    857 
    858     Dim hDC = GetDC(_PromptSys_hWnd)
    859     Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush)
    860     Dim hOldBrushWndDC = SelectObject(hDC, hBrush)
    861 
    862     ExtFloodFill(hDC, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
     841End Sub
     842
     843Sub Paint(x As Long, y As Long, BrushColor As Long, LineColor As Long)
     844    Dim hbr = CreateSolidBrush(GetBasicColor(BrushColor))
     845
     846    Dim hdc = GetDC(_PromptSys_hWnd)
     847    Dim hbrOld = SelectObject(_PromptSys_hMemDC, hbr)
     848    Dim hbrOldWndDC = SelectObject(hdc, hbr)
     849
     850    ExtFloodFill(hdc, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
    863851    ExtFloodFill(_PromptSys_hMemDC, x, y, GetBasicColor(LineColor), FLOODFILLBORDER)
    864852
    865     ReleaseDC(_PromptSys_hWnd, hDC)
    866     SelectObject(_PromptSys_hMemDC, hOldBrush)
    867     SelectObject(hDC, hOldBrushWndDC)
    868     DeleteObject(hBrush)
    869 End Macro
    870 
    871 
    872 '-----------
    873 ' Functions
    874 '-----------
     853    ReleaseDC(_PromptSys_hWnd, hdc)
     854    SelectObject(_PromptSys_hMemDC, hbrOld)
     855    SelectObject(hdc, hbrOldWndDC)
     856    DeleteObject(hbr)
     857End Sub
    875858
    876859Function Inkey$() As String
     
    884867
    885868Function Input$(length As Long) As String
    886     Dim i As Long
     869    Dim i = 0 As Long
    887870
    888871    If length<=0 Then
     
    891874    End If
    892875
    893     i=0
    894876    While 1
    895877        If _PromptSys_KeyChar Then
     
    905887End Function
    906888
     889End Namespace 'Detail
     890
     891Function OwnerWnd() As HWND
     892    Return Detail._PromptSys_hWnd
     893End Function
     894
     895End Namespace 'Prompt
     896End Namespace 'ActiveBasic
     897
     898'----------------------
     899' Prompt text Commands
     900'----------------------
     901
     902Sub PRINT_ToPrompt(s As String)
     903    ActiveBasic.Prompt.Detail.PRINT_ToPrompt(s)
     904End Sub
     905
     906Macro CLS()(num As Long)
     907    ActiveBasic.Prompt.Detail.Cls(num)
     908End Macro
     909
     910Macro COLOR(TextColorCode As Long)(BackColorCode As Long)
     911    ActiveBasic.Prompt.Detail.Color(TextColorCode, BackColorCode)
     912End Macro
     913
     914'---------- Defined in "command.sbp" ----------
     915'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
     916'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
     917'----------------------------------------------
     918Sub INPUT_FromPrompt(ShowStr As String)
     919    ActiveBasic.Prompt.Detail.INPUT_FromPrompt(ShowStr)
     920End Sub
     921
     922Sub PRINTUSING_ToPrompt(UsingStr As String)
     923    ActiveBasic.Prompt.Detail.PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
     924End Sub
     925
     926Macro LOCATE(x As Long, y As Long)
     927    ActiveBasic.Prompt.Detail.Locate(x, y)
     928End Macro
     929
     930
     931'-------------------
     932' Graphics Commands
     933'-------------------
     934
     935Macro 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)
     936    '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
     937    'Circle (x, y), radius [, color] [, start] [, end] [, aspect] [, f] [, color2]
     938    ActiveBasic.Prompt.Detail.Circle(x, y, radius, ColorCode, StartPos, EndPos, Aspect, bFill, BrushColor)
     939End Macro
     940
     941Macro 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)
     942    '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
     943    'Line (sx,sy)-[STEP](ex,ey),[ColorCode],[B/Bf],[BrushColor]
     944    ActiveBasic.Prompt.Detail.Line(sx, sy, bStep, ex, ey, ColorCode, fType, BrushColor)
     945End Macro
     946
     947Macro PSET(x As Long, y As Long)(ColorCode As Long)
     948    '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
     949    'PSet (x,y),ColorCode
     950    ActiveBasic.Prompt.Detail.PSet(x, y, ColorCode)
     951End Macro
     952
     953Macro PAINT(x As Long, y As Long, BrushColor As Long)(ByVal LineColor As Long)
     954    '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
     955    'Paint (x,y),BrushColor,LineColor
     956    ActiveBasic.Prompt.Detail.Paint(x, y, BrushColor, LineColor)
     957End Macro
     958
     959
     960'-----------
     961' Functions
     962'-----------
     963
     964Function Inkey$() As String
     965    Return ActiveBasic.Prompt.Detail.Inkey$()
     966End Function
     967
     968Function Input$(length As Long) As String
     969    Return ActiveBasic.Prompt.Detail.Input$(length)
     970End Function
     971
     972ActiveBasic.Prompt.Detail._PromptSys_Initialize()
    907973
    908974#endif '_INC_PROMPT
  • Include/system/string.sbp

    r237 r258  
    157157
    158158Function GetTCStr(s As String, ByRef tcs As PCTSTR) As SIZE_T
    159     Return GetStr(s.Chars, s.Length As SIZE_T, wcs)
     159    Return GetStr(s.Chars, s.Length As SIZE_T, tcs)
    160160End Function
    161161
     
    177177
    178178Function GetSCStr(s As String, ByRef ss As *StrChar) As SIZE_T
    179     Return GetStr(s.Chars, s.Length As SIZE_T, wcs)
     179    Return GetStr(s.Chars, s.Length As SIZE_T, ss)
    180180End Function
    181181
Note: See TracChangeset for help on using the changeset viewer.