CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    form hide and unhide the form using rightclick shortcut

    Hi all,
    I have written a code for sound application.Functionalitywise it works perfectely.But i want to hide a form, that is easy,but i want that form to unhide using a rightclick menu(own custumized menu of application itself).I have tried it for system icon . created rightclick popup menu.it hides form.but how can i unhide that frm once it is hide.
    actualy i want rigth click menu item that unhide the form..is there any idea pls.?

  2. #2
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: form hide and unhide the form using rightclick shortcut

    Can you show us your code for system tray icon? Cheers... It should be easy.
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

  3. #3
    Join Date
    Dec 2006
    Location
    Pune, India.
    Posts
    579

    Re: form hide and unhide the form using rightclick shortcut

    Use :
    Code:
    Form.Show

  4. #4
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Re: form hide and unhide the form using rightclick shortcut

    it is not the case.once form is hide form.show will not work except we use any rightclick popuup menu or any desktop shortcut. So i want shortcut or rightclick menu only.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: form hide and unhide the form using rightclick shortcut

    Try this:
    Code:
    Option Explicit
    
    'User-defined variable to pass to the Shell_NotiyIcon function
    Private 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
    
    'Constants for the Shell_NotifyIcon function
    Private Const NIM_ADD = &H0
    Private Const NIM_MODIFY = &H1
    Private Const NIM_DELETE = &H2
    
    Private Const WM_MOUSEMOVE = &H200
    
    Private Const NIF_MESSAGE = &H1
    Private Const NIF_ICON = &H2
    Private Const NIF_TIP = &H4
    
    Private Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_LBUTTONUP = &H202
    Private Const WM_RBUTTONDBLCLK = &H206
    Private Const WM_RBUTTONDOWN = &H204
    Private Const WM_RBUTTONUP = &H205
    
    'Declare the API function call
    Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" _
        (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
        
    Dim nid As NOTIFYICONDATA
    
    Public Sub AddIcon(ByVal ToolTip As String)
    
        On Error GoTo ErrorHandler
        
        'Add icon to system tray
        With nid
            .cbSize = Len(nid)
            .hWnd = Me.hWnd
            .uId = vbNull
            .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
            .uCallBackMessage = WM_MOUSEMOVE
            .hIcon = Me.Icon
            .szTip = ToolTip & vbNullChar
        End With
        Call Shell_NotifyIcon(NIM_ADD, nid)
        
    Exit Sub
    ErrorHandler:   'Display error message
        Screen.MousePointer = vbDefault
        MsgBox Err.Description, vbInformation, App.ProductName & " - " & Me.Caption
    
    End Sub
    
    Private Sub Form_Load()
    
        Call AddIcon("This would be a tooltip...")
        
    End Sub
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    Dim msg             As Long
    
        On Error GoTo ErrorHandler
        
        'Respond to user interaction
        msg = X / Screen.TwipsPerPixelX
        Select Case msg
                
            Case WM_LBUTTONDBLCLK
                'nothing
        
            Case WM_LBUTTONDOWN
                'nothing
            
            Case WM_LBUTTONUP
                If Me.WindowState = vbMinimized Then
                    Me.WindowState = vbNormal
                    Me.Show
                Else
                    Me.WindowState = vbMinimized
                    Me.Hide
                End If
                
            Case WM_RBUTTONDBLCLK
                'nothing
            
            Case WM_RBUTTONDOWN
                'nothing
            
            Case WM_RBUTTONUP
                Call PopupMenu(mnuFile, vbPopupMenuRightAlign)
                
        End Select
        
    Exit Sub
    ErrorHandler:   'Display error message
        Screen.MousePointer = vbDefault
        MsgBox Err.Description, vbInformation, App.ProductName & " - " & Me.Caption
    
    End Sub
    
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    
        'Remove icon from system tray
        Call Shell_NotifyIcon(NIM_DELETE, nid)
    
    End Sub
    
    Private Sub mnuFileArray_Click(Index As Integer)
    
        Select Case Index
            Case 0  'Option 1
                MsgBox "You've clicked on option1 - good for you!", _
                       vbInformation, App.ProductName & Me.Caption
                       
            Case 1  'Option 2
                MsgBox "You've clicked on option2 - great!", _
                       vbInformation, App.ProductName & Me.Caption
                       
            Case 4  'Option 1
                Unload Me
                End
        
        End Select
        
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Re: form hide and unhide the form using rightclick shortcut

    tx for the code,
    actualy i had already a code of such type, in which we can hide a form.but in above code a icon will remain displayed in systray in right bottom corner of taskbar.I want to hide everythig i.e form and/or systray icon.in simple word i want a code just like ,as we press 'ctrl+alt+del' to display a "windows task manager".
    Last edited by mynick; April 23rd, 2008 at 10:12 AM.

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: form hide and unhide the form using rightclick shortcut

    That would be a system service. Why would you want to hide your form from the user? And don't say it's some kind of security. We get those about 6 time per semester...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Re: form hide and unhide the form using rightclick shortcut

    I want to run an application in stealth mode.
    in other words ,if any idea through which we can use a keybord key combination to invoke an application or process which is already runing behind..

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: form hide and unhide the form using rightclick shortcut

    What is stealth mode? I want to know what's running on my computer. It sounds like you want to do something that the user would want to do. Again, I ask, what are you doing?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Re: form hide and unhide the form using rightclick shortcut

    i just want a code(keyboard shortcut )by which i can display(or unhide) a form(application), just like in case "ctrl+alt+del" to show "task manager"

  11. #11
    Join Date
    Apr 2008
    Location
    Philippines, Manila
    Posts
    19

    Re: form hide and unhide the form using rightclick shortcut

    my nick, u can hide forms when having two forms at a a time. hiding forms, simply code:

    Private_Sub Form1_Click()
    form1.hide
    form2.show

    otherwise

    Private Sub Form1_Click()
    form1.hide
    form2.show

    or you can place a button in your form named "Back"

    Private Sub Command1_Click()
    form1.hide

    ^_^

    dont make it complicated
    make it simple...

  12. #12
    Join Date
    Apr 2008
    Location
    Philippines, Manila
    Posts
    19

    Talking Re: form hide and unhide the form using rightclick shortcut

    Mynick, if you want a fastkey terminator try this

    if u have a cmdbutton

    You should name it for example "&Procede" or "_Procede" or "*Procede"

    just try one of these and after running the program you press "ALT P" to terminate try it

  13. #13
    Join Date
    Apr 2008
    Location
    Philippines, Manila
    Posts
    19

    Re: form hide and unhide the form using rightclick shortcut

    For the programming Master:

    Can you please tell me how to make a WEBSITE using VB 6.0??

    Whats the difference between an open source and not open source prog'mng language???

  14. #14
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: form hide and unhide the form using rightclick shortcut

    mynick, I get the impression that you are looking for a global mouse hook, I'm almost 100% convinced that that is the case.
    If that's the case, it is absolutely ridiculous to have total control over the user's mouse - think about all the other applications on the system, that still need to function as they are intended to.
    Rather concider a global keyboard hook instead.

  15. #15
    Join Date
    Jun 2005
    Location
    gandhinagar,gujarat
    Posts
    51

    Re: form hide and unhide the form using rightclick shortcut

    still i could not get solution.

Page 1 of 2 12 LastLast

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

Featured