How could I get the used 530kb memory back?
Code: Select all
#include once "windows.bi"
#include once "win\shellapi.bi"
#include once "win\tlhelp32.bi"
Declare Function WinMain ( Byval hInstance As HINSTANCE, Byval hPrevInstance As HINSTANCE,szCmdLine As String, Byval iCmdShow As Integer ) As Integer
Const WM_SHELLNOTIFY = WM_USER + 5
Const ID_EXIT =1, ID_NONE =2, ID_FREE=3
Dim Shared iTray As NOTIFYICONDATA
Dim Shared mTray As HANDLE
Dim Shared szAppName As String
Dim Shared TB_CREATED As Integer
Dim Shared MainMenu As HANDLE
End WinMain( GetModuleHandle( null ), null, Command$, SW_NORMAL )
Function WndProc ( Byval hWnd As HWND, Byval message As UINT, Byval wParam As WPARAM, _
Byval lParam As LPARAM ) As LRESULT
Static pt As Point
Function = 0
Select Case (message)
Case WM_CREATE
TB_CREATED = RegisterWindowMessage ("TaskbarCreated")
Exit Function
Case WM_DESTROY
UnregisterClass (szAppName, GetModuleHandle( null ))
Shell_NotifyIcon (NIM_DELETE, @iTray)
PostQuitMessage( 0 )
Exit Function
Case WM_COMMAND
Select Case LOWORD (wParam)
Case ID_EXIT
DestroyWindow (hWnd)
Case ID_NONE
'
Case ID_FREE
'
End Select
Case WM_CREATE
TB_CREATED = RegisterWindowMessage ("TaskbarCreated")
Case WM_SHELLNOTIFY
If lParam = WM_RBUTTONDOWN Then
mTray = CreateMenu ()
MainMenu = CreateMenu ()
InsertMenu (MainMenu, 0, MF_POPUP, mTray, "invisible menu")
InsertMenu (mTray, 0, MF_SEPARATOR, -1, "")
InsertMenu (mTray, 1, MF_STRING, ID_EXIT, "E&xit")
GetCursorPos (@pt)
SetForegroundWindow (hWnd)
TrackPopupMenuEx (mTray, TPM_LEFTALIGN Or TPM_RIGHTBUTTON, pt.x, pt.y, hWnd, NULL)
PostMessage (hWnd, WM_NULL, 0, 0)
DestroyMenu (MainMenu)
EndIf
Case TB_CREATED
Shell_NotifyIcon (NIM_ADD, @iTray)
End Select
Function = DefWindowProc( hWnd, message, wParam, lParam )
End Function
Function WinMain ( Byval hInstance As HINSTANCE, _
Byval hPrevInstance As HINSTANCE, _
szCmdLine As String, _
Byval iCmdShow As Integer ) As Integer
Dim wMsg As MSG
Dim wcls As WNDCLASS
Dim hWnd As HWND
Function = 0
szAppName = "Auto Servicer"
hWnd=FindWindow(szAppName,NULL)
If hWnd <> 0 Then
SetForegroundWindow(hWnd)
Exit Function
End If
With wcls
.style = CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra = 0
.cbWndExtra = 0
.hInstance = hInstance
.hIcon = LoadIcon( NULL, IDI_APPLICATION )
.hCursor = LoadCursor( NULL, IDC_ARROW )
.hbrBackground = GetStockObject( WHITE_BRUSH )
.lpszMenuName = NULL
.lpszClassName = Strptr( szAppName )
End With
If( RegisterClass( @wcls ) = FALSE ) Then
MessageBox( null, "This program requires Windows NT!", szAppName, MB_ICONERROR )
Exit Function
End If
'' Create the window and _BUT DONT_ show it
hWnd = CreateWindowEx( 0, szAppName, "", _
0, _
0, 0, 0, 0, _
NULL, NULL, _
hInstance, _
NULL )
'Create Tray
iTray.cbSize = sizeof (NOTIFYICONDATA)
iTray.hWnd = hWnd
'iTray.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (CLOCKICON))
iTray.uFlags = NIF_TIP Or NIF_ICON Or NIF_MESSAGE Or NIF_INFO Or NIF_STATE
iTray.uCallbackMessage = WM_SHELLNOTIFY
iTray.szTip= szAppName
Shell_NotifyIcon (NIM_ADD, @iTray)
While( GetMessage( @wMsg, NULL, 0, 0 ) <> FALSE )
TranslateMessage( @wMsg )
DispatchMessage( @wMsg )
Wend
Function = wMsg.wParam
End Function