Hide and Show Application in Taskbar 
Author Message
 Hide and Show Application in Taskbar

Hello,

I am programming a software which can be hidden with the starting parameter
/hide, e.g. program.exe /hide.

I then call  App.TaskVisible = False  which hides the program from the
taskbar.

This of course means, there is no way to get to the program again.

Now, the user should be able to run a program.exe /show, which makes the
program visible again. I do not want a second instance.

How do I make the original Program show up again?

regards,
Gunter



Tue, 14 Sep 2004 09:09:21 GMT  
 Hide and Show Application in Taskbar
What you need is a method of communicating between applications

Option Explicit

' 29/07/2001  J French ISS Ltd
'
' Demonstration of communication between Apps
'
' Method: Send data from one App to Textbox
'         in another App
'
' Inspired by: Norstrom - developing Chat System
'
' Add 1 Commandbutton : cmdSend
'     1 Textbox       : txtSend
'     1 Textbox       : txtTarget
'
' NOTE:
'    txtTarget - MUST contain 'txtTarget' at design time
'
' Compile and run
'
' THIS DEMO ONLY WORKS WHEN THE APP IS COMPILED
'
' You can modify it to run
'    (slightly differently) in the IDE

Private Declare Function SendMessageStr _
        Lib "user32" _
        Alias "SendMessageA" _
        (ByVal hwnd As Long, _
         ByVal wMsg As Long, _
         ByVal wParam As Long, _
         ByVal S As String) _
        As Long

Private Declare Function FindWindowEx _
        Lib "user32" _
        Alias "FindWindowExA" _
        (ByVal hWnd1 As Long, _
         ByVal hWnd2 As Long, _
         ByVal lpsz1 As String, _
         ByVal lpsz2 As String) _
        As Long

Private Declare Function GetClassName _
        Lib "user32" _
        Alias "GetClassNameA" _
        (ByVal hwnd As Long, _
         ByVal lpClassName As String, _
         ByVal nMaxCount As Long) _
        As Long

Private Declare Function GetWindowText _
        Lib "user32" _
        Alias "GetWindowTextA" _
        (ByVal hwnd As Long, _
         ByVal lpString As String, _
         ByVal cch As Long) As Long

Private Const WM_SETTEXT = &HC

Private hTgt&

Private Sub Form_Load()
    Dim S$

    Me.Top = 0
    Me.AutoRedraw = True
    Me.Caption = "TARGET"
    cmdSend.Enabled = False
    txtSend.Enabled = False

    If App.PrevInstance Then
       Me.Caption = "SOURCE"
       Call LS_FindTarget
       cmdSend.Enabled = True
       txtSend.Enabled = True
       txtTarget.Enabled = False
       Me.Left = Screen.Width - Me.Width
    End If

    If App.PrevInstance = 0 Then
       Me.Left = 0
       S$ = App.Path
       If Right$(S$, 1) <> "\" Then
          S$ = S$ + "\"
       End If
       Shell S$ + App.EXEName, vbNormalFocus
    End If
End Sub

Private Sub cmdSend_Click()
    Static Count&
    Count = Count + 1
    LS_Send "Msg" + Str$(Count) + ":" + txtSend.Text
End Sub

' --- Locate TARGET App and Textbox
Private Sub LS_FindTarget()
    Dim hApp&

    ' --- locate Top Window with Caption "TARGET"
    hApp = FindWindowEx(0, 0, vbNullString, "TARGET")
    Me.Print "hApp:"; hApp
    Me.Print LF_ClassName(hApp); " / "; LF_WindowText(hApp)
    ' --- locate the Textbox containing 'txtTarget' at design time
    hTgt = FindWindowEx(hApp, 0, vbNullString, "txtTarget")
    Me.Print "hTgt:"; hTgt; " / "; LF_WindowText(hTgt)
    Me.Print LF_ClassName(hTgt)
End Sub

' --- actually push data to the TARGET instance
Private Sub LS_Send(S$)
    Call SendMessageStr(hTgt, WM_SETTEXT, 0, S$)
End Sub

' --- prove that we activate the TARGET App
Private Sub txtTarget_Change()
    If Me.CurrentY > Me.ScaleHeight - 250 Then Me.Cls
    Me.Print txtTarget.Text
End Sub

Private Function LF_ClassName(Hnd&) As String
    Dim Q&, S$
    S$ = Space$(100)
    ' ---
    Q = GetClassName(Hnd, S$, Len(S$))
    LF_ClassName = Left$(S$, Q)
End Function

Private Function LF_WindowText(Hnd&) As String
    Dim Q&, S$
    S$ = Space$(100)
    ' ---
    Q = GetWindowText(Hnd, S$, Len(S$))
    LF_WindowText = Left$(S$, Q)
End Function

On Fri, 29 Mar 2002 02:09:21 +0100, "Gunter Schmidt"

Quote:

>Hello,

>I am programming a software which can be hidden with the starting parameter
>/hide, e.g. program.exe /hide.

>I then call  App.TaskVisible = False  which hides the program from the
>taskbar.

>This of course means, there is no way to get to the program again.

>Now, the user should be able to run a program.exe /show, which makes the
>program visible again. I do not want a second instance.

>How do I make the original Program show up again?

>regards,
>Gunter



Tue, 14 Sep 2004 17:19:55 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Hide/Show Taskbar

2. Hide title bar and still show app name in taskbar - how

3. Hide/show Taskbar

4. Showing/Hiding running programs in the taskbar at run-time

5. Showing/Hiding running programs in the taskbar at run-time

6. How to show and hide TaskBar?

7. Showing/Hiding running programs in the taskbar at run-time

8. Hiding/Unhiding a form shown in the Taskbar

9. How hide MDI application in taskbar

10. Hide application button in taskbar

11. Hiding an application from the Task Manager and the TaskBar

12. Show In TaskBar - Changing setting between application executions

 

 
Powered by phpBB® Forum Software