Страница: 1 |
Вопрос: HELP!!!!ПОМОГИТЕ!!!!VB6
Добавлено: 20.08.10 20:43
Автор вопроса: MISTER X | Web-сайт: studioartf.ru | ICQ: 463865965
на форме имеется:Command1 и Image1.
задача:по клику Command1 вывести изображение в Image1 либо по ссылке из интернета либо с компа(локально).
Private Sub Command1_Click()
Image1.Picture = "C:/logo.gif"
End sub
или
Private Sub Command1_Click()
Image1.Picture = "http://www.site/logo.gif"
End sub
при нажатии на кнопку. выделяет "...logo.gif" и выдает ошибку Type mismatch
как мне реализовать загрузку картинки в Image1??? при этом по клику ссылка разная,т.е картинка тоже т.е она должна еще и меняться.
Заранее спасибо
Ответить
Номер ответа: 3Автор ответа: Сurious
Вопросов: 7Ответов: 18
Профиль | | #3
Добавлено: 22.08.10 18:39
А пути следующие.
Код модуля:
Option Explicit
Public Const INTERNET_SERVICE_FTP = 1
Public Const INTERNET_SERVICE_GOPHER = 2
Public Const INTERNET_SERVICE_HTTP = 3
Public Const INTERNET_DEFAULT_HTTP_PORT = 80
Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Public Const INTERNET_FLAG_RELOAD = &H80000000
Public Const HTTP_QUERY_CONTENT_TYPE = 1
Public Const HTTP_QUERY_CONTENT_LENGTH = 5
Public Const HTTP_QUERY_EXPIRES = 10
Public Const HTTP_QUERY_LAST_MODIFIED = 11
Public Const HTTP_QUERY_PRAGMA = 17
Public Const HTTP_QUERY_VERSION = 18
Public Const HTTP_QUERY_STATUS_CODE = 19
Public Const HTTP_QUERY_STATUS_TEXT = 20
Public Const HTTP_QUERY_RAW_HEADERS = 21
Public Const HTTP_QUERY_RAW_HEADERS_CRLF = 22
Public Const HTTP_QUERY_FORWARDED = 30
Public Const HTTP_QUERY_SERVER = 37
Public Const HTTP_QUERY_USER_AGENT = 39
Public Const HTTP_QUERY_SET_COOKIE = 43
Public Const HTTP_QUERY_REQUEST_METHOD = 45
Public Declare Function InternetOpen Lib "wininet.dll" _
Alias "InternetOpenA" ( _
ByVal lpszCallerName As String , ByVal dwAccessType As Long , _
ByVal lpszProxyName As String , ByVal lpszProxyBypass As String , _
ByVal dwFlags As Long ) As Long
Public Declare Function InternetConnect Lib "wininet.dll" _
Alias "InternetConnectA" ( _
ByVal hInternetSession As Long , ByVal lpszServerName As String , _
ByVal nProxyPort As Integer , ByVal lpszUsername As String , _
ByVal lpszPassword As String , ByVal dwService As Long , _
ByVal dwFlags As Long , ByVal dwContext As Long ) As Long
Public Declare Function HttpOpenRequest Lib "wininet.dll" _
Alias "HttpOpenRequestA" (ByVal hInternetSession As Long , _
ByVal lpszVerb As String , ByVal lpszObjectName As String , _
ByVal lpszVersion As String , ByVal lpszReferer As String , _
ByVal lpszAcceptTypes As Long , ByVal dwFlags As Long , _
ByVal dwContext As Long ) As Long
Public Declare Function HttpSendRequest Lib "wininet.dll" _
Alias "HttpSendRequestA" (ByVal hHttpRequest As Long , _
ByVal sHeaders As String , ByVal lHeadersLength As Long , _
ByVal sOptional As String , ByVal lOptionalLength As Long ) As Boolean
Public Declare Function InternetReadFile Lib "wininet.dll" _
(ByVal hFile As Long , ByVal sBuffer As String , _
ByVal lNumBytesToRead As Long , _
lNumberOfBytesRead As Long ) As Integer
Public Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInternetHandle As Long ) As Boolean
Public Declare Function HttpQueryInfo Lib "wininet.dll" _
Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long , _
ByVal lInfoLevel As Long , ByVal sBuffer As String , _
ByRef lBufferLength As Long , ByRef lIndex As Long ) As Integer
Public Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long , _
ByVal szURL As String , ByVal szFileName As String , _
ByVal dwReserved As Long , ByVal lpfnCB As Long ) As Long
Public Declare Function lcreat Lib "kernel32" _
Alias "_lcreat" (ByVal lpPathName As String , _
ByVal iAttribute As Long ) As Long
Public Declare Function lwriteStr Lib "kernel32" _
Alias "_lwrite" (ByVal hFile As Long , _
ByVal lpBuffer As String , ByVal wBytes As Long ) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long ) As Long
Global hInternetOpen As Long
Global aRet As Long
Код формы:
Private Sub Command1_Click()
If URLDownloadToFile(0, " " http://www.site/logo.gif"" , "C:\logo.gif" , 0, 0) = 0 Then
Image1.Picture = LoadPicture("C:\logo.gif" )
End If
End Sub
Private Sub Form_Load()
hInternetOpen = InternetOpen("AftarSoft TestAgent" , INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer , UnloadMode As Integer )
aRet = InternetCloseHandle(hInternetOpen)
End Sub
Ответить
Страница: 1 |
Поиск по форуму