Results 1 to 3 of 3

Thread: minimize MDI form to systray

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638

    minimize MDI form to systray

    right, this is driving me up the wall! i found some code to minimize my MDI form to the systray, and then allows the user to either double-click the icon to restore the window, or right-click it to get a menu that allows them to restore or exit.

    this all works fine in the IDE, but when it's compiled, it doesn't react to any mouse clicks on the icon, so i can't restore the window.

    the thing that's making me drive further up the wall is the fact that the sample program that i got the code from works fine in the IDE and when compiled (it's also an MDI project, and i just copy/pasted the code).

    this is the code that it seems to have trouble with:

    VB Code:
    1. Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, _
    2. x As Single, Y As Single)
    3.     If (Me.ScaleWidth = vbPixels) Then
    4.         lngMsg = x
    5.     Else
    6.         lngMsg = x / Screen.TwipsPerPixelX
    7.     End If
    8.    
    9.     Select Case lngMsg
    10.         Case WM_LBUTTONDBLCLK    '515: Restore form window
    11.             Me.WindowState = vbMaximized
    12.             lngResult = SetForegroundWindow(Me.hwnd)
    13.             Shell_NotifyIcon NIM_DELETE, nid
    14.             Me.Show
    15.         Case WM_RBUTTONUP        '517: Display popup menu
    16.             lngResult = SetForegroundWindow(Me.hwnd)
    17.             Me.PopupMenu mnuSystray
    18.     End Select
    19. End Sub

    any ideas why this isn't working? thanks.
    Last edited by tr0n; Sep 17th, 2002 at 06:19 AM.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    i've just realised that when the program is minimized in the systray, the MouseMove event isn't even being called.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    well it looks like no-one can help, but is it me or is this code pretty crap anyway? it seems to be the method of almost every example i've seen, but i've found that if i move my mouse to certain points on the screen, the popumenu appears, or the windowstate changes (because of what's going on in the MouseMove event).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width