Alaska Software Inc. - Hiding the button in the Windows Taskbar when using runshell()
Username: Password:
AuthorTopic: Hiding the button in the Windows Taskbar when using runshell()
Richard PulliamHiding the button in the Windows Taskbar when using runshell()
on Mon, 25 Jun 2007 14:24:19 -0500
Hi,

I am sure someone asked this before.  Wish I kept the solution.

How do I stop a button from appearing in the Windows Taskbar when I execute
a RunShell() ?  A button will appear even if executing with the "run in
background" switch On.....
James Loughner Re: Hiding the button in the Windows Taskbar when using runshell()
on Mon, 25 Jun 2007 15:40:16 -0400
Richard Pulliam wrote:
> Hi,
> 
> I am sure someone asked this before.  Wish I kept the solution.
> 
> How do I stop a button from appearing in the Windows Taskbar when I execute
> a RunShell() ?  A button will appear even if executing with the "run in
> background" switch On.....
> 
> 
I think

oDlg:Sysmenu := .F.

will do it.
Richard PulliamRe: Hiding the button in the Windows Taskbar when using runshell()
on Mon, 25 Jun 2007 15:17:26 -0500
Hi,

The following is a rough compilable example.


#DEFINE CRLF CHR(13)+CHR(10)

FUNCTION Main()
/*
   Procedure TEST.PRG.

   To make TEST.EXE:

   XPP TEST
   ALINK TEST /SUBSYSTEM:WINDOWS
*/

MsgBox("The program will call MS Word."+CRLF+"Make the MS Word icon in
the"+;
   CRLF+"taskbar invisible."+CRLF+CRLF+"Is it possible?")

MSWord(CURDRIVE()+":\"+CURDIR()+"\test.prg")

RETURN(NIL)

/* ========================================================================
*/
FUNCTION MSWord(cFile)
LOCAL   cWordExe:=FindMSWord(), cCommand, aInfo, cTrash:="C:\_TRASH_.TXT",;
i, nLen

IF EMPTY(cWordExe)
   FERASE(cTrash)
   cCommand:="/C DIR /B/S WINWORD.EXE > "+cTrash
   RUNSHELL(cCommand,,.F.,.T.)
   aInfo:={}
   IF FILE(cTrash) .AND. LEN(MEMOREAD(cTrash))>10  10 IS REASONABLE SIZE?
      aInfo:=File2Array(cTrash)
   ENDIF
   IF (nLen:=LEN(aInfo))>0
      FOR i:=1 TO nLen
         cFile:=ALLTRIM(aInfo[i])
         IF FILE(cFile)
            cWordExe:=cFile
            EXIT
         ENDIF
      NEXT
   ENDIF
ENDIF

IF !EMPTY(cWordExe)
   RUNSHELL(cFile, cWordExe)
ENDIF

RETURN(NIL)

/* ========================================================================
*/
FUNCTION File2Array(cFile)
LOCAL aRetVal:={}, cBuff, nPos

IF !FILE(cFile)
   RETURN(aRetVal)
ENDIF

cBuff:=MEMOREAD(cFile)
WHILE( (nPos:=AT(CRLF, cBuff))> 0 )
   AADD(aRetVal, SUBSTR(cBuff, 1, nPos-1))
   cBuff:=SUBSTR(cBuff, nPos+2)
ENDDO
AADD(aRetVal, cBuff)

RETURN(aRetVal)

/* ========================================================================
*/
STATIC FUNCTION FindMSWord()
LOCAL cRetVal:=""

IF FILE("C:\PROGRA~1\MICROS~1\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~1\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~2\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~2\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~3\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~3\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~4\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~4\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~5\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~5\OFFICE\WINWORD.EXE"
ENDIF
RETURN(cRetVal)

/* ========================================================================
*/
PROCEDURE AppSys()
RETURN

/* ========================================================================
*/




"James Loughner" <jwrl@suddenlink.net> wrote in message
news:53b9dba3$73f1df87$1bc72@news.alaska-software.com...
> Richard Pulliam wrote:
> > Hi,
> >
> > I am sure someone asked this before.  Wish I kept the solution.
> >
> > How do I stop a button from appearing in the Windows Taskbar when I
execute
> > a RunShell() ?  A button will appear even if executing with the "run in
> > background" switch On.....
> >
> >
> I think
>
> oDlg:Sysmenu := .F.
>
> will do it.
Richard PulliamRe: Hiding the button in the Windows Taskbar when using runshell()
on Mon, 25 Jun 2007 15:19:37 -0500
The following is a rough example:

#DEFINE CRLF CHR(13)+CHR(10)

FUNCTION Main()
/*
   To make TEST.EXE:

   XPP TEST
   ALINK TEST /SUBSYSTEM:WINDOWS
*/

MsgBox("The program will call MS Word."+CRLF+"Make the MS Word icon in
the"+;
   CRLF+"taskbar invisible."+CRLF+CRLF+"Is it possible?")

MSWord(CURDRIVE()+":\"+CURDIR()+"\test.prg")

RETURN(NIL)

/* ========================================================================
*/

FUNCTION MSWord(cFile)
LOCAL   cWordExe:=FindMSWord(), cCommand, aInfo, cTrash:="C:\_TRASH_.TXT",;
i, nLen

IF EMPTY(cWordExe)
   FERASE(cTrash)
   cCommand:="/C DIR /B/S WINWORD.EXE > "+cTrash
   RUNSHELL(cCommand,,.F.,.T.)
   aInfo:={}
   IF FILE(cTrash) .AND. LEN(MEMOREAD(cTrash))>10  10 IS REASONABLE SIZE?
      aInfo:=File2Array(cTrash)
   ENDIF
   IF (nLen:=LEN(aInfo))>0
      FOR i:=1 TO nLen
         cFile:=ALLTRIM(aInfo[i])
         IF FILE(cFile)
            cWordExe:=cFile
            EXIT
         ENDIF
      NEXT
   ENDIF
ENDIF

IF !EMPTY(cWordExe)
   RUNSHELL(cFile, cWordExe)
ENDIF

RETURN(NIL)

/* ========================================================================
*/


FUNCTION File2Array(cFile)
LOCAL aRetVal:={}, cBuff, nPos

IF !FILE(cFile)
   RETURN(aRetVal)
ENDIF

cBuff:=MEMOREAD(cFile)
WHILE( (nPos:=AT(CRLF, cBuff))> 0 )
   AADD(aRetVal, SUBSTR(cBuff, 1, nPos-1))
   cBuff:=SUBSTR(cBuff, nPos+2)
ENDDO
AADD(aRetVal, cBuff)

RETURN(aRetVal)

/* ========================================================================
*/
STATIC FUNCTION FindMSWord()
LOCAL cRetVal:=""

IF FILE("C:\PROGRA~1\MICROS~1\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~1\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~2\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~2\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~3\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~3\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~4\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~4\OFFICE\WINWORD.EXE"
ENDIF
IF FILE("C:\PROGRA~1\MICROS~5\OFFICE\WINWORD.EXE")
   cRetVal:="C:\PROGRA~1\MICROS~5\OFFICE\WINWORD.EXE"
ENDIF
RETURN(cRetVal)

/* ========================================================================
*/
PROCEDURE AppSys()
RETURN

/* ========================================================================
*/





"James Loughner" <jwrl@suddenlink.net> wrote in message
news:53b9dba3$73f1df87$1bc72@news.alaska-software.com...
> Richard Pulliam wrote:
> > Hi,
> >
> > I am sure someone asked this before.  Wish I kept the solution.
> >
> > How do I stop a button from appearing in the Windows Taskbar when I
execute
> > a RunShell() ?  A button will appear even if executing with the "run in
> > background" switch On.....
> >
> >
> I think
>
> oDlg:Sysmenu := .F.
>
> will do it.
Thomas Braun
Re: Hiding the button in the Windows Taskbar when using runshell()
on Tue, 26 Jun 2007 08:54:26 +0200
Richard Pulliam wrote:

> How do I stop a button from appearing in the Windows Taskbar when I execute
> a RunShell() ?

I don't think this is possible... and I can't remember having seen a
solution here (well, maybe I'm wrong 

> A button will appear even if executing with the "run in
> background" switch On.....

This only controls the focus behaviour - with "background" = .T., the
called application should not take the input focus away from the Xbase++
application and the apllications window should stay in the background...
but I doubt this works all the time, because this also can be changed by
the called application.

Thomas
Simon de BruinRe: Hiding the button in the Windows Taskbar when using runshell()
on Wed, 27 Jun 2007 15:21:27 +0200
Use a dllcall instead of RunShell.
SW_HIDE determinates the hiding.

#include "Dll.ch"

#define SW_HIDE             0
#define SW_NORMAL           1
#define SW_SHOWMINIMIZED    2
#define SW_SHOWMAXIMIZED    3
#define SW_MAXIMIZE         3
#define SW_SHOWNOACTIVATE   4
#define SW_SHOW             5
#define SW_MINIMIZE         6
#define SW_SHOWMINNOACTIVE  7
#define SW_SHOWNA           8
#define SW_RESTORE          9
#define SW_SHOWDEFAULT      10

DllCall( "SHELL32.DLL" , DLL_STDCALL, "ShellExecuteA", 
AppDesktop():GetHWND(), "open", cProgram, cCmdLine, cPath, SW_HIDE )

"Richard Pulliam" <clippersolutions@bellsouth.net> schreef in bericht 
news:77ae037d$5aa0db01$1bc4c@news.alaska-software.com...
> Hi,
>
> I am sure someone asked this before.  Wish I kept the solution.
>
> How do I stop a button from appearing in the Windows Taskbar when I 
> execute
> a RunShell() ?  A button will appear even if executing with the "run in
> background" switch On.....
>
>
Richard PulliamRe: Hiding the button in the Windows Taskbar when using runshell()
on Fri, 29 Jun 2007 18:02:11 -0500
Hi Simon,

I tried it and it is useful if you want to execute a program that is going
to end without user interface.  I tested it calling notepad and it took me a
while to figure it
was working except that I did not know it, consequently, everytime I called
it with SW_HIDE it was starting another copy of notepad.  It does not show
the
Notepad icon in the windows taskbar.  Found out I had about 20 copies
running when I pressed Ctrl-Alt-Del and looked at running processes.

Guess there is no way to execute a program with an open window and do not
show the taskbar icon.

Thanks.  May come handy in the future.

Richard






"Simon de Bruin" <info@deluca.nl> wrote in message
news:fa2f9d5$350453f6$52b69@news.alaska-software.com...
> Use a dllcall instead of RunShell.
> SW_HIDE determinates the hiding.
>
> #include "Dll.ch"
>
> #define SW_HIDE             0
> #define SW_NORMAL           1
> #define SW_SHOWMINIMIZED    2
> #define SW_SHOWMAXIMIZED    3
> #define SW_MAXIMIZE         3
> #define SW_SHOWNOACTIVATE   4
> #define SW_SHOW             5
> #define SW_MINIMIZE         6
> #define SW_SHOWMINNOACTIVE  7
> #define SW_SHOWNA           8
> #define SW_RESTORE          9
> #define SW_SHOWDEFAULT      10
>
> DllCall( "SHELL32.DLL" , DLL_STDCALL, "ShellExecuteA",
> AppDesktop():GetHWND(), "open", cProgram, cCmdLine, cPath, SW_HIDE )
>
> "Richard Pulliam" <clippersolutions@bellsouth.net> schreef in bericht
> news:77ae037d$5aa0db01$1bc4c@news.alaska-software.com...
> > Hi,
> >
> > I am sure someone asked this before.  Wish I kept the solution.
> >
> > How do I stop a button from appearing in the Windows Taskbar when I
> > execute
> > a RunShell() ?  A button will appear even if executing with the "run in
> > background" switch On.....
> >
> >
>
>