- Код: Выделить всё
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form
Const WS_CHILD As Integer = &H40000000
Const WM_LBUTTONDOWN As Short = &H201s
Const WM_LBUTTONUP As Short = &H202s
Const SW_HIDE As Short = 0
Const SW_NORMAL As Short = 1
Private Structure RECT
Dim Left_Renamed As Integer
Dim Top_Renamed As Integer
Dim Right_Renamed As Integer
Dim Bottom_Renamed As Integer
End Structure
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA"(ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Integer, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hWndParent As Integer, ByVal hMenu As Integer, ByVal hInstance As Integer, ByRef lpParam As Long) As Integer
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Integer) As Integer
Dim bWnd, tWnd, ncWnd As Integer
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Dim R As RECT
'находим taskbar's handle
tWnd = FindWindow("Shell_TrayWnd", vbNullString)
'находим start-button's handle
bWnd = FindWindowEx(tWnd, 0, "BUTTON", vbNullString)
'позиция start'a
GetWindowRect(bWnd, R)
'вот и создаем свою кнопку
ncWnd = CreateWindowEx(0, "BUTTON", "Hello !", WS_CHILD, 0, 0, R.Right_Renamed - R.Left_Renamed, R.Bottom_Renamed - R.Top_Renamed, tWnd, 0, VB6.GetHInstance.ToInt32, 0)
ShowWindow(ncWnd, SW_NORMAL)
ShowWindow(bWnd, SW_HIDE)
End Sub
Private Sub Form1_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
ShowWindow(bWnd, SW_NORMAL)
DestroyWindow(ncWnd)
End Sub
End Class
В общем, все придельно понятно! Создаем кнопку, сажаем вместо пуска... А вот как мне теперь к ней обратиться? Ну, чтобы по нажатию чего-нибудь происходило.