Q: Shell command
I have tried to communicate my VB program with another application
using "AppActivate" and "shell function" but it gave me an error
message " *.dll not found". Why?
Private Sub Command1_Click()
Dim MyAppID, ReturnValue
MyAppID = Shell("C:\PICO\PSW32.EXE", 1)
AppActivate MyAppID
End Sub
kwsun; kwsun@tm.net.my
A:
Shel command returns a long which is not the identification of the
shelled application but only the result of the operation. So MyApplId
is zero if the shell command was succesfull. In any other case there
was a mistake.
AppActivate will bring a given application to the foreground. But you
must call it with a parameter which is the window caption of the
calles application. So when you want to call notepad (which is
already started on your system - with or without the shell command -)
you say: AppActivate "Untitled Notepad" (a empty / new notepad
document).
But using the Shell command can bring the called application to the
foreground and give it the focus without using the AppActivate
command. There are some settings you can call with this command
vbHide 0 Window is hidden and focus is passed to the hidden window.
vbNormalFocus 1 Window has focus and is restored to its original size
and position.
vbMinimizedFocus 2 Window is displayed as an icon with focus.
vbMaximizedFocus 3 Window is maximized with focus.
vbNormalNoFocus 4 Window is restored to its most recent size andposition. The
currently active window remains active.
vbMinimizedNoFocus 6 Window is displayed as an icon. The currently active window
remains active.
So if you change the code to lngResult = Shell("C:\PICO\PSW32.EXE", 3)
you will be sure that the application c:\pico\psw32.exe is maximized
and has the focus.
Return