CODE: [Copy to clipboard]
Option Explicit
Public Const SW_NORMAL = 1
Public Const SW_MAXIMIZE = 3
Public Const SW_RESTORE = 9
Public Const HWND_TOP = 0
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare Function ShowWindowAsync Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
下面的事就很简单了。
相信大家也知道了吧。
在窗体frmmain的load事件中加入如下代码:
CODE: [Copy to clipboard]
Private Sub Form_Load()
Dim temphwnd As Long, x As Long, AppTitle As String
If App.PrevInstance Or FindWindow("ThunderRT5Form", App.Title) > 0 Then
'get the handle to the window
'for non-mdi forms use:
temphwnd = FindWindow("ThunderRT5Form", App.Title)
'for MDI forms use:
'temphwnd = FindWindow("ThunderRT5MDIForm", App.Title)
AppTitle = App.Title
App.Title = "#$#"
Caption = "#$#"
'activate the previous instance at the same
'place and size it was before
'could do to non-asyc with ShowWindow but that
'lead to problems when working outside the current thread
x = ShowWindowAsync(temphwnd, SW_RESTORE)
SetWindowPos temphwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
'set focus to it
AppActivate AppTitle
SetWindowPos temphwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End
End If
Caption = App.Title
Show
lblemail = email
lblurl = URL
End Sub
在标签label1的click事件中写:
CODE: [Copy to clipboard]
Private Sub Label1_Click()
gotoweb
End Sub
在标签lblemail的click事件中写:
CODE: [Copy to clipboard]
Private Sub lblemail_Click()
sendemail
End Sub
在标签 lblurl的click事件中写:
CODE: [Copy to clipboard]
Private Sub lblurl_Click()
gotoweb
End Sub
在按纽cmdend的click事件中:
CODE: [Copy to clipboard]
Private Sub cmdend_Click()
End
End Sub
好了,这样,就完成了在VB中加入超级连接的功能。
上一页 [1] [2]