* Opret et module * Brug den form som er der i forvejen
* Indsæt denne kode i modulet:
--------START--------- Public Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Public Const WM_RBUTTONUP = &H205 Public Const WM_LBUTTONUP = &H202 Public Const WM_LBUTTONDOWN = &H201 Public Const WM_LBUTTONDBLCLK = &H203
Global Const WM_MOUSEMOVE = &H200 Global Const NIM_ADD = 0& Global Const NIM_DELETE = 2& Global Const NIM_MODIFY = 1& Global Const NIF_ICON = 2& Global Const NIF_MESSAGE = 1& Global Const ABM_GETTASKBARPOS = &H5&
Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Type NOTIFYICONDATA cbSize As Long hwnd As Long uID As Long uFlags As Long uCallbackMessage As Long hIcon As Long szTip As String * 64 End Type
Type APPBARDATA cbSize As Long hwnd As Long uCallbackMessage As Long uEdge As Long rc As RECT lParam As Long End Type
Global Notify As NOTIFYICONDATA Global BarData As APPBARDATA
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Sub modIcon(Form1 As Form, IconID As Long, Icon As Object, ToolTip As String) Dim Result As Long Notify.cbSize = 88& Notify.hwnd = Form1.hwnd Notify.uID = IconID Notify.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP Notify.uCallbackMessage = WM_MOUSEMOVE Notify.hIcon = Icon Notify.szTip = ToolTip & Chr$(0) Result = Shell_NotifyIcon(NIM_MODIFY, Notify) End Sub
Sub AddIcon(Form1 As Form, IconID As Long, Icon As Object, ToolTip As String) Dim Result As Long BarData.cbSize = 36& Result = SHAppBarMessage(ABM_GETTASKBARPOS, BarData) Notify.cbSize = 88& Notify.hwnd = Form1.hwnd Notify.uID = IconID Notify.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP Notify.uCallbackMessage = WM_MOUSEMOVE Notify.hIcon = Icon Notify.szTip = ToolTip & Chr$(0) Result = Shell_NotifyIcon(NIM_ADD, Notify) End Sub
Sub delIcon(IconID As Long) Dim Result As Long Notify.uID = IconID Result = Shell_NotifyIcon(NIM_DELETE, Notify) End Sub
----------SLUT----------
* Opret en menu fra menue ditor * Lav understående punkter
---Punkt1 :: Navn "p1" ---Punkt2 :: Navn "p2" ---Minimere :: Navn "Close"
* Dobbeltklik på formen * Vælg generel * Kopier denne kode ind i generel
------START-------- Option Explicit Public Counter As Integer Public IconObject As Object
Private Sub Close_Click() Form1.Hide Set IconObject = Form1.Icon AddIcon Form1, IconObject.Handle, IconObject, "Tray" End Sub
Private Sub Form_Resize() If Form1.WindowState = 1 Then Me.Hide End Sub
Private Sub Form_Unload(Cancel As Integer) delIcon IconObject.Handle delIcon Form1.Icon.Handle End Sub
Private Sub Form_Load() Form1.Hide Set IconObject = Form1.Icon AddIcon Form1, IconObject.Handle, IconObject, "Tray" End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Static Message As Long Message = X / Screen.TwipsPerPixelX Select Case Message Case WM_RBUTTONUP: 'Hvis der bliver højre klikket: Me.PopupMenu Pop Case WM_LBUTTONUP: 'Hvis der bliver venstre klikket: Form1.WindowState = 0 Form1.Show Form1.SetFocus End Select End Sub
Private Sub p1_Click() MsgBox Me.p1.Caption End Sub Private Sub p2_Click() MsgBox Me.p2.Caption End Sub
Private Sub Timer1_Timer() Label1.Caption = Val(Label1.Caption) + 1
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.