VERSION 5.00
Object = "{EF7B805C-D455-4D9C-AA11-46D81E364EF8}#1.0#0"; "HookControl.ocx"
Begin VB.Form F0 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Feuille fantôme!"
   ClientHeight    =   3090
   ClientLeft      =   150
   ClientTop       =   840
   ClientWidth     =   4680
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "F0.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   206
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   312
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Begin HookCtrl.HookControl HKC1 
      Left            =   2280
      Top             =   720
      _ExtentX        =   1058
      _ExtentY        =   582
   End
   Begin VB.PictureBox P0 
      AutoRedraw      =   -1  'True
      BackColor       =   &H0000FFFF&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   0
      ScaleHeight     =   17
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   17
      TabIndex        =   0
      Top             =   0
      Visible         =   0   'False
      Width           =   255
   End
   Begin VB.Menu M_Notification 
      Caption         =   "Notification"
      Begin VB.Menu M_Afficher 
         Caption         =   "&Afficher"
      End
      Begin VB.Menu M_Quitter 
         Caption         =   "&Quitter"
      End
   End
   Begin VB.Menu M_Bureau 
      Caption         =   "Bureau"
      Begin VB.Menu M_Recentrer 
         Caption         =   "&Recentrer"
      End
   End
End
Attribute VB_Name = "F0"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Private Const WM_RBUTTONUP                As Long = &H205
Private Const WM_RBUTTONCLK               As Long = &H204
Private Const WM_LBUTTONCLK               As Long = &H202
Private Const WM_LBUTTONDBLCLK            As Long = &H203
Private Const WM_MOUSEMOVE                As Long = &H200


Private Const MIM_BACKGROUND As Long = &H2
Private Const MIM_APPLYTOSUBMENUS As Long = &H80000000

Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long


Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetMenuInfo Lib "user32" (ByVal hMenu As Long, mi As MENUINFO) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long

Public Function ModSystrayRaised(shWnd, uMsg, wParam, lParam) As Long
If shWnd = Me.hwnd Then 'First we check to see if the message is for this window
        Select Case uMsg    'Then we look at the message
            Case SysTrayTaskbarCreated    'This message is for when the taskbar is created
                'if the taskbar was created, chances are explorer.exe had crashed
               SysTrayRetry
              SysTrayPopBalloon "Detected explorer.exe crash!", App.Title
            
            
            Case WM_TRAYHOOK 'Our user defined window message
                'if we get this we know that lParam carries the "event"
                'that occured on the tray icon
                
                Select Case lParam
                    Case WM_LBUTTONCLK   'Left button dbl clicked
                      '  If Me.WindowState = vbMinimized Then
                        M_Afficher_Click
                        '   Select Case wParam
                          '      Case aTrayIcons(0).Uid
                           '         ModifyTrayIcon Me, aTrayIcons(0).Uid, aTrayIcons(0).ToolTip, aTrayIcons(0).Icon
                            '        SetForegroundWindow Me.hWnd
                              '      SysTrayPopBalloon Me, aTrayIcons(0).Uid, "Program Restored.", App.Title, ICON_INFO, aTrayIcons(0).Sound, aTrayIcons(0).Icon
                             ''       Me.WindowState = vbNormal
                               '     Me.Show
                               '     Me.SetFocus
                               ' Case aTrayIcons(1).Uid
                               '     ModifyTrayIcon Me, aTrayIcons(1).Uid, aTrayIcons(1).ToolTip, aTrayIcons(1).Icon
                                '    SetForegroundWindow Me.hWnd
                                '    SysTrayPopBalloon Me, aTrayIcons(1).Uid, "Program Restored.", App.Title, ICON_INFO, aTrayIcons(1).Sound, aTrayIcons(1).Icon
                                ''    Me.WindowState = vbNormal
                                '    Me.Show
                                 '   Me.SetFocus
                               ' Case aTrayIcons(2).Uid
                               '     ModifyTrayIcon Me, aTrayIcons(2).Uid, aTrayIcons(2).ToolTip, aTrayIcons(2).Icon
                                '    SetForegroundWindow Me.hWnd
                                ''    SysTrayPopBalloon Me, aTrayIcons(2).Uid, "Program Restored.", App.Title, ICON_INFO, aTrayIcons(2).Sound, aTrayIcons(2).Icon
                                '    Me.WindowState = vbNormal
                                '    Me.Show
                                 '   Me.SetFocus
                            'End Select
                       'End If
                    
                    Case WM_RBUTTONUP   'Right button released
                        PopupMenu Me.M_Notification
                        'Select Case wParam
                         '   Case aTrayIcons(0).Uid
                         '       SetForegroundWindow Me.hWnd
                         ''       PopupMenu Me.mnuIcon1
                          '  Case aTrayIcons(1).Uid
                          ''      SetForegroundWindow Me.hWnd
                          '      PopupMenu Me.mnuIcon2
                          '  Case aTrayIcons(2).Uid
                         '       SetForegroundWindow Me.hWnd
                         '       PopupMenu Me.mnuIcon3
                        'End Select
                            
                   ' Case NIN_BALLOONUSERCLICK
                   '     AppendLog "-User clicked the balloon, with uID (" & CStr(wParam) & ")."
                   '
                   ' Case NIN_BALLOONTIMEOUT
                   '     AppendLog "-Balloon with uID (" & CStr(wParam) & "), floated away, or was dismissed."
                End Select
        End Select
    End If
    
    'also pass them to VB
    ModSystrayRaised = CallWindowProc(SysTrayHookId, shWnd, uMsg, wParam, lParam)
End Function



Private Sub M_Afficher_Click()
Interface_Afficher True
End Sub

Private Sub M_Quitter_Click()
Master_ProcFermer
End Sub

Private Sub hkc1_PostedMessage(uMsg As Long, wParam As Long, lParam As Long)

    If uMsg = WM_LBUTTONUP And wParam <> 0 Then
        Debug.Print "WM_LBUTTONUP (Posted)--->"
        Debug.Print vbTab & "Detected Click On ";

        ClickedMenu = HighlightedMenuItemID
        'Select Case HighlightedMenuItemID
        '    Case mnuBoldID:
         '       ClickedMenu = mnuBoldID
          '      Debug.Print "mnuBold"
           ' Case mnuItalicID:
           '     ClickedMenu = mnuItalicID
           '     Debug.Print "mnuItalic"
           ' Case mnuUnderlineID:
           '     ClickedMenu = mnuUnderlineID
           '     Debug.Print "mnuUnderline"
           ' Case mnuUnhookID:
           '     ClickedMenu = mnuUnhookID
           '     Debug.Print "mnuUnhook"
            
            'Case Else:
             '   Debug.Print "OTHER items"
        'End Select

        HighlightedMenuItemID = 0
    End If

End Sub
Private Sub hkc1_SentMessage(ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long)

Dim mii As MENUITEMINFO  ' describes a menu item to add

    If uMsg = WM_INITMENUPOPUP Then 'New popup menu created
        Debug.Print "----------------------" & vbNewLine & "WM_INITMENUPOPUP (Sent)--->"

        If TotalMenuInit = 0 Then
            lngMainMenuHnd = wParam
            AddMyMenu wParam
            Dim mi As MENUINFO
            With mi
                .cbSize = Len(mi)
                .fMask = MIM_BACKGROUND
                .hbrBack = CreateSolidBrush(vbYellow)

                SetMenuInfo GetMenu(Me.hwnd), mi   'main menu bar

            .fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
                .hbrBack = CreateSolidBrush(vbCyan)
            End With
 
            SetMenuInfo GetSubMenu(GetMenu(F0.hwnd), 1), mi    'this could a File menu perhaps

            DrawMenuBar F0.hwnd
 
            With mii ' Add My-Format-Menu
              .fMask = MIIM_STATE Or MIIM_TYPE Or MIIM_SUBMENU
              .fType = MFT_STRING
              .fState = MFS_ENABLED Or MF_DEFAULT
              .dwTypeData = "Bureau"
              .cch = Len(.dwTypeData)
              .HSubMenu = GetSubMenu(GetMenu(F0.hwnd), 1)
            End With

    ' Add this to the top
    retval = InsertMenuItem(wParam, 0, 1, mii)
    F0.Caption = GetLastError
           
        End If

        TotalMenuInit = TotalMenuInit + 1
        '=====================================================
    ElseIf uMsg = WM_UNINITMENUPOPUP Then ' a popup menu destroyed
        Debug.Print "----------------------" & vbNewLine & "WM_UNINITMENUPOPUP (Sent)--->"

        If wParam = lngMainMenuHnd Then
            TotalMenuInit = 0
        ElseIf TotalMenuInit > 0 Then
            TotalMenuInit = TotalMenuInit - 1
        End If

        'Debug.Print TotalMenuInit
        '=====================================================
    ElseIf uMsg = WM_MENUSELECT Then 'A menu is highlighted/de-highlighted
        Debug.Print "----------------------" & vbNewLine & "WM_MENUSELECT (Sent)--->"

        If HiWord(wParam) = &HFFFF And LoWord(wParam) = 0 Then
            Debug.Print vbTab & "Removed Highlight"
            HighlightedMenuItemID = 0
        Else
            HighlightedMenuItemID = LoWord(wParam)
            Debug.Print vbTab & "Highlighted a menu"
        End If

        '=====================================================
    ElseIf uMsg = WM_EXITMENULOOP Then
        Debug.Print "----------------------" & vbNewLine & "WM_EXITMENULOOP(Sent)--->"

        Select Case ClickedMenu 'Check if any menuitem was clicked or not
            Case 10
                ZoomIt 0, 0, 0, False
            Case 20
            Case 30
                Interface_Afficher True
            Case 10000
                Master_ProcFermer
        End Select

        HighlightedMenuItemID = 0
        ClickedMenu = 0
    End If

End Sub

Private Sub AddMyMenu(wParam As Long) 'Adds our custom menu

    Dim mii As MENUITEMINFO  ' describes a menu item to add
    Dim retval As Long       ' return value
    '-------------------------------------------------
    Dim hPopupMenu As Long
    hPopupMenu = CreatePopupMenu
    '-------------------------------------------------

    With mii
        .fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
        .fType = MFT_STRING
        .fState = MFS_ENABLED
        .dwTypeData = "Recentrer, zoom nul"
        .cch = Len(.dwTypeData)
        .wID = 10
        .cbSize = Len(mii)
    End With

    retval = InsertMenuItem(hPopupMenu, 0, 1, mii)
    '-------------------------------------------------


    With mii
        .cbSize = Len(mii)
        .fMask = MIIM_TYPE
        .wID = 0
        .fType = MFT_SEPARATOR
    End With

    retval = InsertMenuItem(hPopupMenu, 1, 1, mii)
    '=========================================================
        
    With mii
      
        .fState = MFS_ENABLED And MF_DEFAULT And MFS_CHECKED And MIIM_CHECKMARKS
        .fType = MFT_STRING
        .dwTypeData = "Couper l'image source"
        .cch = Len(.dwTypeData)
        .wID = 20
        .cbSize = Len(mii)
    End With

    retval = InsertMenuItem(hPopupMenu, 2, 1, mii)
    '-------------------------------------------------
        
        
    With mii
        .fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
        .fType = MFT_STRING
        .fState = MFS_ENABLED
        .dwTypeData = "Interface"
        .cch = Len(.dwTypeData)
        .wID = 30
        .cbSize = Len(mii)
    End With

    retval = InsertMenuItem(hPopupMenu, 3, 1, mii)
    '-------------------------------------------------
    
 

    

   ' If InIDE = -1 Then
        With mii 'Add Submenu's separetor
            .cbSize = Len(mii)
            .fMask = MIIM_TYPE
            .wID = 0
            .fType = MFT_SEPARATOR
        End With

        retval = InsertMenuItem(hPopupMenu, 4, 1, mii)
        '=========================================================


    
         With mii
            .fMask = MIIM_STATE Or MIIM_ID Or MIIM_TYPE
            .fType = MFT_STRING
            .fState = MFS_ENABLED
            .dwTypeData = "Quitter le programme" '(Seulement disponible dans VB)"
            .cch = Len(.dwTypeData)
            .wID = 10000
            .cbSize = Len(mii)
        End With

        retval = InsertMenuItem(hPopupMenu, 5, 1, mii)
        '=========================================================
    'End If


    With mii 'Main separetor
        .cbSize = Len(mii)
        .fMask = MIIM_TYPE
        .wID = 0
        .fType = MFT_SEPARATOR
    End With

    ' Add this to the top
    retval = InsertMenuItem(wParam, 0, 1, mii)
    '-------------------------------------------------

    With mii
        .fMask = MIIM_STATE Or MIIM_TYPE Or MIIM_SUBMENU
        .fType = MFT_STRING
        .fState = MFS_ENABLED Or MF_DEFAULT
        .dwTypeData = "Essai37"
        .cch = Len(.dwTypeData)
        .HSubMenu = hPopupMenu
    End With

    ' Add this to the top
    retval = InsertMenuItem(wParam, 0, 1, mii)
    '-------------------------




End Sub



Private Sub M_Recentrer_Click()
ZoomIt 0, 0, 0, False
End Sub
