Const IDI_APPLICATION
= 32512
Const WS_EX_CLIENTEDGE
= &H00000200 Const WS_OVERLAPPED
= &H00000000 Const WS_CAPTION
= &H00C00000 Const WS_SYSMENU
= &H00080000 Const WS_THICKFRAME
= &H00040000 Const WS_MINIMIZEBOX
= &H00020000 Const WS_MAXIMIZEBOX
= &H00010000 Const WS_OVERLAPPEDWINDOW
= WS_OVERLAPPED
Or WS_CAPTION
Or WS_SYSMENU
Or WS_THICKFRAME
Or WS_MINIMIZEBOX
Or WS_MAXIMIZEBOX
Const CW_USEDEFAULT
= &H80000000 Const WS_TABSTOP
= &H00010000 Const WS_CHILD
= &H40000000 Const WS_VISIBLE
= &H10000000
Const WS_VSCROLL
= &H00200000 Const WS_HSCROLL
= &H00100000
Const BS_AUTOCHECKBOX
= 3 Const BS_AUTORADIOBUTTON
= 9 Const BS_SPLITBUTTON
= &HC Const BS_DEFPUSHBUTTON
= &H00000001
Const SW_SHOWDEFAULT
= &HA
Const WM_GETTEXT
= &H000D Const WM_COMMAND
= &H0111 Const WM_ENTERSIZEMOVE
= &H0231 Const WM_EXITSIZEMOVE
= &H0232
Const SPI_GETNONCLIENTMETRICS
= &H0029 Const WM_SETFONT
= &H0030
Const PROGRESS_CLASS
= "msctls_progress32"
Const CCM_LAST
= CCM_FIRST
+ &H200 Const CCM_SETBKCOLOR
= CCM_FIRST
+ 1 Const CCM_SETCOLORSCHEME
= CCM_FIRST
+ 2 Const CCM_GETCOLORSCHEME
= CCM_FIRST
+ 3 Const CCM_GETDROPTARGET
= CCM_FIRST
+ 4 Const CCM_SETUNICODEFORMAT
= CCM_FIRST
+ 5 Const CCM_GETUNICODEFORMAT
= CCM_FIRST
+ 6 Const CCM_SETVERSION
= CCM_FIRST
+ &H7 Const CCM_GETVERSION
= CCM_FIRST
+ &H8 Const CCM_SETNOTIFYWINDOW
= CCM_FIRST
+ &H9 Const CCM_SETWINDOWTHEME
= CCM_FIRST
+ &HB Const CCM_DPISCALE
= CCM_FIRST
+ &HC
Const COMCTL32_VERSION
= 6
Const PBM_SETRANGE
= WM_USER
+ 1 Const PBM_SETPOS
= WM_USER
+ 2 Const PBM_DELTAPOS
= WM_USER
+ 3 Const PBM_SETSTEP
= WM_USER
+ 4 Const PBM_STEPIT
= WM_USER
+ 5 Const PBM_SETRANGE32
= WM_USER
+ 6 Const PBM_SETSTATE
= WM_USER
+ 16
Const PBM_GETRANGE
= WM_USER
+ 7 Const PBM_GETPOS
= WM_USER
+ 8 Const PBM_SETBARCOLOR
= WM_USER
+ 9 Const PBM_SETBKCOLOR
= CCM_SETBKCOLOR
Const WM_SETTEXT
= &H000C
Const ES_AUTOVSCROLL
= &H0040 Const ES_AUTOHSCROLL
= &H0080 Const ES_WANTRETURN
= &H1000 Const ES_READONLY
= &H0800
Const WC_COMBOBOX
= "ComboBox"
Const WM_CTLCOLORBTN
= &H0135
Const WM_ERASEBKGND
= &H0014
As Long cbClsExtra
, cbWndExtra
As Offset hInstance
, hIcon
, hCursor
, hbrBackground
, lpszMenuName
, lpszClassName
, hIconSm
As Long left
, top
, right
, bottom
Function CreateWindowEx%&
(ByVal dwExStyle
As Long, Byval lpClassName
As Offset, Byval lpWindowName
As Offset, Byval dwStyle
As Long, Byval X
As Long, Byval Y
As Long, Byval nWidth
As Long, Byval nHeight
As Long, Byval hWndParent
As Offset, Byval wMenu
As Offset, Byval hInstance
As Offset, Byval lpParam
As Offset) Sub CreateWindowEx
(ByVal dwExStyle
As Long, Byval lpClassName
As Offset, Byval lpWindowName
As Offset, Byval dwStyle
As Long, Byval X
As Long, Byval Y
As Long, Byval nWidth
As Long, Byval nHeight
As Long, Byval hWndParent
As Offset, Byval wMenu
As Offset, Byval hInstance
As Offset, Byval lpParam
As Offset)
'Function CreateFontIndirect%& Alias "CreateFontIndirectA" (ByVal lplf As Offset)
Function CreateFont%&
Alias "CreateFontA" (ByVal cHeight
As Long, Byval cWidth
As Long, Byval cEscapement
As Long, Byval cOrientation
As Long, Byval cWeight
As Long, Byval bItalic
As Unsigned Long, Byval bUnderline
As Unsigned Long, Byval bStrikeout
As Unsigned Long, Byval iCharSet
As Unsigned Long, Byval iOutPrecision
As Unsigned Long, Byval iClipPrecision
As Unsigned Long, Byval iQuality
As Unsigned Long, Byval iPitchAndFamily
As Unsigned Long, pszFaceName
As String)
wc.lpfnWndProc = GetWindowProc
wc.hInstance = hInstance
wc.hCursor = LoadCursor(0, MAKEINTRESOURCE(IDC_ARROW))
wc.hIcon
= ExtractIcon
(0, _CWD$ + "\WSA-icon.ico" + Chr$(0), 0)wc.hbrBackground = CreateSolidBrush(__RGB(61, 219, 134))
wc.lpszClassName
= Offset(className
)
Dim As String childTitle: childTitle
= "QB64 APK Installer for WSA" + Chr$(0) Dim Shared As Offset parentWin: parentWin
= CreateWindowEx
(0, MAKELPARAM
(reg
, 0), Offset(childTitle
), WS_OVERLAPPED
Or WS_CAPTION
Or WS_SYSMENU
Or WS_MINIMIZEBOX
Or WS_MAXIMIZEBOX
, CW_USEDEFAULT
, CW_USEDEFAULT
, 320, 120, 0, 0, hInstance
, 0)
Dim Shared As Offset browseBtn: browseBtn
= CreateWindowEx
(0, Offset(t0
), Offset(t1
), WS_TABSTOP
Or WS_VISIBLE
Or WS_CHILD
Or BS_DEFPUSHBUTTON
, 5, 10, 50, 25, parentWin
, 0, hInstance
, 0)
Dim Shared As Offset installBtn: installBtn
= CreateWindowEx
(0, Offset(t0
), Offset(t1
), WS_TABSTOP
Or WS_VISIBLE
Or WS_CHILD
Or BS_DEFPUSHBUTTON
, 80, 10, 50, 25, parentWin
, 0, hInstance
, 0)
Dim Shared As Offset outputBox: outputBox
= NewEditBox
(5, 50, 300, 20, "READONLY", "")
SetFont browseBtn, "Arial", 12, "", "BLACK"
SetFont installBtn, "Arial", 12, "", "BLACK"
SetFont outputBox, "Arial", 16, "", ""
ShowWindow parentWin, SW_SHOWDEFAULT
UpdateWindow parentWin
WindowProc = DefWindowProc(hwnd, uMsg, wParam, lParam)
PostQuitMessage 0
WindowProc = 0
APKfile
= ComDlgFileName
("Open APK Package", Dir$("downloads"), "Android APK Files(*.APK)|*.APK", 1, 0) + Chr$(0) SetWindowText outputBox
, Offset(APKfile
) stdout = pipecom_lite("adb connect 127.0.0.1:58526")
Shell "adb install " + APKfile
SoftError "Connection failure", "adb failed to connect to the Windows Subsystem for Android host"
WindowProc = DefWindowProc(hwnd, uMsg, wParam, lParam)
flags
= WS_CHILD
Or WS_VISIBLE
flags
= flags
Or WS_VSCROLL
Or WS_HSCROLL
Or ES_AUTOHSCROLL
Or ES_AUTOVSCROLL
Or ES_LEFT
Or ES_MULTILINE
Or ES_WANTRETURN
flags
= flags
Or WS_VSCROLL
Or ES_AUTOVSCROLL
Or ES_LEFT
Or ES_MULTILINE
Or ES_WANTRETURN
flags
= flags
Or ES_READONLY
defaultText
= defaultText
+ Chr$(0) NewEditBox
= CreateWindowEx
(0, Offset(class
), Offset(defaultText
), flags
, x
, y
, w
, h
, parentWin
, 0, hInstance
, 0)
GetWindowRect parentWin
, Offset(rect
) WindowHeight = rect.bottom - rect.top
GetWindowRect parentWin
, Offset(rect
) WindowWidth = rect.right - rect.left
Const SWP_NOSIZE
= &H0001 SetWindowPos parentWin, 0, X, Y, 0, 0, SWP_NOSIZE
Const SWP_NOMOVE
= &H0002 SetWindowPos parentWin, 0, 0, 0, w, h, SWP_NOMOVE
GetWindowText parentWin
, Offset(wintitle
), Len(wintitle
) WindowTitle = wintitle
Dim As Byte bold
, underline
, strikeout
, italic
weight = 100
Case "EXTRALIGHT", "ULTRALIGHT" weight = 200
weight = 300
weight = 400
weight = 500
Case "SEMIBOLD", "DEMIBOLD" weight = 600
weight = 700
Case "EXTRABOLD", "ULTRABOLD" weight = 800
weight = 900
weight = 0
__font
= CreateFont
(__height
, 0, 0, 0, weight
, italic
, underline
, strikeout
, 0, 0, 0, 5, FF_DECORATIVE
Or FF_MODERN
Or FF_ROMAN
Or FF_SCRIPT
Or FF_SWISS
, fontName
+ Chr$(0)) SendMessage controlHandle, WM_SETFONT, __font, MAKELPARAM(-1, 0)
EnableWindow controlHandle, -1
EnableWindow controlHandle, 0
SendMessage pbHandle
, PBM_GETRANGE
, 0, Offset(range
) Dim As Offset currentpos: currentpos
= SendMessage
(pbHandle
, PBM_GETPOS
, 0, 0) SendMessage pbHandle, PBM_DELTAPOS, amount, 0
SendMessage pbHandle
, PBM_GETRANGE
, 0, Offset(range
) Dim As Offset currentpos: currentpos
= SendMessage
(pbHandle
, PBM_GETPOS
, 0, 0) If currentpos
>= range.iHigh
Or newValue
> range.iHigh
Or newValue
< range.iLow
Then Exit Sub SendMessage pbHandle, PBM_SETPOS, newValue, 0
SendMessage pbHandle
, PBM_GETRANGE
, 0, Offset(range
) Dim As Offset currentpos: currentpos
= SendMessage
(pbHandle
, PBM_GETPOS
, 0, 0) SendMessage pbHandle, PBM_STEPIT, 0, 0
SendMessage pbHandle, PBM_SETSTATE, PBST_NORMAL, 0
SendMessage pbHandle, PBM_SETSTATE, PBST_ERROR, 0
SendMessage pbHandle, PBM_SETSTATE, PBST_PAUSED, 0
Rem $Include:'MessageBox.BM'