For Programmers: Free Programming Magazines  


Home > Archive > Clipper > September 2005 > Starting up a xHarbour app ??









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Starting up a xHarbour app ??
Mel Smith

2005-08-30, 9:55 pm

Dear Friends,

As a demo for a client, I wish to start up (from inside an existing
Clipper app), an xHarbour app (gui-based).

I will be using Blinker's swpruncmd() to start up the xHarbour app, but
am having difficulty *returning* to my Clipper app after exiting the
xHarbour app.

Does anyone have any advice on using the 'Start' command with the proper
options (I used Start /w but still ended up on the Desktop and had to click
the taskbar icon to return to my Clipper app). I wish this demo to work on
Win98SE, Win2k, and on WinXP machines

My partially successful call on win98se is like this:

swpruncmd("start /w myapp.exe",0,"","")

... on a WinXP machine the xHarbour app doesn't even 'start' (there's a
'flicker' but no Joy !) :((

I would appreciate any further advice.

TIA,

-Mel Smith


Ron Pinkas

2005-08-31, 3:55 am

Hi Mel,

> As a demo for a client, I wish to start up (from inside an existing
> Clipper app), an xHarbour app (gui-based).
>
> I will be using Blinker's swpruncmd() to start up the xHarbour app, but
> am having difficulty *returning* to my Clipper app after exiting the
> xHarbour app.
>
> Does anyone have any advice on using the 'Start' command with the
> proper options (I used Start /w but still ended up on the Desktop and had
> to click the taskbar icon to return to my Clipper app). I wish this demo
> to work on Win98SE, Win2k, and on WinXP machines
>
> My partially successful call on win98se is like this:
>
> swpruncmd("start /w myapp.exe",0,"","")
>
> ... on a WinXP machine the xHarbour app doesn't even 'start' (there's a
> 'flicker' but no Joy !) :((
>
> I would appreciate any further advice.


//--------------------------------------------//
PROCEDURE Main()

__Run( "command.com /c xBuildW.exe" )
Alert( "Done" )

RETURN
//--------------------------------------------//

Ron


Mel Smith

2005-08-31, 6:55 pm

Ron said:

> //--------------------------------------------//
> PROCEDURE Main()
>
> __Run( "command.com /c xBuildW.exe" )
> Alert( "Done" )
>
> RETURN
> //--------------------------------------------//


Ron,

Perhaps you misunderstood me (or I wasn't clear on my problem) ?? I
wish to start the xHB app from within my Clipper app using the Blinker
swpruncmd(...) function. This works (mostly), except the when exiting the
xHB app to return to Clipper app, I don't *quite* get back to my Clipper
app. It stays on the taskbar 'waiting to be clicked' :)))


Thanks for the repsonse.

-Mel


Mel Smith

2005-08-31, 6:55 pm

Ron said:

> //--------------------------------------------//
> PROCEDURE Main()
>
> __Run( "command.com /c xBuildW.exe" )
> Alert( "Done" )
>
> RETURN
> //--------------------------------------------//


Ron,

Perhaps you misunderstood me (or I wasn't clear on my problem) ?? I
wish to start the xHB app from within my Clipper app using the Blinker
swpruncmd(...) function. This works (mostly), except the when exiting the
xHB app to return to Clipper app, I don't *quite* get back to my Clipper
app. It stays on the taskbar 'waiting to be clicked' :)))


Thanks for the repsonse.

-Mel


Paul Tucker

2005-08-31, 6:55 pm

Mel,

Are you running as a window, or full screen?

Starting any Windows app and having it give focus back to the Dos app on
exit is more of a generic Windows issue than xHarbour. I don't have any
reference here to look up , but you'll need to find the handle of the
console the vdm is running in and try setting focus to it

Paul

"Mel Smith" <medsyntel@aol.com> wrote in message
news:3nlt7hF265ltU1@individual.net...
> Ron said:
>
>
> Ron,
>
> Perhaps you misunderstood me (or I wasn't clear on my problem) ?? I
> wish to start the xHB app from within my Clipper app using the Blinker
> swpruncmd(...) function. This works (mostly), except the when exiting the
> xHB app to return to Clipper app, I don't *quite* get back to my Clipper
> app. It stays on the taskbar 'waiting to be clicked' :)))
>
>
> Thanks for the repsonse.
>
> -Mel
>
>



Ron Pinkas

2005-08-31, 6:55 pm

Mel,

> Perhaps you misunderstood me (or I wasn't clear on my problem) ?? I
> wish to start the xHB app from within my Clipper app using the Blinker
> swpruncmd(...) function. This works (mostly), except the when exiting the
> xHB app to return to Clipper app, I don't *quite* get back to my Clipper
> app. It stays on the taskbar 'waiting to be clicked' :)))


I believe I did understand, your problem, and did propose a WORKING and
TESTED solution. Did you bother to review it? In my tests using __Run() vs.
swpruncmd(), did NOT make any difference. The essence of the solution is the
"command.com /c" prefix, to the EXE name.

Here is a tested, working, sample:

//-------------------------------------------------//
PROCEDURE Main()

swpruncmd( "command.com /c <YourAppNameHere>.exe" )
Alert( "Done" )

RETURN
//-------------------------------------------------//

Ron


Markus Wiederstein

2005-08-31, 6:55 pm

Hi Paul,

nice to see you around ;-)

Mel,

it's quite simple with a Tool called Autohotkey

http://www.autohotkey.com/

Example:
Activating and manipulating windows

To activate a window (make it foremost), use WinActivate. To detect
whether a window exists, use IfWinExist or WinWait. The following example
illustrates these commands:

IfWinExist, MyClipperApp
{
WinActivate
}
else
{
Run, MyClipperApp
WinWait, MyClipperApp
WinActivate
}

The above example first searches for any existing window whose title
starts with "MyClipperApp" (case sensitive). If such a window is found, it
is activated. Otherwise, MyClipperApp is launched and the script waits for
the MyClipperApp window to appear, at which time it is activated. The
above example also utilizes the last found window to avoid the need to
specify the window's title with each WinActivate.

Some of the other commonly used window commands are:
IfWinActive: Checks if the specified window is currently active.
WinWaitActive: Waits for the specified window to become active (typically
used immediately after a Run command).
WinClose: Closes the specified window.
WinMove: Moves or resizes the specified window.
WinMinimize, WinMaximize, WinRestore: Minimizes, maximizes, or restores
the specified window, respectively.

Markus


Am Wed, 31 Aug 2005 16:46:53 +0200 hat Paul Tucker <paul@richsoftware.com>
geschrieben:

> Mel,
>
> Are you running as a window, or full screen?
>
> Starting any Windows app and having it give focus back to the Dos app on
> exit is more of a generic Windows issue than xHarbour. I don't have any
> reference here to look up , but you'll need to find the handle of the
> console the vdm is running in and try setting focus to it
>
> Paul
>
> "Mel Smith" <medsyntel@aol.com> wrote in message
> news:3nlt7hF265ltU1@individual.net...
>
>




--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
Mel Smith

2005-08-31, 9:55 pm

Ron,

O.K., I'll go over your solution again tomorrow (and see if I can make
it work)

(and yes, I *did* look at your solution but put it aside because I
thought you had misinterpreted my question -- Sorry !)

Thank you !

-Mel


Mel Smith

2005-08-31, 9:55 pm

Paul,

I'm running the Clipper app as purely a DOS console app (no Window), and
the xHarbour app as a Minigui Windows app.

Also, I'm testing on both a Win98SE machine (which does not return to my
DOS app (it needs a 'click' on the taskbar to return), and on a WinXP Home
machine which 'flickers' but doesn't even start up the Windows xHarbours
app.

Thanks.

-Mel

"Paul Tucker" <paul@richsoftware.com> wrote in message
news:xpjRe.3274$884.566995@news20.bellglobal.com...
> Mel,
>
> Are you running as a window, or full screen?
>
> Starting any Windows app and having it give focus back to the Dos app on
> exit is more of a generic Windows issue than xHarbour. I don't have any
> reference here to look up , but you'll need to find the handle of the
> console the vdm is running in and try setting focus to it
>
> Paul
>
> "Mel Smith" <medsyntel@aol.com> wrote in message
> news:3nlt7hF265ltU1@individual.net...
>
>



Mel Smith

2005-08-31, 9:55 pm

Markus,

Thanks for the link to autohotkey. I'll look at that tomorrow.

-Mel


Paul Tucker

2005-09-01, 6:55 pm

Hello Markus,

> Hi Paul,
>
> nice to see you around ;-)



Likewise. It's been.... many harvests!

Paul


Paul Tucker

2005-09-01, 6:55 pm

Mel,

One solution that can cause what you describe under XP is if there is a path
involved in what you're trying to run, and it may contain spaces.
Otherwise, my blinker commands details are pretty rusty - is there a way to
determine the error code or return result of swpruncommand?

If none of the other solutions pan out - I _might_ have something you can
try - (after I try it myself)

Paul

"Mel Smith" <medsyntel@aol.com> wrote in message
news:3nn305F2cdviU1@individual.net...[color=darkred]
> Paul,
>
> I'm running the Clipper app as purely a DOS console app (no Window),
> and the xHarbour app as a Minigui Windows app.
>
> Also, I'm testing on both a Win98SE machine (which does not return to
> my DOS app (it needs a 'click' on the taskbar to return), and on a WinXP
> Home machine which 'flickers' but doesn't even start up the Windows
> xHarbours app.
>
> Thanks.
>
> -Mel
>
> "Paul Tucker" <paul@richsoftware.com> wrote in message
> news:xpjRe.3274$884.566995@news20.bellglobal.com...


Markus Wiederstein

2005-09-01, 6:55 pm

Paul,

i think Mel has not really an ERROR, it's simply a 2k/xp behavior.

If you run a Win GUI app from within a clipper app (fullscreen), the
focus doesn't return back to the dos app.

On the desktop you'd have to click the taskbar icon of the dos session
to get back from where you started.

That's why i told mel to take a look at autohotkey.com, you can write a
simple
script that would give the focus back to the dos session after finishing
the
win gui task.

regards,
Markus



Am Thu, 01 Sep 2005 15:49:18 +0200 hat Paul Tucker <paul@richsoftware.com>
geschrieben:

> Mel,
>
> One solution that can cause what you describe under XP is if there is a
> path
> involved in what you're trying to run, and it may contain spaces.
> Otherwise, my blinker commands details are pretty rusty - is there a way
> to
> determine the error code or return result of swpruncommand?
>
> If none of the other solutions pan out - I _might_ have something you can
> try - (after I try it myself)
>
> Paul
>
> "Mel Smith" <medsyntel@aol.com> wrote in message
> news:3nn305F2cdviU1@individual.net...
>
>




--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
Detlef Hoefner

2005-09-01, 6:55 pm

"Markus Wiederstein" <markus.wiederstein@web.de> wrote
> Paul,
>
> i think Mel has not really an ERROR, it's simply a 2k/xp behavior.


Hi Mel,

i'm glad to read that you really don't have an error!
( couldn't resist to write this ;- )

Best regards,
Detlef


Mel Smith

2005-09-01, 6:55 pm

Paul said:

"> One solution that can cause what you describe under XP is if there is a
path
> involved in what you're trying to run, and it may contain spaces.
> Otherwise, my blinker commands details are pretty rusty - is there a way

to
> determine the error code or return result of swpruncommand?


Paul:
Here is the actual code I'm testing on a win98se machine (the path is
actually and exactly where the Clipper app is executing). Note that I had
Ron Pinkas' 'RUN' command also under test. When *it* ran it started my test
windows browser but barely got the window open and all controls were
disabled (so I reverted to the swpruncmd() function):

IF FILE("C:\ACT\PCHBROW.EXE") // THIS IS A TEST WINDOW FUNCTION -- SO
TRY IT OUT
SWPRUNCMD("START /wait C:\ACT\PCHBROW.EXE",0,"","")
//__RUN("command.com /c C:\ACT\PCHBROW.EXE")
ENDIF


Yes, there are the major error and minor error codes that swpruncmd()
returns, and I can test them later. I'm very familiar with the swpruncmd(),
and use it constantly. Will do that test later (or over the wend) -- This
particular task is on 'spec' and I'm not being paid for it and I do have
several other 'paid' tasks to perform. So, I'll tend to 'money-making' for
a bit first. Thanks for the offer.

-Mel



Mel Smith

2005-09-01, 6:55 pm

Markus said:
>
> If you run a Win GUI app from within a clipper app (fullscreen), the
> focus doesn't return back to the dos app.
>
> On the desktop you'd have to click the taskbar icon of the dos session
> to get back from where you started.


Markus,

Thanks for confirming my impression.

I have downloaded the whole autohotkey bundle, and am just starting to
look at it.

(However, as a first impression, it looks like I have to include
autokey.exe with all my systems ???)

Thanks again,

-Mel Smith


Mel Smith

2005-09-01, 6:55 pm

Detlef said:
>
> i'm glad to read that you really don't have an error!
> ( couldn't resist to write this ;- )


Detlef:

I am usually 'awash' in a sea of errors, but this time it is probably a
small puddle of misunderstanding.

-Mel


Paul Tucker

2005-09-01, 6:55 pm

Markus,

>
> i think Mel has not really an ERROR, it's simply a 2k/xp behavior.


Understood. I might have a solution, but it too would involve a separate
program.

Paul


Paul Tucker

2005-09-01, 6:55 pm

Mel,
> Here is the actual code I'm testing on a win98se machine (the path is
> actually and exactly where the Clipper app is executing). Note that I had
> Ron Pinkas' 'RUN' command also under test. When *it* ran it started my
> test
> windows browser but barely got the window open and all controls were
> disabled (so I reverted to the swpruncmd() function):


Ok - well that should not have happened, and should have nothing to do with
the 'method' of invoking the app. Try it again, using swpruncmd instead of
run - but with the command.com line (or try cmd.exe /c/d on xp)

Check those error valuse when you can. The only other thing off the top of
my head is to ask whether 'temp' points to a valid path on both machines.

>
> IF FILE("C:\ACT\PCHBROW.EXE") // THIS IS A TEST WINDOW FUNCTION -- SO
> TRY IT OUT
> SWPRUNCMD("START /wait C:\ACT\PCHBROW.EXE",0,"","")
> //__RUN("command.com /c C:\ACT\PCHBROW.EXE")
> ENDIF
>
>
> Yes, there are the major error and minor error codes that swpruncmd()
> returns, and I can test them later. I'm very familiar with the
> swpruncmd(),
> and use it constantly. Will do that test later (or over the wend) --
> This
> particular task is on 'spec' and I'm not being paid for it and I do have
> several other 'paid' tasks to perform. So, I'll tend to 'money-making'
> for
> a bit first. Thanks for the offer.
>
> -Mel



Detlef Hoefner

2005-09-01, 6:55 pm

Sorry Mel,

i didn' t explain my recent comment.

If in German you say that someone has an error,
it could mean this person might be a little chuckleheaded.

So i was happy to read that you don't have an error ;- )

Hope you don't mind my comment.
It was meant as a gag not related to any Clipper/xHarbour topic.

Best regards,
Detlef




Markus Wiederstein

2005-09-01, 6:55 pm

Am Thu, 01 Sep 2005 19:10:29 +0200 hat Mel Smith <medsyntel@aol.com>
geschrieben:
[color=darkred]
>
> I have downloaded the whole autohotkey bundle, and am just starting to >
> look at it.
>
> (However, as a first impression, it looks like I have to include
> autokey.exe with all my systems ???)

No, you simply create a script and then you can compile it to a
self-contained exe.

Should work like this:

1. Clipper program calls Autohotkey-compiled-exe (ACE)
2. ACE performs the following tasks:
- start the windows program
- wait until win app is finished
- give focus back to the dos program
- exit
3. Clipper app alive agin

Markus
AUGE_OHR

2005-09-01, 6:55 pm

hi,

> xHB app to return to Clipper app, I don't *quite* get back to my Clipper
> app. It stays on the taskbar 'waiting to be clicked' :)))


so why don´t you make your xHB App to "focus" your Cl*pper App and
"BringWindowToTop" before return ?

following Source is Xbase++ ... (ask Ron for help translating it to xHB)
it scan the Windows-Tasklist

greetings by OHR
Jimmy

*** snip ***
*PROCEDURE AppSys
* LOCAL oDlg, oXbp
*
* // Check if a copy is already running
* IF ChkPrevApp( "MyApp" )
* QUIT
* ENDIF
* ...
*RETURN

#include "DLL.ch"
#define GW_HWNDFIRST 0
#define GW_HWNDLAST 1
#define GW_HWNDNEXT 2
#define GW_HWNDPREV 3
#define GW_OWNER 4
#define GW_CHILD 5
#define GW_MAX 5
/*
* ShowWindow() Commands, from WINUSER.H
*/
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#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
#define SW_MAX 10

DLLFUNCTION ShowWindow( nHwnd, nCmdShow ) USING STDCALL FROM
USER32.DLL
DLLFUNCTION BringWindowToTop( nHwnd ) USING STDCALL FROM
USER32.DLL
DLLFUNCTION SetForegroundWindow( nHwnd ) USING STDCALL FROM
USER32.DLL

****************************************
************************************
***
FUNCTION ChkPrevApp( cNaam )
****************************************
************************************
***
LOCAL nEvent, mp1, mp2
LOCAL oDlg
local aTasklist
local aSize := {0,0}
local aPos := {0,0}
LOCAL lRunnin := .F.
LOCAL i
LOCAL nHwnd
oDlg := XbpDialog():new( AppDesktop(), , aPos, aSize, , .F.)
oDlg:clipSiblings := .T.
oDlg:drawingArea:ClipChildren := .T.
oDlg:create()
setappfocus(oDlg)
aTasklist := GetTaskList( oDlg:gethWnd( ) )
For i = 1 to Len( aTasklist )
cWind := TRIM( UPPER( Substr( aTasklist[i], 9 ) ) )
cWind := Substr( cWind, 1, Len( cWind ) - 1 )
If cWind == Trim( Upper( cNaam ) )
lRunnin := .T.
nHwnd := Val( Left( aTasklist[i], 8 ) )
ShowWindow( nHwnd, SW_RESTORE )
BringWindowToTop( nHwnd )
SetForegroundWindow( nHwnd )

Return lRunnin
EndIf
Next
Return lRunnin

****************************************
************************************
***
FUNCTION gettasklist( hWnd )
****************************************
************************************
***
local aList:={}
local cWindowName
local nVisible
while hWnd != 0
cWindowname := space(100)
if ( getwindowtexta( hWnd, @cWindowName, len( cWindowName ) ) <> 0 )
nVisible := IsWindowVisible(hWnd)
if nVisible == 1
aadd( aList, Str( hWnd, 8 ) + cWindowname )
endif
endif
hWnd = GetWindow( hWnd, GW_HWNDNEXT )
end
return aList

****************************************
************************************
***
FUNCTION GetWindow( hWnd, uCmd )
****************************************
************************************
***
LOCAL nDll:=DllLoad("USER32.DLL")
LOCAL xRet:=DllCall(nDll,DLL_STDCALL,"GetWindow", hWnd,uCmd)
DllUnLoad(nDll)
RETURN xRet

****************************************
************************************
***
FUNCTION GetWindowTextA( hWnd, lPstring, nMax )
****************************************
************************************
***
LOCAL nDll:=DllLoad("USER32.DLL")
LOCAL xRet:=DllCall( nDll, DLL_STDCALL, "GetWindowTextA", hWnd, @lPstring,
nMax )
DllUnLoad(nDll)
RETURN xRet

****************************************
************************************
***
FUNCTION IsWindowVisible( hWnd)
****************************************
************************************
***
LOCAL nDll:=DllLoad("USER32.DLL")
LOCAL xRet:=DllCall(nDll,DLL_STDCALL,"IsWindowVisible", hWnd)
DllUnLoad(nDll)
RETURN xRet

*** eof ***


Ron Pinkas

2005-09-01, 6:55 pm

> O.K., I'll go over your solution again tomorrow (and see if I can make
> it work)


Oh, the suspense, well?

Ron


Mel Smith

2005-09-05, 6:55 pm

Jimmy,

Thanks for the large and detailed offering. Will puzzle on it later
next w.

btw, when I run a 3rd party windows app (rrwrun.exe) to print a
windows-based report, I always return to my Clipper 5.2e app when exiting
the R&R exe. But this consistently works only on a win98se platform. On
Win2k, it also works, but on WinXP, you have to 'click' to get back to
Clipper.

Thanks to everyone (on this Labour Day long wend)

-Mel Smith


Phil Barnett

2005-09-05, 6:55 pm

On Thu, 01 Sep 2005 09:36:21 -0400, Paul Tucker wrote:

> Likewise. It's been.... many harvests!


N kidding...
Ron Pinkas

2005-09-06, 3:55 am

> Oh, the suspense, well?

Mel, could you kindly report your test results?

Ron


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com