Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chunmingwang authored Aug 24, 2023
1 parent 6960c6f commit f4fa56c
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 104 deletions.
33 changes: 7 additions & 26 deletions Download.bas
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#include once "Download.bi"
#pragma once
' Download 下载
' Copyright (c) 2022 CM.Wang
' Freeware. Use at your own risk.

#include once "Download.bi"

Constructor Download()
hLib = DyLibLoad("urlmon.dll")
Expand Down Expand Up @@ -28,14 +33,6 @@ Destructor Download()
If hLib Then DyLibFree(hLib)
End Destructor

Private Property Download.DeleteCacheEntry(nVal As Boolean)
mDeleteCache = nVal
End Property

Private Property Download.DeleteCacheEntry() As Boolean
Return mDeleteCache
End Property

Sub Download.DownloadUrl(ByVal Owner As Any Ptr, ByRef Url As Const WString, ByRef FileName As Const WString)
mBSC->pOwner = Owner
mOwner = Owner
Expand All @@ -52,7 +49,7 @@ Sub Download.DownloadUrl(ByVal Owner As Any Ptr, ByRef Url As Const WString, ByR
DonePercent = 0
DownloadSpeed = 0

If mDeleteCache Then DeleteUrlCacheEntry(mUrl)
If DeleteCacheEntry Then DeleteUrlCacheEntry(mUrl)
mThread = ThreadCreate(Cast(Any Ptr, @DownloadThread), @This)
End Sub

Expand All @@ -71,14 +68,6 @@ Private Sub Download.DownloadDoing()
Done = True
End Sub

'Private Property Download.Cancel() As Boolean
' Return Cancel
'End Property
'
'Private Property Download.Cancel(ByVal nVal As Boolean)
' Cancel = nVal
'End Property

Private Property Download.ElapsedTime() As Double
If mTimeStart Then
If mTimeStop = False Then
Expand All @@ -99,14 +88,6 @@ Private Property Download.Done(ByVal nVal As Integer)
If mDone<> NULL AndAlso OnDone<> NULL Then OnDone(mOwner)
End Property

'Private Property Download.Status() As Integer
' Return mStatus
'End Property
'
'Private Property Download.Status(ByVal nVal As Integer)
' mStatus = nVal
'End Property

Private Function Download.OnStartBinding(ByVal IBSCO As IBindStatusCallback_CM Ptr, ByVal dwReserved As DWORD, ByVal pib As IBinding Ptr) As HRESULT
Dim d As Download Ptr = IBSCO->pThis
If d->Cancel Then Return E_ABORT Else Function = E_NOTIMPL
Expand Down
16 changes: 8 additions & 8 deletions Download.bi
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#include once "win/wininet.bi"
#pragma once
' Download 下载
' Copyright (c) 2022 CM.Wang
' Freeware. Use at your own risk.

#include once "win/wininet.bi"
#include once "win/urlmon.bi"
#include once "../MDINotepad/Text.bi"
#include once "../MDINotepad/TimeMeter.bi"

'https://forum.powerbasic.com/forum/user-to-user-discussions/programming/20626-using-the-urldownloadtofile-api
'https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775123(v=vs.85)

Type IBindStatusCallback_CM
lpVtbl As IBindStatusCallbackVtbl Ptr 'lpVtbl
Expand All @@ -24,7 +30,6 @@ Private:
mFileName As WString Ptr = NULL

mDone As Boolean = False
mDeleteCache As Boolean = False
TiMtr As TimeMeter
mElapsedTime As Double
mTimeStart As Boolean
Expand Down Expand Up @@ -57,6 +62,7 @@ Public:
DownloadSize As ULong
DonePercent As Double
DownloadSpeed As Double
DeleteCacheEntry As Boolean = False

Public:

Expand All @@ -66,16 +72,10 @@ Public:
OnMsg As Sub(Owner As Any Ptr, ByRef MsgStr As Const WString)
OnCacheFile As Sub(Owner As Any Ptr, ByRef CacheFile As Const WString)
OnReDir As Sub(Owner As Any Ptr, ByRef Url As Const WString)
'Declare Property Cancel() As Boolean
'Declare Property Cancel(ByVal nVal As Boolean)
Declare Property Done() As Integer
Declare Property Done(ByVal nVal As Integer)
Declare Property ElapsedTime() As Double
'Declare Property Status() As Integer
'Declare Property Status(ByVal nVal As Integer)
Declare Sub DownloadUrl(ByVal Owner As Any Ptr, ByRef Url As Const WString, ByRef FileName As Const WString)
Declare Property DeleteCacheEntry() As Boolean
Declare Property DeleteCacheEntry(ByVal nVal As Boolean)
End Type

#ifndef __USE_MAKE__
Expand Down
10 changes: 4 additions & 6 deletions Download.vfp
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,28 @@
File=../MDINotepad/FileAct.bi
File=../MDINotepad/ITL3.bi
File=../MDINotepad/Text.bi
File=../MDINotepad/TimeMeter.bi
*File=frmDownload.frm
File=Download.bas
File=../MDINotepad/FileAct.bas
File=../MDINotepad/ITL3.bas
File=../MDINotepad/Text.bas
File=../MDINotepad/TimeMeter.bas
*File=frmDownload.rc
ProjectType=0
Subsystem=2
ProjectName="Download"
HelpFileName=""
ProjectDescription="Download"
PassAllModuleFilesToCompiler=false
OpenProjectAsFolder=false
MajorVersion=0
MinorVersion=0
RevisionVersion=0
BuildVersion=432
BuildVersion=484
AutoIncrementVersion=false
ApplicationTitle="Download"
ApplicationIcon=""
Manifest=true
RunAsAdministrator=false
CompanyName="VisualFBEditor"
CompanyName="Visual FB Editor"
FileDescription="{ProjectDescription}"
InternalName="Download"
LegalCopyright="Cm.Wang"
Expand All @@ -37,7 +35,7 @@ OptimizationLevel=0
OptimizationFastCode=false
OptimizationSmallCode=false
CompilationArguments32Windows="-x "Download32.exe""
CompilationArguments64Windows="-x "Download64.exe""
CompilationArguments64Windows="-x "Download64.exe" -gen gas64"
CompilationArguments32Linux=""
CompilationArguments64Linux=""
CompilerPath=""
Expand Down
25 changes: 15 additions & 10 deletions Download32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ https://github.com/PaulSquires/WinFBE/archive/refs/heads/master.zip
https://github.com/PaulSquires/WinFormsX/archive/refs/heads/master.zip
https://github.com/JoseRoca/WinFBX/archive/refs/heads/master.zip
https://github.com/tannerhelland/PhotoDemon/archive/refs/heads/main.zip
https://www.scintilla.org/scintilla531.zip
https://www.scintilla.org/scite531.zip
https://www.scintilla.org/wscite531.zip
https://www.scintilla.org/wscite32_531.zip
https://www.7-zip.org/a/7z2201-x64.exe
https://dl1.cdn.filezilla-project.org/client/FileZilla_3.61.0_win32-setup.exe
https://the.earth.li/~sgtatham/putty/latest/wa64/putty.zip
https://github.com/git-for-windows/git/releases/download/v2.38.1.windows.1/PortableGit-2.38.1-64-bit.7z.exe
http://www.foobar2000.org/files/foobar2000_v1.6.13.exe
https://users.freebasic-portal.de/stw/builds/freebasic_manual.chm
https://users.freebasic-portal.de/stw/builds/freebasic_additional_headers.zip
https://users.freebasic-portal.de/stw/builds/win32_mingw_additional_libs.zip
https://users.freebasic-portal.de/stw/builds/win64_mingw_additional_libs.zip
https://users.freebasic-portal.de/stw/builds/win32/fbc_win32_mingw_0795_2023-02-11.zip
https://users.freebasic-portal.de/stw/builds/win64/fbc_win64_mingw_0806_2023-02-11.zip
https://www.scintilla.org/scintilla533.zip
https://www.scintilla.org/scite533.zip
https://www.scintilla.org/wscite533.zip
https://www.scintilla.org/wscite32_533.zip
https://7-zip.org/a/7z2201-x64.exe
https://download.filezilla-project.org/client/FileZilla_3.63.1_win64_sponsored2-setup.exe
https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.78-installer.msi
https://www.foobar2000.org/getfile/foobar2000_v1.6.16.exe
https://t1.daumcdn.net/potplayer/PotPlayer/Version/Latest/PotPlayerSetup64.exe
https://www.elnec.com/sw/beeh304dev.zip
https://github.com/Nevcairiel/LAVFilters/releases/download/0.77.2/LAVFilters-0.77.2-Installer.exe
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Download
Example for VisualFBEditor

URLDownloadToFile

https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms775123(v=vs.85)

![Download](https://user-images.githubusercontent.com/35757455/199168803-02b1b4b2-7639-4738-895f-fb6dfd13554e.gif)
65 changes: 14 additions & 51 deletions frmDownload.frm
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'#Region "Form"
#if defined(__FB_MAIN__) AndAlso Not defined(__MAIN_FILE__)
#define __MAIN_FILE__
Const _MAIN_FILE_ = __FILE__
#ifdef __FB_WIN32__
#cmdline "frmDownload.rc"
#endif
Const _MAIN_FILE_ = __FILE__
#endif

#include once "string.bi"
#include once "mff/Form.bi"
#include once "mff/CommandButton.bi"
#include once "mff/Dialogs.bi"
#include once "mff/Label.bi"
Expand All @@ -16,8 +16,6 @@
#include once "mff/CheckBox.bi"
#include once "mff/TimerComponent.bi"
#include once "mff/GroupBox.bi"

#include once "mff/Form.bi"
#include once "mff/TextBox.bi"
#include once "mff/CommandButton.bi"
#include once "mff/ComboBoxEdit.bi"
Expand All @@ -40,19 +38,12 @@

Declare Sub CtlEnabled(e As Boolean)

Declare Static Sub _cmdButton_Click(ByRef Sender As Control)
Declare Sub cmdButton_Click(ByRef Sender As Control)
Declare Static Sub _cmbSourceURL_Selected(ByRef Sender As ComboBoxEdit, ItemIndex As Integer)
Declare Sub cmbSourceURL_Selected(ByRef Sender As ComboBoxEdit, ItemIndex As Integer)
Declare Static Sub _Form_Show(ByRef Sender As Form)
Declare Sub Form_Show(ByRef Sender As Form)
Declare Static Sub _cmbSourceURL_Change(ByRef Sender As ComboBoxEdit)
Declare Sub cmbSourceURL_Change(ByRef Sender As ComboBoxEdit)
Declare Static Sub _Form_Create(ByRef Sender As Control)
Declare Sub Form_Create(ByRef Sender As Control)
Declare Static Sub _Form_Close(ByRef Sender As Form, ByRef Action As Integer)
Declare Sub Form_Close(ByRef Sender As Form, ByRef Action As Integer)
Declare Static Sub _TimerComponent1_Timer(ByRef Sender As TimerComponent)
Declare Sub TimerComponent1_Timer(ByRef Sender As TimerComponent)
Declare Constructor

Expand Down Expand Up @@ -86,9 +77,9 @@
'...instructions for other OSes
.Caption = "VFBE URLDownloadToFile32"
#endif
.OnShow = @_Form_Show
.OnCreate = @_Form_Create
.OnClose = @_Form_Close
.OnShow = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @Form_Show)
.OnCreate = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @Form_Create)
.OnClose = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Form, ByRef Action As Integer), @Form_Close)
.BorderStyle = FormBorderStyle.FixedSingle
.MinimizeBox = True
.MaximizeBox = False
Expand Down Expand Up @@ -134,8 +125,8 @@
.SetBounds 10, 30, 480, 21
.Designer = @This
.Parent = @GroupBox1
.OnSelected = @_cmbSourceURL_Selected
.OnChange = @_cmbSourceURL_Change
.OnSelected = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As ComboBoxEdit, ItemIndex As Integer), @cmbSourceURL_Selected)
.OnChange = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As ComboBoxEdit), @cmbSourceURL_Change)
.AddItem "https://github.com/XusinboyBekchanov/VisualFBEditor/archive/refs/heads/master.zip"
.AddItem "https://github.com/XusinboyBekchanov/MyFbFramework/archive/refs/heads/master.zip"
.AddItem "https://github.com/PaulSquires/WinFBE/archive/refs/heads/master.zip"
Expand Down Expand Up @@ -169,7 +160,7 @@
.Caption = "Select"
.SetBounds 400, 20, 90, 20
.Designer = @This
.OnClick = @_cmdButton_Click
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @cmdButton_Click)
.Parent = @GroupBox2
End With
' txtTargetFile
Expand All @@ -189,7 +180,7 @@
.Caption = "Browse"
.SetBounds 400, 50, 90, 20
.Designer = @This
.OnClick = @_cmdButton_Click
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @cmdButton_Click)
.Parent = @GroupBox2
End With
' lblSourceSize
Expand Down Expand Up @@ -273,7 +264,7 @@
.Enabled = False
.SetBounds 320, 420, 90, 20
.Designer = @This
.OnClick = @_cmdButton_Click
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @cmdButton_Click)
.Parent = @This
End With
' cmdDownload
Expand All @@ -284,7 +275,7 @@
.Caption = "Download"
.SetBounds 420, 420, 90, 20
.Designer = @This
.OnClick = @_cmdButton_Click
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @cmdButton_Click)
.Parent = @This
End With
' FolderBrowserDialog1
Expand All @@ -300,39 +291,11 @@
.Interval = 100
.SetBounds 10, 10, 16, 16
.Designer = @This
.OnTimer = @_TimerComponent1_Timer
.OnTimer = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As TimerComponent), @TimerComponent1_Timer)
.Parent = @GroupBox3
End With
End Constructor

Private Sub frmDownloadType._TimerComponent1_Timer(ByRef Sender As TimerComponent)
*Cast(frmDownloadType Ptr, Sender.Designer).TimerComponent1_Timer(Sender)
End Sub

Private Sub frmDownloadType._Form_Close(ByRef Sender As Form, ByRef Action As Integer)
*Cast(frmDownloadType Ptr, Sender.Designer).Form_Close(Sender, Action)
End Sub

Private Sub frmDownloadType._Form_Create(ByRef Sender As Control)
*Cast(frmDownloadType Ptr, Sender.Designer).Form_Create(Sender)
End Sub

Private Sub frmDownloadType._cmbSourceURL_Change(ByRef Sender As ComboBoxEdit)
*Cast(frmDownloadType Ptr, Sender.Designer).cmbSourceURL_Change(Sender)
End Sub

Private Sub frmDownloadType._Form_Show(ByRef Sender As Form)
*Cast(frmDownloadType Ptr, Sender.Designer).Form_Show(Sender)
End Sub

Private Sub frmDownloadType._cmbSourceURL_Selected(ByRef Sender As ComboBoxEdit, ItemIndex As Integer)
*Cast(frmDownloadType Ptr, Sender.Designer).cmbSourceURL_Selected(Sender, ItemIndex)
End Sub

Private Sub frmDownloadType._cmdButton_Click(ByRef Sender As Control)
*Cast(frmDownloadType Ptr, Sender.Designer).cmdButton_Click(Sender)
End Sub

Dim Shared frmDownload As frmDownloadType

#if _MAIN_FILE_ = __FILE__
Expand Down Expand Up @@ -424,8 +387,8 @@ End Sub

Private Sub frmDownloadType.Form_Create(ByRef Sender As Control)
Dim hr As HRESULT = CoInitialize(0)
Dim i As Integer = InStrRev(App.FileName, "\") - 1
txtTargetPath.Text = Mid(App.FileName, 1, i)
Dim i As Integer = InStrRev(App.FileName, "\")
txtTargetPath.Text = Mid(App.FileName, 1, i - 1) ' & "Download"
Dim t As WString Ptr
Dim s As WString Ptr
Dim ss(Any) As WString Ptr
Expand Down
6 changes: 3 additions & 3 deletions frmDownload.rc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#define APP_TITLE_STR "Download\0"
#define VER_FILEDESCRIPTION_STR "Download\0"

#define VER_FILEVERSION 0,0,0,432
#define VER_FILEVERSION_STR "0.0.0.432\0"
#define VER_FILEVERSION 0,0,0,480
#define VER_FILEVERSION_STR "0.0.0.480\0"

#define VER_LEGALCOPYRIGHT_STR "Cm.Wang\0"

Expand All @@ -15,7 +15,7 @@

#define VER_PRODUCTVERSION 0,0,0,0
#define VER_PRODUCTVERSION_STR "0.0.0\0"
#define VER_COMPANYNAME_STR "VisualFBEditor\0"
#define VER_COMPANYNAME_STR "Visual FB Editor\0"

VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
Expand Down

0 comments on commit f4fa56c

Please sign in to comment.