Changeset 258 for Include/basic
- Timestamp:
- May 21, 2007, 1:03:21 AM (18 years ago)
- Location:
- Include/basic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/basic/command.sbp
r251 r258 34 34 35 35 Sub _System_End() 36 Dim exitCode = Environment.ExitCode36 Dim exitCode = System.Environment.ExitCode 37 37 _System_EndProgram() 38 38 ExitProcess(exitCode) -
Include/basic/function.sbp
r257 r258 1231 1231 End Function 1232 1232 1233 Namespace 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 1259 End Namespace 1260 1233 1261 #endif '_INC_FUNCTION -
Include/basic/prompt.sbp
r208 r258 5 5 #define _INC_PROMPT 6 6 7 8 7 #require <api_imm.sbp> 9 8 #require <Classes/System/Math.ab> 10 9 #require <Classes/System/Environment.ab> 10 11 Namespace ActiveBasic 12 Namespace Prompt 13 Namespace Detail 14 11 15 Function _PromptSys_GetTextExtentPoint32(hdc As HDC, psz As PCSTR, cb As Long, ByRef Size As SIZE) As Long 12 16 _PromptSys_GetTextExtentPoint32 = GetTextExtentPoint32A(hdc, psz, cb, Size) … … 50 54 End Type 51 55 52 Dim _PromptSys_LogFont As LOGFONT53 56 Dim _PromptSys_hFont As HFONT 54 57 Dim _PromptSys_FontSize As SIZE 55 58 Dim _PromptSys_InputStr[255] As StrChar 56 Dim _PromptSys_InputLen As Long59 Dim _PromptSys_InputLen = -1 As Long 57 60 Dim _PromptSys_KeyChar As Byte 58 61 Dim _PromptSys_CurPos As POINTAPI … … 64 67 Dim _System_OSVersionInfo As OSVERSIONINFO 65 68 66 _PromptSys_InputLen = -167 69 68 70 'graphic … … 72 74 Dim _PromptSys_GlobalPos As POINTAPI 73 75 76 Sub _PromptSys_Initialize() 74 77 _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) 78 Dim _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain), 0, 0, _PromptSys_dwThreadID) 77 79 If _PromptSys_hThread = 0 Then 78 80 Debug … … 80 82 End If 81 83 WaitForSingleObject(_PromptSys_hInitFinish, INFINITE) 84 End Sub 82 85 83 86 Sub DrawPromptBuffer(hDC As HDC, StartLine As Long, EndLine As Long) … … 267 270 Dim ps As PAINTSTRUCT 268 271 Dim hdc = BeginPaint(hwnd, ps) 269 'With _PromptSys_ScreenSize270 'BitBlt(hdc, 0, 0, .cx, .cy, _PromptSys_hMemDC, 0, 0, SRCCOPY)271 With ps.rcPaint272 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) 273 276 End With 274 277 DrawPromptBuffer(hdc, -1, 0) … … 287 290 End With 288 291 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) 290 296 End If 291 297 ImmReleaseContext(hwnd, himc) … … 365 371 366 372 SendMessage(hwnd, WM_KILLFOCUS, 0, 0) 367 PRINT_ToPrompt(TempStr)373 ActiveBasic.Prompt.Detail.PRINT_ToPrompt(TempStr) 368 374 SendMessage(hwnd, WM_SETFOCUS, 0, 0) 369 375 End If … … 372 378 Function _PromptWnd_GetCompositionStringW(himc As HIMC, ByRef rpsz As PWSTR) As Long 373 379 Dim size = ImmGetCompositionStringW(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位 374 rpsz = _System_malloc(size) As P TSTR380 rpsz = _System_malloc(size) As PWSTR 375 381 If rpsz = 0 Then 376 382 'Debug … … 382 388 Function _PromptWnd_GetCompositionStringA(himc As HIMC, ByRef rpsz As PSTR) As Long 383 389 Dim size = ImmGetCompositionStringA(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位 384 rpsz = _System_malloc(size) As P TSTR390 rpsz = _System_malloc(size) As PSTR 385 391 If rpsz = 0 Then 386 392 'Debug … … 403 409 tempStr.Assign(str, size) 404 410 #else 405 With _System_OSVersionInfo 411 Dim osver = System.Environment.OSVersion 412 With osver 406 413 ' GetCompositionStringW is not implimented in Windows 95 407 If . dwMajorVersion = 4 And .dwMinorVersion = 0 And .dwPlatformId = VER_PLATFORM_WIN32_WINDOWSThen414 If .Version.Major = 4 And .Version.Minor = 0 And .Platform = System.PlatformID.Win32Windows Then 408 415 Dim strA As PCSTR 409 416 Dim sizeA = _PromptWnd_GetCompositionStringA(himc, strA) … … 421 428 _PromptSys_InputLen += tempStr.Length 422 429 423 SendMessage(hwnd, WM_KILLFOCUS, 0, 0) : Debug424 PRINT_ToPrompt(tempStr)430 SendMessage(hwnd, WM_KILLFOCUS, 0, 0) 431 ActiveBasic.Prompt.Detail.PRINT_ToPrompt(tempStr) 425 432 SendMessage(hwnd, WM_SETFOCUS, 0, 0) 426 433 … … 454 461 End With 455 462 456 'LogFont initialize 457 With _PromptSys_LogFont 463 '_PromptSys_hFont initialize 464 Dim lf As LOGFONT 465 With lf 458 466 .lfHeight = -16 459 467 .lfWidth = 0 … … 469 477 .lfQuality = DEFAULT_QUALITY 470 478 .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) 475 483 476 484 'Critical Section … … 487 495 .hIconSm = LoadImage(0, MAKEINTRESOURCE(IDI_WINLOGO), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HICON 488 496 .hCursor = LoadImage(0, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE Or LR_SHARED) As HCURSOR 489 .lpszClassName = "PROMPT"497 .lpszClassName = ToTCStr("PROMPT") 490 498 .lpfnWndProc = AddressOf(PromptProc) 491 499 .hbrBackground = GetStockObject(BLACK_BRUSH) … … 494 502 495 503 '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"), _ 497 505 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _ 498 506 0, 0, wcl.hInstance, 0) … … 503 511 Do 504 512 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 506 519 TranslateMessage(msg) 507 520 DispatchMessage(msg) … … 509 522 510 523 '強制的に終了する 511 End 'ExitProcess(0)524 End 512 525 513 526 EnterCriticalSection(_PromptSys_SectionOfBufferAccess) … … 522 535 DeleteCriticalSection(_PromptSys_SectionOfBufferAccess) 523 536 524 End 'ExitProcess(0) 525 End Function 526 527 528 '---------------------- 529 ' Prompt text Commands 530 '---------------------- 531 532 Macro CLS()(num As Long) 537 End 538 End Function 539 540 'Prompt text command functoins 541 542 Sub Cls(n As Long) 533 543 Dim i As Long 534 544 535 545 'When parameter was omitted, num is set to 1 536 If n um = 0 Then num= 1537 538 If n um = 1 Or num= 3 Then546 If n = 0 Then n = 1 547 548 If n = 1 Or n = 3 Then 539 549 'Clear the text screen 540 550 For i = 0 To 100 … … 550 560 End If 551 561 552 If n um = 2 Or num= 3 Then562 If n = 2 Or n = 3 Then 553 563 'Clear the graphics screen 554 564 Dim hOldBrush = SelectObject(_PromptSys_hMemDC, GetStockObject(BLACK_BRUSH)) … … 561 571 'Redraw 562 572 InvalidateRect(_PromptSys_hWnd, ByVal 0, 0) 563 End Macro564 565 Macro COLOR(TextColorCode As Long)(BackColorCode As Long)566 _PromptSys_NowTextColor = GetBasicColor( TextColorCode)567 If BackColorCode = -1 Then573 End Sub 574 575 Sub Color(textColorCode As Long, backColorCode As Long) 576 _PromptSys_NowTextColor = GetBasicColor(textColorCode) 577 If backColorCode = -1 Then 568 578 _PromptSys_NowBackColor = -1 569 579 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 582 End Sub 583 584 Sub INPUT_FromPrompt(showStr As String) 579 585 Dim i As Long, i2 As Long, i3 As Long 580 586 Dim buf As String … … 582 588 *InputReStart 583 589 584 PRINT_ToPrompt(ShowStr)590 ActiveBasic.Prompt.Detail.PRINT_ToPrompt(showStr) 585 591 586 592 'Input by keyboard … … 616 622 i++ 617 623 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") 619 625 Goto *InputReStart 620 626 ElseIf _PromptSys_InputStr[i2] = 0 Then 621 627 If _System_InputDataPtr[i]<>0 Then 622 PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")628 ActiveBasic.Prompt.Detail.PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n") 623 629 Goto *InputReStart 624 630 Else … … 631 637 End Sub 632 638 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) 639 Sub Locate(x As Long, y As Long) 638 640 If x < 0 Then x = 0 639 641 If y < 0 Then y = 0 … … 653 655 _PromptSys_TextLine[y].Length = x 654 656 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 657 End Sub 658 659 'Prompt graphic command functions 660 661 Sub 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) 666 662 Dim i1 As Long, i2 As Long, i3 As Long, i4 As Long 667 663 … … 763 759 DeleteObject(hPen) 764 760 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] 761 End Sub 762 763 Sub 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) 770 764 Dim temp As Long 771 765 … … 796 790 End If 797 791 798 Dim h DC= GetDC(_PromptSys_hWnd)792 Dim hdc = GetDC(_PromptSys_hWnd) 799 793 Dim hPen = CreatePen(PS_SOLID, 1, GetBasicColor(ColorCode)) 800 794 Dim hBrush As HBRUSH … … 805 799 End If 806 800 807 SelectObject(h DC, hPen)808 SelectObject(h DC, hBrush)801 SelectObject(hdc, hPen) 802 SelectObject(hdc, hBrush) 809 803 Dim hOldPen = SelectObject(_PromptSys_hMemDC, hPen) 810 804 Dim hOldBrush = SelectObject(_PromptSys_hMemDC, hBrush) … … 816 810 LineTo(_PromptSys_hMemDC,ex,ey) 817 811 SetPixel(_PromptSys_hMemDC,ex,ey,GetBasicColor(ColorCode)) 818 MoveToEx(h DC,sx,sy,ByVal NULL)819 LineTo(h DC,ex,ey)820 SetPixel(h DC,ex,ey,GetBasicColor(ColorCode))812 MoveToEx(hdc,sx,sy,ByVal NULL) 813 LineTo(hdc,ex,ey) 814 SetPixel(hdc,ex,ey,GetBasicColor(ColorCode)) 821 815 Case Else 822 816 'Rectangle 823 Rectangle(h DC,sx,sy,ex+1,ey+1)817 Rectangle(hdc,sx,sy,ex+1,ey+1) 824 818 Rectangle(_PromptSys_hMemDC,sx,sy,ex+1,ey+1) 825 819 End Select 826 820 827 ReleaseDC(_PromptSys_hWnd,h DC)821 ReleaseDC(_PromptSys_hWnd,hdc) 828 822 SelectObject(_PromptSys_hMemDC,hOldPen) 829 823 SelectObject(_PromptSys_hMemDC,hOldBrush) … … 834 828 .y = ey 835 829 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)) 830 End Sub 831 832 Sub PSet(x As Long, y As Long, ColorCode As Long) 833 Dim hdc = GetDC(_PromptSys_hWnd) 834 SetPixel(hdc, x, y, GetBasicColor(ColorCode)) 844 835 SetPixel(_PromptSys_hMemDC, x, y, GetBasicColor(ColorCode)) 845 ReleaseDC(_PromptSys_hWnd, h DC)836 ReleaseDC(_PromptSys_hWnd, hdc) 846 837 With _PromptSys_GlobalPos 847 838 .x = x 848 839 .y = y 849 840 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) 841 End Sub 842 843 Sub 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) 863 851 ExtFloodFill(_PromptSys_hMemDC, x, y, GetBasicColor(LineColor), FLOODFILLBORDER) 864 852 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) 857 End Sub 875 858 876 859 Function Inkey$() As String … … 884 867 885 868 Function Input$(length As Long) As String 886 Dim i As Long869 Dim i = 0 As Long 887 870 888 871 If length<=0 Then … … 891 874 End If 892 875 893 i=0894 876 While 1 895 877 If _PromptSys_KeyChar Then … … 905 887 End Function 906 888 889 End Namespace 'Detail 890 891 Function OwnerWnd() As HWND 892 Return Detail._PromptSys_hWnd 893 End Function 894 895 End Namespace 'Prompt 896 End Namespace 'ActiveBasic 897 898 '---------------------- 899 ' Prompt text Commands 900 '---------------------- 901 902 Sub PRINT_ToPrompt(s As String) 903 ActiveBasic.Prompt.Detail.PRINT_ToPrompt(s) 904 End Sub 905 906 Macro CLS()(num As Long) 907 ActiveBasic.Prompt.Detail.Cls(num) 908 End Macro 909 910 Macro COLOR(TextColorCode As Long)(BackColorCode As Long) 911 ActiveBasic.Prompt.Detail.Color(TextColorCode, BackColorCode) 912 End 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 '---------------------------------------------- 918 Sub INPUT_FromPrompt(ShowStr As String) 919 ActiveBasic.Prompt.Detail.INPUT_FromPrompt(ShowStr) 920 End Sub 921 922 Sub PRINTUSING_ToPrompt(UsingStr As String) 923 ActiveBasic.Prompt.Detail.PRINT_ToPrompt(_System_GetUsingFormat(UsingStr)) 924 End Sub 925 926 Macro LOCATE(x As Long, y As Long) 927 ActiveBasic.Prompt.Detail.Locate(x, y) 928 End Macro 929 930 931 '------------------- 932 ' Graphics Commands 933 '------------------- 934 935 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) 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) 939 End Macro 940 941 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) 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) 945 End Macro 946 947 Macro PSET(x As Long, y As Long)(ColorCode As Long) 948 '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します) 949 'PSet (x,y),ColorCode 950 ActiveBasic.Prompt.Detail.PSet(x, y, ColorCode) 951 End Macro 952 953 Macro 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) 957 End Macro 958 959 960 '----------- 961 ' Functions 962 '----------- 963 964 Function Inkey$() As String 965 Return ActiveBasic.Prompt.Detail.Inkey$() 966 End Function 967 968 Function Input$(length As Long) As String 969 Return ActiveBasic.Prompt.Detail.Input$(length) 970 End Function 971 972 ActiveBasic.Prompt.Detail._PromptSys_Initialize() 907 973 908 974 #endif '_INC_PROMPT
Note:
See TracChangeset
for help on using the changeset viewer.