dneprcomp
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Option Explicit 'defWindowProc: Variable to hold the ID of the ' default window message processing ' procedure. Returned by SetWindowLong. Public defWindowProc As Long 'isSubclassed: flag indicating that subclassing ' has been done. Provides the means ' to call the correct message-handler. Public isSubclassed As Boolean 'Activates and displays a window. 'If the window is minimized or maximized, 'the system restores it to its original size and position. 'An application should specify this flag when displaying 'the window for the first time. Public Const SW_SHOWNORMAL = 1 'Private Const SW_HIDE = 0 'Private Const SW_SHOW = 5 Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long 'Get/SetWindowLong messages Public Const GWL_WNDPROC As Long = (-4) Public Const GWL_HWNDPARENT As Long = (-8) Public Const GWL_ID As Long = (-12) Public Const GWL_STYLE As Long = (-16) Public Const GWL_EXSTYLE As Long = (-20) Public Const GWL_USERDATA As Long = (-21) 'general windows messages Public Const WM_USER As Long = &H400 Public Const WM_MYHOOK As Long = WM_USER + 1 Public Const WM_NOTIFY As Long = &H4E Public Const WM_COMMAND As Long = &H111 Public Const WM_CLOSE As Long = &H10 Public Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" _ (ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hWnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Any) As Long Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _ (ByVal lpPrevWndFunc As Long, _ ByVal hWnd As Long, _ ByVal uMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long 'our own window message procedure Public Function WindowProc(ByVal hWnd As Long, _ ByVal uMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long 'window message procedure ' 'If the handle returned is to our form, 'call a form-specific message handler to 'deal with the tray notifications. If it 'is a general system message, pass it on to 'the default window procedure. ' 'If its ours, we look at lParam for the 'message generated, and react appropriately. On Error Resume Next Select Case hWnd 'form-specific handler Case frmOrder.hWnd Select Case uMsg 'check uMsg for the application-defined 'identifier (NID.uID) assigned to the 'systray icon in NOTIFYICONDATA (NID). 'WM_MYHOOK was defined as the message sent 'as the .uCallbackMessage member of 'NOTIFYICONDATA the systray icon Case WM_MYHOOK 'lParam is the value of the message 'that generated the tray notification. Select Case lParam Case WM_RBUTTONUP: 'This assures that focus is restored to 'the form when the menu is closed. If the 'form is hidden, it (correctly) has no effect. Call SetForegroundWindow(frmOrder.hWnd) 'show the menu frmOrder.PopupMenu frmOrder.mnuPopUp Case WM_LBUTTONDBLCLK: frmOrder.mnuPopUpShow_Click End Select 'handle any other form messages by 'passing to the default message proc Case Else WindowProc = CallWindowProc(defWindowProc, _ hWnd, _ uMsg, _ wParam, _ lParam) Exit Function End Select 'this takes care of messages when the 'handle specified is not that of the form Case Else WindowProc = CallWindowProc(defWindowProc, _ hWnd, _ uMsg, _ wParam, _ lParam) End Select End Function | Всего записей: 3920 | Зарегистр. 31-03-2002 | Отправлено: 21:51 10-12-2005 | Исправлено: dneprcomp, 05:02 11-12-2005 |
|